github.com/slene/docker@v1.8.0-rc1/docs/reference/api/docker_remote_api_v1.18.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API v1.18"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent = "smn_remoteapi"
     8  weight = 3
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API v1.18
    13  
    14  ## 1. Brief introduction
    15  
    16   - The Remote API has replaced `rcli`.
    17   - The daemon listens on `unix:///var/run/docker.sock` but you can
    18     [Bind Docker to another host/port or a Unix socket](
    19     /articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket).
    20   - The API tends to be REST, but for some complex commands, like `attach`
    21     or `pull`, the HTTP connection is hijacked to transport `STDOUT`,
    22     `STDIN` and `STDERR`.
    23  
    24  # 2. Endpoints
    25  
    26  ## 2.1 Containers
    27  
    28  ### List containers
    29  
    30  `GET /containers/json`
    31  
    32  List containers
    33  
    34  **Example request**:
    35  
    36          GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    37  
    38  **Example response**:
    39  
    40          HTTP/1.1 200 OK
    41          Content-Type: application/json
    42  
    43          [
    44               {
    45                       "Id": "8dfafdbc3a40",
    46                       "Names":["/boring_feynman"],
    47                       "Image": "ubuntu:latest",
    48                       "Command": "echo 1",
    49                       "Created": 1367854155,
    50                       "Status": "Exit 0",
    51                       "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    52                       "SizeRw": 12288,
    53                       "SizeRootFs": 0
    54               },
    55               {
    56                       "Id": "9cd87474be90",
    57                       "Names":["/coolName"],
    58                       "Image": "ubuntu:latest",
    59                       "Command": "echo 222222",
    60                       "Created": 1367854155,
    61                       "Status": "Exit 0",
    62                       "Ports": [],
    63                       "SizeRw": 12288,
    64                       "SizeRootFs": 0
    65               },
    66               {
    67                       "Id": "3176a2479c92",
    68                       "Names":["/sleepy_dog"],
    69                       "Image": "ubuntu:latest",
    70                       "Command": "echo 3333333333333333",
    71                       "Created": 1367854154,
    72                       "Status": "Exit 0",
    73                       "Ports":[],
    74                       "SizeRw":12288,
    75                       "SizeRootFs":0
    76               },
    77               {
    78                       "Id": "4cb07b47f9fb",
    79                       "Names":["/running_cat"],
    80                       "Image": "ubuntu:latest",
    81                       "Command": "echo 444444444444444444444444444444444",
    82                       "Created": 1367854152,
    83                       "Status": "Exit 0",
    84                       "Ports": [],
    85                       "SizeRw": 12288,
    86                       "SizeRootFs": 0
    87               }
    88          ]
    89  
    90  Query Parameters:
    91  
    92  -   **all** – 1/True/true or 0/False/false, Show all containers.
    93          Only running containers are shown by default (i.e., this defaults to false)
    94  -   **limit** – Show `limit` last created
    95          containers, include non-running ones.
    96  -   **since** – Show only containers created since Id, include
    97          non-running ones.
    98  -   **before** – Show only containers created before Id, include
    99          non-running ones.
   100  -   **size** – 1/True/true or 0/False/false, Show the containers
   101          sizes
   102  -   **filters** - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
   103    -   exited=&lt;int&gt; -- containers with exit code of &lt;int&gt;
   104    -   status=(restarting|running|paused|exited)
   105    -   label=`key` or `label="key=value"` of a container label
   106  
   107  Status Codes:
   108  
   109  -   **200** – no error
   110  -   **400** – bad parameter
   111  -   **500** – server error
   112  
   113  ### Create a container
   114  
   115  `POST /containers/create`
   116  
   117  Create a container
   118  
   119  **Example request**:
   120  
   121          POST /containers/create HTTP/1.1
   122          Content-Type: application/json
   123  
   124          {
   125               "Hostname": "",
   126               "Domainname": "",
   127               "User": "",
   128               "AttachStdin": false,
   129               "AttachStdout": true,
   130               "AttachStderr": true,
   131               "Tty": false,
   132               "OpenStdin": false,
   133               "StdinOnce": false,
   134               "Env": null,
   135               "Cmd": [
   136                       "date"
   137               ],
   138               "Entrypoint": "",
   139               "Image": "ubuntu",
   140               "Labels": {
   141                       "com.example.vendor": "Acme",
   142                       "com.example.license": "GPL",
   143                       "com.example.version": "1.0"
   144               },
   145               "Volumes": {
   146                       "/tmp": {}
   147               },
   148               "WorkingDir": "",
   149               "NetworkDisabled": false,
   150               "MacAddress": "12:34:56:78:9a:bc",
   151               "ExposedPorts": {
   152                       "22/tcp": {}
   153               },
   154               "HostConfig": {
   155                 "Binds": ["/tmp:/tmp"],
   156                 "Links": ["redis3:redis"],
   157                 "LxcConf": {"lxc.utsname":"docker"},
   158                 "Memory": 0,
   159                 "MemorySwap": 0,
   160                 "CpuShares": 512,
   161                 "CpusetCpus": "0,1",
   162                 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   163                 "PublishAllPorts": false,
   164                 "Privileged": false,
   165                 "ReadonlyRootfs": false,
   166                 "Dns": ["8.8.8.8"],
   167                 "DnsSearch": [""],
   168                 "ExtraHosts": null,
   169                 "VolumesFrom": ["parent", "other:ro"],
   170                 "CapAdd": ["NET_ADMIN"],
   171                 "CapDrop": ["MKNOD"],
   172                 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   173                 "NetworkMode": "bridge",
   174                 "Devices": [],
   175                 "Ulimits": [{}],
   176                 "LogConfig": { "Type": "json-file", Config: {} },
   177                 "SecurityOpt": [""],
   178                 "CgroupParent": ""
   179              }
   180          }
   181  
   182  **Example response**:
   183  
   184          HTTP/1.1 201 Created
   185          Content-Type: application/json
   186  
   187          {
   188               "Id":"e90e34656806"
   189               "Warnings":[]
   190          }
   191  
   192  Json Parameters:
   193  
   194  -   **Hostname** - A string value containing the desired hostname to use for the
   195        container.
   196  -   **Domainname** - A string value containing the desired domain name to use
   197        for the container.
   198  -   **User** - A string value containing the user to use inside the container.
   199  -   **Memory** - Memory limit in bytes.
   200  -   **MemorySwap**- Total memory limit (memory + swap); set `-1` to disable swap,
   201        always use this with `memory`, and make the value larger than `memory`.
   202  -   **CpuShares** - An integer value containing the CPU Shares for container
   203        (ie. the relative weight vs other containers).
   204  -   **Cpuset** - The same as CpusetCpus, but deprecated, please don't use.
   205  -   **CpusetCpus** - String value containing the cgroups CpusetCpus to use.
   206  -   **AttachStdin** - Boolean value, attaches to stdin.
   207  -   **AttachStdout** - Boolean value, attaches to stdout.
   208  -   **AttachStderr** - Boolean value, attaches to stderr.
   209  -   **Tty** - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.
   210  -   **OpenStdin** - Boolean value, opens stdin,
   211  -   **StdinOnce** - Boolean value, close stdin after the 1 attached client disconnects.
   212  -   **Env** - A list of environment variables in the form of `VAR=value`
   213  -   **Labels** - Adds a map of labels that to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}`
   214  -   **Cmd** - Command to run specified as a string or an array of strings.
   215  -   **Entrypoint** - Set the entrypoint for the container a string or an array
   216        of strings
   217  -   **Image** - String value containing the image name to use for the container
   218  -   **Volumes** – An object mapping mountpoint paths (strings) inside the
   219        container to empty objects.
   220  -   **WorkingDir** - A string value containing the working dir for commands to
   221        run in.
   222  -   **NetworkDisabled** - Boolean value, when true disables networking for the
   223        container
   224  -   **ExposedPorts** - An object mapping ports to an empty object in the form of:
   225        `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
   226  -   **HostConfig**
   227      -   **Binds** – A list of volume bindings for this container. Each volume
   228              binding is a string of the form `container_path` (to create a new
   229              volume for the container), `host_path:container_path` (to bind-mount
   230              a host path into the container), or `host_path:container_path:ro`
   231              (to make the bind-mount read-only inside the container).
   232      -   **Links** - A list of links for the container. Each link entry should be
   233            in the form of `container_name:alias`.
   234      -   **LxcConf** - LXC specific configurations. These configurations will only
   235            work when using the `lxc` execution driver.
   236      -   **PortBindings** - A map of exposed container ports and the host port they
   237            should map to. It should be specified in the form
   238            `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   239            Take note that `port` is specified as a string and not an integer value.
   240      -   **PublishAllPorts** - Allocates a random host port for all of a container's
   241            exposed ports. Specified as a boolean value.
   242      -   **Privileged** - Gives the container full access to the host. Specified as
   243            a boolean value.
   244      -   **ReadonlyRootfs** - Mount the container's root filesystem as read only.
   245            Specified as a boolean value.
   246      -   **Dns** - A list of dns servers for the container to use.
   247      -   **DnsSearch** - A list of DNS search domains
   248      -   **ExtraHosts** - A list of hostnames/IP mappings to be added to the
   249          container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
   250      -   **VolumesFrom** - A list of volumes to inherit from another container.
   251            Specified in the form `<container name>[:<ro|rw>]`
   252      -   **CapAdd** - A list of kernel capabilities to add to the container.
   253      -   **Capdrop** - A list of kernel capabilities to drop from the container.
   254      -   **RestartPolicy** – The behavior to apply when the container exits.  The
   255              value is an object with a `Name` property of either `"always"` to
   256              always restart or `"on-failure"` to restart only when the container
   257              exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   258              controls the number of times to retry before giving up.
   259              The default is not to restart. (optional)
   260              An ever increasing delay (double the previous delay, starting at 100mS)
   261              is added before each restart to prevent flooding the server.
   262      -   **NetworkMode** - Sets the networking mode for the container. Supported
   263            values are: `bridge`, `host`, and `container:<name|id>`
   264      -   **Devices** - A list of devices to add to the container specified in the
   265            form
   266            `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   267      -   **Ulimits** - A list of ulimits to be set in the container, specified as
   268            `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
   269            `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard", 2048 }}`
   270      -   **SecurityOpt**: A list of string values to customize labels for MLS
   271          systems, such as SELinux.
   272      -   **LogConfig** - Log configuration for the container, specified as
   273            `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
   274            Available types: `json-file`, `syslog`, `none`.
   275            `json-file` logging driver.
   276      -   **CgroupParent** - Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
   277  
   278  Query Parameters:
   279  
   280  -   **name** – Assign the specified name to the container. Must
   281      match `/?[a-zA-Z0-9_-]+`.
   282  
   283  Status Codes:
   284  
   285  -   **201** – no error
   286  -   **404** – no such container
   287  -   **406** – impossible to attach (container not running)
   288  -   **500** – server error
   289  
   290  ### Inspect a container
   291  
   292  `GET /containers/(id)/json`
   293  
   294  Return low-level information on the container `id`
   295  
   296  
   297  **Example request**:
   298  
   299          GET /containers/4fa6e0f0c678/json HTTP/1.1
   300  
   301  **Example response**:
   302  
   303          HTTP/1.1 200 OK
   304          Content-Type: application/json
   305  
   306  	{
   307  		"AppArmorProfile": "",
   308  		"Args": [
   309  			"-c",
   310  			"exit 9"
   311  		],
   312  		"Config": {
   313  			"AttachStderr": true,
   314  			"AttachStdin": false,
   315  			"AttachStdout": true,
   316  			"Cmd": [
   317  				"/bin/sh",
   318  				"-c",
   319  				"exit 9"
   320  			],
   321  			"Domainname": "",
   322  			"Entrypoint": null,
   323  			"Env": [
   324  				"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   325  			],
   326  			"ExposedPorts": null,
   327  			"Hostname": "ba033ac44011",
   328  			"Image": "ubuntu",
   329  			"Labels": {
   330  				"com.example.vendor": "Acme",
   331  				"com.example.license": "GPL",
   332  				"com.example.version": "1.0"
   333  			},
   334  			"MacAddress": "",
   335  			"NetworkDisabled": false,
   336  			"OnBuild": null,
   337  			"OpenStdin": false,
   338  			"PortSpecs": null,
   339  			"StdinOnce": false,
   340  			"Tty": false,
   341  			"User": "",
   342  			"Volumes": null,
   343  			"WorkingDir": ""
   344  		},
   345  		"Created": "2015-01-06T15:47:31.485331387Z",
   346  		"Driver": "devicemapper",
   347  		"ExecDriver": "native-0.2",
   348  		"ExecIDs": null,
   349  		"HostConfig": {
   350  			"Binds": null,
   351  			"CapAdd": null,
   352  			"CapDrop": null,
   353  			"ContainerIDFile": "",
   354  			"CpusetCpus": "",
   355  			"CpuShares": 0,
   356  			"Devices": [],
   357  			"Dns": null,
   358  			"DnsSearch": null,
   359  			"ExtraHosts": null,
   360  			"IpcMode": "",
   361  			"Links": null,
   362  			"LxcConf": [],
   363  			"Memory": 0,
   364  			"MemorySwap": 0,
   365  			"NetworkMode": "bridge",
   366  			"PortBindings": {},
   367  			"Privileged": false,
   368  			"ReadonlyRootfs": false,
   369  			"PublishAllPorts": false,
   370  			"RestartPolicy": {
   371  				"MaximumRetryCount": 2,
   372  				"Name": "on-failure"
   373  			},
   374  			"LogConfig": {
   375  				"Config": null,
   376  				"Type": "json-file"
   377  			},
   378  			"SecurityOpt": null,
   379  			"VolumesFrom": null,
   380  			"Ulimits": [{}]
   381  		},
   382  		"HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
   383  		"HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
   384  		"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
   385  		"Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
   386  		"Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
   387  		"MountLabel": "",
   388  		"Name": "/boring_euclid",
   389  		"NetworkSettings": {
   390  			"Bridge": "",
   391  			"Gateway": "",
   392  			"IPAddress": "",
   393  			"IPPrefixLen": 0,
   394  			"MacAddress": "",
   395  			"PortMapping": null,
   396  			"Ports": null
   397  		},
   398  		"Path": "/bin/sh",
   399  		"ProcessLabel": "",
   400  		"ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
   401  		"RestartCount": 1,
   402  		"State": {
   403  			"Error": "",
   404  			"ExitCode": 9,
   405  			"FinishedAt": "2015-01-06T15:47:32.080254511Z",
   406  			"OOMKilled": false,
   407  			"Paused": false,
   408  			"Pid": 0,
   409  			"Restarting": false,
   410  			"Running": false,
   411  			"StartedAt": "2015-01-06T15:47:32.072697474Z"
   412  		},
   413  		"Volumes": {},
   414  		"VolumesRW": {}
   415  	}
   416  
   417  Status Codes:
   418  
   419  -   **200** – no error
   420  -   **404** – no such container
   421  -   **500** – server error
   422  
   423  ### List processes running inside a container
   424  
   425  `GET /containers/(id)/top`
   426  
   427  List processes running inside the container `id`
   428  
   429  **Example request**:
   430  
   431          GET /containers/4fa6e0f0c678/top HTTP/1.1
   432  
   433  **Example response**:
   434  
   435          HTTP/1.1 200 OK
   436          Content-Type: application/json
   437  
   438          {
   439               "Titles": [
   440                       "USER",
   441                       "PID",
   442                       "%CPU",
   443                       "%MEM",
   444                       "VSZ",
   445                       "RSS",
   446                       "TTY",
   447                       "STAT",
   448                       "START",
   449                       "TIME",
   450                       "COMMAND"
   451                       ],
   452               "Processes": [
   453                       ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
   454                       ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
   455               ]
   456          }
   457  
   458  Query Parameters:
   459  
   460  -   **ps_args** – ps arguments to use (e.g., aux)
   461  
   462  Status Codes:
   463  
   464  -   **200** – no error
   465  -   **404** – no such container
   466  -   **500** – server error
   467  
   468  ### Get container logs
   469  
   470  `GET /containers/(id)/logs`
   471  
   472  Get stdout and stderr logs from the container ``id``
   473  
   474  > **Note**:
   475  > This endpoint works only for containers with `json-file` logging driver.
   476  
   477  **Example request**:
   478  
   479         GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1&timestamps=1&follow=1&tail=10 HTTP/1.1
   480  
   481  **Example response**:
   482  
   483         HTTP/1.1 101 UPGRADED
   484         Content-Type: application/vnd.docker.raw-stream
   485         Connection: Upgrade
   486         Upgrade: tcp
   487  
   488         {{ STREAM }}
   489  
   490  Query Parameters:
   491  
   492  -   **follow** – 1/True/true or 0/False/false, return stream. Default false
   493  -   **stdout** – 1/True/true or 0/False/false, show stdout log. Default false
   494  -   **stderr** – 1/True/true or 0/False/false, show stderr log. Default false
   495  -   **timestamps** – 1/True/true or 0/False/false, print timestamps for
   496          every log line. Default false
   497  -   **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all
   498  
   499  Status Codes:
   500  
   501  -   **101** – no error, hints proxy about hijacking
   502  -   **200** – no error, no upgrade header found
   503  -   **404** – no such container
   504  -   **500** – server error
   505  
   506  ### Inspect changes on a container's filesystem
   507  
   508  `GET /containers/(id)/changes`
   509  
   510  Inspect changes on container `id`'s filesystem
   511  
   512  **Example request**:
   513  
   514          GET /containers/4fa6e0f0c678/changes HTTP/1.1
   515  
   516  **Example response**:
   517  
   518          HTTP/1.1 200 OK
   519          Content-Type: application/json
   520  
   521          [
   522               {
   523                       "Path": "/dev",
   524                       "Kind": 0
   525               },
   526               {
   527                       "Path": "/dev/kmsg",
   528                       "Kind": 1
   529               },
   530               {
   531                       "Path": "/test",
   532                       "Kind": 1
   533               }
   534          ]
   535  
   536  Values for `Kind`:
   537  
   538  - `0`: Modify
   539  - `1`: Add
   540  - `2`: Delete
   541  
   542  Status Codes:
   543  
   544  -   **200** – no error
   545  -   **404** – no such container
   546  -   **500** – server error
   547  
   548  ### Export a container
   549  
   550  `GET /containers/(id)/export`
   551  
   552  Export the contents of container `id`
   553  
   554  **Example request**:
   555  
   556          GET /containers/4fa6e0f0c678/export HTTP/1.1
   557  
   558  **Example response**:
   559  
   560          HTTP/1.1 200 OK
   561          Content-Type: application/octet-stream
   562  
   563          {{ TAR STREAM }}
   564  
   565  Status Codes:
   566  
   567  -   **200** – no error
   568  -   **404** – no such container
   569  -   **500** – server error
   570  
   571  ### Get container stats based on resource usage
   572  
   573  `GET /containers/(id)/stats`
   574  
   575  This endpoint returns a live stream of a container's resource usage statistics.
   576  
   577  > **Note**: this functionality currently only works when using the *libcontainer* exec-driver.
   578  
   579  **Example request**:
   580  
   581          GET /containers/redis1/stats HTTP/1.1
   582  
   583  **Example response**:
   584  
   585          HTTP/1.1 200 OK
   586          Content-Type: application/json
   587  
   588          {
   589             "read" : "2015-01-08T22:57:31.547920715Z",
   590             "network" : {
   591                "rx_dropped" : 0,
   592                "rx_bytes" : 648,
   593                "rx_errors" : 0,
   594                "tx_packets" : 8,
   595                "tx_dropped" : 0,
   596                "rx_packets" : 8,
   597                "tx_errors" : 0,
   598                "tx_bytes" : 648
   599             },
   600             "memory_stats" : {
   601                "stats" : {
   602                   "total_pgmajfault" : 0,
   603                   "cache" : 0,
   604                   "mapped_file" : 0,
   605                   "total_inactive_file" : 0,
   606                   "pgpgout" : 414,
   607                   "rss" : 6537216,
   608                   "total_mapped_file" : 0,
   609                   "writeback" : 0,
   610                   "unevictable" : 0,
   611                   "pgpgin" : 477,
   612                   "total_unevictable" : 0,
   613                   "pgmajfault" : 0,
   614                   "total_rss" : 6537216,
   615                   "total_rss_huge" : 6291456,
   616                   "total_writeback" : 0,
   617                   "total_inactive_anon" : 0,
   618                   "rss_huge" : 6291456,
   619                   "hierarchical_memory_limit" : 67108864,
   620                   "total_pgfault" : 964,
   621                   "total_active_file" : 0,
   622                   "active_anon" : 6537216,
   623                   "total_active_anon" : 6537216,
   624                   "total_pgpgout" : 414,
   625                   "total_cache" : 0,
   626                   "inactive_anon" : 0,
   627                   "active_file" : 0,
   628                   "pgfault" : 964,
   629                   "inactive_file" : 0,
   630                   "total_pgpgin" : 477
   631                },
   632                "max_usage" : 6651904,
   633                "usage" : 6537216,
   634                "failcnt" : 0,
   635                "limit" : 67108864
   636             },
   637             "blkio_stats" : {},
   638             "cpu_stats" : {
   639                "cpu_usage" : {
   640                   "percpu_usage" : [
   641                      16970827,
   642                      1839451,
   643                      7107380,
   644                      10571290
   645                   ],
   646                   "usage_in_usermode" : 10000000,
   647                   "total_usage" : 36488948,
   648                   "usage_in_kernelmode" : 20000000
   649                },
   650                "system_cpu_usage" : 20091722000000000,
   651                "throttling_data" : {}
   652             }
   653          }
   654  
   655  Status Codes:
   656  
   657  -   **200** – no error
   658  -   **404** – no such container
   659  -   **500** – server error
   660  
   661  ### Resize a container TTY
   662  
   663  `POST /containers/(id)/resize?h=<height>&w=<width>`
   664  
   665  Resize the TTY for container with  `id`. The container must be restarted for the resize to take effect.
   666  
   667  **Example request**:
   668  
   669          POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   670  
   671  **Example response**:
   672  
   673          HTTP/1.1 200 OK
   674          Content-Length: 0
   675          Content-Type: text/plain; charset=utf-8
   676  
   677  Status Codes:
   678  
   679  -   **200** – no error
   680  -   **404** – No such container
   681  -   **500** – Cannot resize container
   682  
   683  ### Start a container
   684  
   685  `POST /containers/(id)/start`
   686  
   687  Start the container `id`
   688  
   689  > **Note**:
   690  > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
   691  > See [create a container](#create-a-container) for details.
   692  
   693  **Example request**:
   694  
   695          POST /containers/(id)/start HTTP/1.1
   696  
   697  **Example response**:
   698  
   699          HTTP/1.1 204 No Content
   700  
   701  Status Codes:
   702  
   703  -   **204** – no error
   704  -   **304** – container already started
   705  -   **404** – no such container
   706  -   **500** – server error
   707  
   708  ### Stop a container
   709  
   710  `POST /containers/(id)/stop`
   711  
   712  Stop the container `id`
   713  
   714  **Example request**:
   715  
   716          POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   717  
   718  **Example response**:
   719  
   720          HTTP/1.1 204 No Content
   721  
   722  Query Parameters:
   723  
   724  -   **t** – number of seconds to wait before killing the container
   725  
   726  Status Codes:
   727  
   728  -   **204** – no error
   729  -   **304** – container already stopped
   730  -   **404** – no such container
   731  -   **500** – server error
   732  
   733  ### Restart a container
   734  
   735  `POST /containers/(id)/restart`
   736  
   737  Restart the container `id`
   738  
   739  **Example request**:
   740  
   741          POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   742  
   743  **Example response**:
   744  
   745          HTTP/1.1 204 No Content
   746  
   747  Query Parameters:
   748  
   749  -   **t** – number of seconds to wait before killing the container
   750  
   751  Status Codes:
   752  
   753  -   **204** – no error
   754  -   **404** – no such container
   755  -   **500** – server error
   756  
   757  ### Kill a container
   758  
   759  `POST /containers/(id)/kill`
   760  
   761  Kill the container `id`
   762  
   763  **Example request**:
   764  
   765          POST /containers/e90e34656806/kill HTTP/1.1
   766  
   767  **Example response**:
   768  
   769          HTTP/1.1 204 No Content
   770  
   771  Query Parameters
   772  
   773  -   **signal** - Signal to send to the container: integer or string like "SIGINT".
   774          When not set, SIGKILL is assumed and the call will waits for the container to exit.
   775  
   776  Status Codes:
   777  
   778  -   **204** – no error
   779  -   **404** – no such container
   780  -   **500** – server error
   781  
   782  ### Rename a container
   783  
   784  `POST /containers/(id)/rename`
   785  
   786  Rename the container `id` to a `new_name`
   787  
   788  **Example request**:
   789  
   790          POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
   791  
   792  **Example response**:
   793  
   794          HTTP/1.1 204 No Content
   795  
   796  Query Parameters:
   797  
   798  -   **name** – new name for the container
   799  
   800  Status Codes:
   801  
   802  -   **204** – no error
   803  -   **404** – no such container
   804  -   **409** - conflict name already assigned
   805  -   **500** – server error
   806  
   807  ### Pause a container
   808  
   809  `POST /containers/(id)/pause`
   810  
   811  Pause the container `id`
   812  
   813  **Example request**:
   814  
   815          POST /containers/e90e34656806/pause HTTP/1.1
   816  
   817  **Example response**:
   818  
   819          HTTP/1.1 204 No Content
   820  
   821  Status Codes:
   822  
   823  -   **204** – no error
   824  -   **404** – no such container
   825  -   **500** – server error
   826  
   827  ### Unpause a container
   828  
   829  `POST /containers/(id)/unpause`
   830  
   831  Unpause the container `id`
   832  
   833  **Example request**:
   834  
   835          POST /containers/e90e34656806/unpause HTTP/1.1
   836  
   837  **Example response**:
   838  
   839          HTTP/1.1 204 No Content
   840  
   841  Status Codes:
   842  
   843  -   **204** – no error
   844  -   **404** – no such container
   845  -   **500** – server error
   846  
   847  ### Attach to a container
   848  
   849  `POST /containers/(id)/attach`
   850  
   851  Attach to the container `id`
   852  
   853  **Example request**:
   854  
   855          POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   856  
   857  **Example response**:
   858  
   859          HTTP/1.1 101 UPGRADED
   860          Content-Type: application/vnd.docker.raw-stream
   861          Connection: Upgrade
   862          Upgrade: tcp
   863  
   864          {{ STREAM }}
   865  
   866  Query Parameters:
   867  
   868  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   869  -   **stream** – 1/True/true or 0/False/false, return stream.
   870          Default false
   871  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   872          to stdin. Default false
   873  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   874          stdout log, if stream=true, attach to stdout. Default false
   875  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   876          stderr log, if stream=true, attach to stderr. Default false
   877  
   878  Status Codes:
   879  
   880  -   **101** – no error, hints proxy about hijacking
   881  -   **200** – no error, no upgrade header found
   882  -   **400** – bad parameter
   883  -   **404** – no such container
   884  -   **500** – server error
   885  
   886      **Stream details**:
   887  
   888      When using the TTY setting is enabled in
   889      [`POST /containers/create`
   890      ](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"),
   891      the stream is the raw data from the process PTY and client's stdin.
   892      When the TTY is disabled, then the stream is multiplexed to separate
   893      stdout and stderr.
   894  
   895      The format is a **Header** and a **Payload** (frame).
   896  
   897      **HEADER**
   898  
   899      The header will contain the information on which stream write the
   900      stream (stdout or stderr). It also contain the size of the
   901      associated frame encoded on the last 4 bytes (uint32).
   902  
   903      It is encoded on the first 8 bytes like this:
   904  
   905          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
   906  
   907      `STREAM_TYPE` can be:
   908  
   909  -   0: stdin (will be written on stdout)
   910  -   1: stdout
   911  -   2: stderr
   912  
   913      `SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of
   914      the uint32 size encoded as big endian.
   915  
   916      **PAYLOAD**
   917  
   918      The payload is the raw stream.
   919  
   920      **IMPLEMENTATION**
   921  
   922      The simplest way to implement the Attach protocol is the following:
   923  
   924      1.  Read 8 bytes
   925      2.  chose stdout or stderr depending on the first byte
   926      3.  Extract the frame size from the last 4 bytes
   927      4.  Read the extracted size and output it on the correct output
   928      5.  Goto 1
   929  
   930  ### Attach to a container (websocket)
   931  
   932  `GET /containers/(id)/attach/ws`
   933  
   934  Attach to the container `id` via websocket
   935  
   936  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
   937  
   938  **Example request**
   939  
   940          GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
   941  
   942  **Example response**
   943  
   944          {{ STREAM }}
   945  
   946  Query Parameters:
   947  
   948  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   949  -   **stream** – 1/True/true or 0/False/false, return stream.
   950          Default false
   951  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   952          to stdin. Default false
   953  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   954          stdout log, if stream=true, attach to stdout. Default false
   955  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   956          stderr log, if stream=true, attach to stderr. Default false
   957  
   958  Status Codes:
   959  
   960  -   **200** – no error
   961  -   **400** – bad parameter
   962  -   **404** – no such container
   963  -   **500** – server error
   964  
   965  ### Wait a container
   966  
   967  `POST /containers/(id)/wait`
   968  
   969  Block until container `id` stops, then returns the exit code
   970  
   971  **Example request**:
   972  
   973          POST /containers/16253994b7c4/wait HTTP/1.1
   974  
   975  **Example response**:
   976  
   977          HTTP/1.1 200 OK
   978          Content-Type: application/json
   979  
   980          {"StatusCode": 0}
   981  
   982  Status Codes:
   983  
   984  -   **200** – no error
   985  -   **404** – no such container
   986  -   **500** – server error
   987  
   988  ### Remove a container
   989  
   990  `DELETE /containers/(id)`
   991  
   992  Remove the container `id` from the filesystem
   993  
   994  **Example request**:
   995  
   996          DELETE /containers/16253994b7c4?v=1 HTTP/1.1
   997  
   998  **Example response**:
   999  
  1000          HTTP/1.1 204 No Content
  1001  
  1002  Query Parameters:
  1003  
  1004  -   **v** – 1/True/true or 0/False/false, Remove the volumes
  1005          associated to the container. Default false
  1006  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
  1007          Default false
  1008  
  1009  Status Codes:
  1010  
  1011  -   **204** – no error
  1012  -   **400** – bad parameter
  1013  -   **404** – no such container
  1014  -   **500** – server error
  1015  
  1016  ### Copy files or folders from a container
  1017  
  1018  `POST /containers/(id)/copy`
  1019  
  1020  Copy files or folders of container `id`
  1021  
  1022  **Example request**:
  1023  
  1024          POST /containers/4fa6e0f0c678/copy HTTP/1.1
  1025          Content-Type: application/json
  1026  
  1027          {
  1028               "Resource": "test.txt"
  1029          }
  1030  
  1031  **Example response**:
  1032  
  1033          HTTP/1.1 200 OK
  1034          Content-Type: application/x-tar
  1035  
  1036          {{ TAR STREAM }}
  1037  
  1038  Status Codes:
  1039  
  1040  -   **200** – no error
  1041  -   **404** – no such container
  1042  -   **500** – server error
  1043  
  1044  ## 2.2 Images
  1045  
  1046  ### List Images
  1047  
  1048  `GET /images/json`
  1049  
  1050  **Example request**:
  1051  
  1052          GET /images/json?all=0 HTTP/1.1
  1053  
  1054  **Example response**:
  1055  
  1056          HTTP/1.1 200 OK
  1057          Content-Type: application/json
  1058  
  1059          [
  1060            {
  1061               "RepoTags": [
  1062                 "ubuntu:12.04",
  1063                 "ubuntu:precise",
  1064                 "ubuntu:latest"
  1065               ],
  1066               "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
  1067               "Created": 1365714795,
  1068               "Size": 131506275,
  1069               "VirtualSize": 131506275
  1070            },
  1071            {
  1072               "RepoTags": [
  1073                 "ubuntu:12.10",
  1074                 "ubuntu:quantal"
  1075               ],
  1076               "ParentId": "27cf784147099545",
  1077               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1078               "Created": 1364102658,
  1079               "Size": 24653,
  1080               "VirtualSize": 180116135
  1081            }
  1082          ]
  1083  
  1084  **Example request, with digest information**:
  1085  
  1086          GET /images/json?digests=1 HTTP/1.1
  1087  
  1088  **Example response, with digest information**:
  1089  
  1090          HTTP/1.1 200 OK
  1091          Content-Type: application/json
  1092  
  1093          [
  1094            {
  1095              "Created": 1420064636,
  1096              "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
  1097              "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
  1098              "RepoDigests": [
  1099                "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
  1100              ],
  1101              "RepoTags": [
  1102                "localhost:5000/test/busybox:latest",
  1103                "playdate:latest"
  1104              ],
  1105              "Size": 0,
  1106              "VirtualSize": 2429728
  1107            }
  1108          ]
  1109  
  1110  The response shows a single image `Id` associated with two repositories
  1111  (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use
  1112  either of the `RepoTags` values `localhost:5000/test/busybox:latest` or
  1113  `playdate:latest` to reference the image.
  1114  
  1115  You can also use `RepoDigests` values to reference an image. In this response,
  1116  the array has only one reference and that is to the
  1117  `localhost:5000/test/busybox` repository; the `playdate` repository has no
  1118  digest. You can reference this digest using the value:
  1119  `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
  1120  
  1121  See the `docker run` and `docker build` commands for examples of digest and tag
  1122  references on the command line.
  1123  
  1124  Query Parameters:
  1125  
  1126  -   **all** – 1/True/true or 0/False/false, default false
  1127  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
  1128    -   dangling=true
  1129    -   label=`key` or `label="key=value"` of an image label
  1130  -   **filter** - only return images with the specified name
  1131  
  1132  ### Build image from a Dockerfile
  1133  
  1134  `POST /build`
  1135  
  1136  Build an image from a Dockerfile
  1137  
  1138  **Example request**:
  1139  
  1140          POST /build HTTP/1.1
  1141  
  1142          {{ TAR STREAM }}
  1143  
  1144  **Example response**:
  1145  
  1146          HTTP/1.1 200 OK
  1147          Content-Type: application/json
  1148  
  1149          {"stream": "Step 1..."}
  1150          {"stream": "..."}
  1151          {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1152  
  1153  The input stream must be a tar archive compressed with one of the
  1154  following algorithms: identity (no compression), gzip, bzip2, xz.
  1155  
  1156  The archive must include a build instructions file, typically called
  1157  `Dockerfile` at the root of the archive. The `dockerfile` parameter may be
  1158  used to specify a different build instructions file by having its value be
  1159  the path to the alternate build instructions file to use.
  1160  
  1161  The archive may include any number of other files,
  1162  which will be accessible in the build context (See the [*ADD build
  1163  command*](/reference/builder/#dockerbuilder)).
  1164  
  1165  The build will also be canceled if the client drops the connection by quitting
  1166  or being killed.
  1167  
  1168  Query Parameters:
  1169  
  1170  -   **dockerfile** - path within the build context to the Dockerfile. This is 
  1171          ignored if `remote` is specified and points to an individual filename.
  1172  -   **t** – repository name (and optionally a tag) to be applied to
  1173          the resulting image in case of success
  1174  -   **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the 
  1175          URI specifies a filename, the file's contents are placed into a file 
  1176  		called `Dockerfile`.
  1177  -   **q** – suppress verbose build output
  1178  -   **nocache** – do not use the cache when building the image
  1179  -   **pull** - attempt to pull the image even if an older image exists locally
  1180  -   **rm** - remove intermediate containers after a successful build (default behavior)
  1181  -   **forcerm** - always remove intermediate containers (includes rm)
  1182  -   **memory** - set memory limit for build
  1183  -   **memswap** - Total memory (memory + swap), `-1` to disable swap
  1184  -   **cpushares** - CPU shares (relative weight)
  1185  -   **cpusetcpus** - CPUs in which to allow execution, e.g., `0-3`, `0,1`
  1186  
  1187      Request Headers:
  1188  
  1189  -   **Content-type** – should be set to `"application/tar"`.
  1190  -   **X-Registry-Config** – base64-encoded ConfigFile object
  1191  
  1192  Status Codes:
  1193  
  1194  -   **200** – no error
  1195  -   **500** – server error
  1196  
  1197  ### Create an image
  1198  
  1199  `POST /images/create`
  1200  
  1201  Create an image, either by pulling it from the registry or by importing it
  1202  
  1203  **Example request**:
  1204  
  1205          POST /images/create?fromImage=ubuntu HTTP/1.1
  1206  
  1207  **Example response**:
  1208  
  1209          HTTP/1.1 200 OK
  1210          Content-Type: application/json
  1211  
  1212          {"status": "Pulling..."}
  1213          {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
  1214          {"error": "Invalid..."}
  1215          ...
  1216  
  1217      When using this endpoint to pull an image from the registry, the
  1218      `X-Registry-Auth` header can be used to include
  1219      a base64-encoded AuthConfig object.
  1220  
  1221  Query Parameters:
  1222  
  1223  -   **fromImage** – name of the image to pull
  1224  -   **fromSrc** – source to import.  The value may be a URL from which the image
  1225          can be retrieved or `-` to read the image from the request body.
  1226  -   **repo** – repository
  1227  -   **tag** – tag
  1228  -   **registry** – the registry to pull from
  1229  
  1230      Request Headers:
  1231  
  1232  -   **X-Registry-Auth** – base64-encoded AuthConfig object
  1233  
  1234  Status Codes:
  1235  
  1236  -   **200** – no error
  1237  -   **500** – server error
  1238  
  1239  
  1240  
  1241  ### Inspect an image
  1242  
  1243  `GET /images/(name)/json`
  1244  
  1245  Return low-level information on the image `name`
  1246  
  1247  **Example request**:
  1248  
  1249          GET /images/ubuntu/json HTTP/1.1
  1250  
  1251  **Example response**:
  1252  
  1253          HTTP/1.1 200 OK
  1254          Content-Type: application/json
  1255  
  1256          {
  1257               "Created": "2013-03-23T22:24:18.818426-07:00",
  1258               "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  1259               "ContainerConfig":
  1260                       {
  1261                               "Hostname": "",
  1262                               "User": "",
  1263                               "AttachStdin": false,
  1264                               "AttachStdout": false,
  1265                               "AttachStderr": false,
  1266                               "PortSpecs": null,
  1267                               "Tty": true,
  1268                               "OpenStdin": true,
  1269                               "StdinOnce": false,
  1270                               "Env": null,
  1271                               "Cmd": ["/bin/bash"],
  1272                               "Dns": null,
  1273                               "Image": "ubuntu",
  1274                               "Labels": {
  1275                                   "com.example.vendor": "Acme",
  1276                                   "com.example.license": "GPL",
  1277                                   "com.example.version": "1.0"
  1278                               },
  1279                               "Volumes": null,
  1280                               "VolumesFrom": "",
  1281                               "WorkingDir": ""
  1282                       },
  1283               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1284               "Parent": "27cf784147099545",
  1285               "Size": 6824592
  1286          }
  1287  
  1288  Status Codes:
  1289  
  1290  -   **200** – no error
  1291  -   **404** – no such image
  1292  -   **500** – server error
  1293  
  1294  ### Get the history of an image
  1295  
  1296  `GET /images/(name)/history`
  1297  
  1298  Return the history of the image `name`
  1299  
  1300  **Example request**:
  1301  
  1302          GET /images/ubuntu/history HTTP/1.1
  1303  
  1304  **Example response**:
  1305  
  1306          HTTP/1.1 200 OK
  1307          Content-Type: application/json
  1308  
  1309          [
  1310               {
  1311                       "Id": "b750fe79269d",
  1312                       "Created": 1364102658,
  1313                       "CreatedBy": "/bin/bash"
  1314               },
  1315               {
  1316                       "Id": "27cf78414709",
  1317                       "Created": 1364068391,
  1318                       "CreatedBy": ""
  1319               }
  1320          ]
  1321  
  1322  Status Codes:
  1323  
  1324  -   **200** – no error
  1325  -   **404** – no such image
  1326  -   **500** – server error
  1327  
  1328  ### Push an image on the registry
  1329  
  1330  `POST /images/(name)/push`
  1331  
  1332  Push the image `name` on the registry
  1333  
  1334  **Example request**:
  1335  
  1336          POST /images/test/push HTTP/1.1
  1337  
  1338  **Example response**:
  1339  
  1340          HTTP/1.1 200 OK
  1341          Content-Type: application/json
  1342  
  1343          {"status": "Pushing..."}
  1344          {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1345          {"error": "Invalid..."}
  1346          ...
  1347  
  1348      If you wish to push an image on to a private registry, that image must already have been tagged
  1349      into a repository which references that registry host name and port.  This repository name should
  1350      then be used in the URL. This mirrors the flow of the CLI.
  1351  
  1352  **Example request**:
  1353  
  1354          POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1355  
  1356  
  1357  Query Parameters:
  1358  
  1359  -   **tag** – the tag to associate with the image on the registry, optional
  1360  
  1361  Request Headers:
  1362  
  1363  -   **X-Registry-Auth** – include a base64-encoded AuthConfig
  1364          object.
  1365  
  1366  Status Codes:
  1367  
  1368  -   **200** – no error
  1369  -   **404** – no such image
  1370  -   **500** – server error
  1371  
  1372  ### Tag an image into a repository
  1373  
  1374  `POST /images/(name)/tag`
  1375  
  1376  Tag the image `name` into a repository
  1377  
  1378  **Example request**:
  1379  
  1380          POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1381  
  1382  **Example response**:
  1383  
  1384          HTTP/1.1 201 OK
  1385  
  1386  Query Parameters:
  1387  
  1388  -   **repo** – The repository to tag in
  1389  -   **force** – 1/True/true or 0/False/false, default false
  1390  -   **tag** - The new tag name
  1391  
  1392  Status Codes:
  1393  
  1394  -   **201** – no error
  1395  -   **400** – bad parameter
  1396  -   **404** – no such image
  1397  -   **409** – conflict
  1398  -   **500** – server error
  1399  
  1400  ### Remove an image
  1401  
  1402  `DELETE /images/(name)`
  1403  
  1404  Remove the image `name` from the filesystem
  1405  
  1406  **Example request**:
  1407  
  1408          DELETE /images/test HTTP/1.1
  1409  
  1410  **Example response**:
  1411  
  1412          HTTP/1.1 200 OK
  1413          Content-type: application/json
  1414  
  1415          [
  1416           {"Untagged": "3e2f21a89f"},
  1417           {"Deleted": "3e2f21a89f"},
  1418           {"Deleted": "53b4f83ac9"}
  1419          ]
  1420  
  1421  Query Parameters:
  1422  
  1423  -   **force** – 1/True/true or 0/False/false, default false
  1424  -   **noprune** – 1/True/true or 0/False/false, default false
  1425  
  1426  Status Codes:
  1427  
  1428  -   **200** – no error
  1429  -   **404** – no such image
  1430  -   **409** – conflict
  1431  -   **500** – server error
  1432  
  1433  ### Search images
  1434  
  1435  `GET /images/search`
  1436  
  1437  Search for an image on [Docker Hub](https://hub.docker.com).
  1438  
  1439  > **Note**:
  1440  > The response keys have changed from API v1.6 to reflect the JSON
  1441  > sent by the registry server to the docker daemon's request.
  1442  
  1443  **Example request**:
  1444  
  1445          GET /images/search?term=sshd HTTP/1.1
  1446  
  1447  **Example response**:
  1448  
  1449          HTTP/1.1 200 OK
  1450          Content-Type: application/json
  1451  
  1452          [
  1453                  {
  1454                      "description": "",
  1455                      "is_official": false,
  1456                      "is_automated": false,
  1457                      "name": "wma55/u1210sshd",
  1458                      "star_count": 0
  1459                  },
  1460                  {
  1461                      "description": "",
  1462                      "is_official": false,
  1463                      "is_automated": false,
  1464                      "name": "jdswinbank/sshd",
  1465                      "star_count": 0
  1466                  },
  1467                  {
  1468                      "description": "",
  1469                      "is_official": false,
  1470                      "is_automated": false,
  1471                      "name": "vgauthier/sshd",
  1472                      "star_count": 0
  1473                  }
  1474          ...
  1475          ]
  1476  
  1477  Query Parameters:
  1478  
  1479  -   **term** – term to search
  1480  
  1481  Status Codes:
  1482  
  1483  -   **200** – no error
  1484  -   **500** – server error
  1485  
  1486  ## 2.3 Misc
  1487  
  1488  ### Check auth configuration
  1489  
  1490  `POST /auth`
  1491  
  1492  Get the default username and email
  1493  
  1494  **Example request**:
  1495  
  1496          POST /auth HTTP/1.1
  1497          Content-Type: application/json
  1498  
  1499          {
  1500               "username":" hannibal",
  1501               "password: "xxxx",
  1502               "email": "hannibal@a-team.com",
  1503               "serveraddress": "https://index.docker.io/v1/"
  1504          }
  1505  
  1506  **Example response**:
  1507  
  1508          HTTP/1.1 200 OK
  1509  
  1510  Status Codes:
  1511  
  1512  -   **200** – no error
  1513  -   **204** – no error
  1514  -   **500** – server error
  1515  
  1516  ### Display system-wide information
  1517  
  1518  `GET /info`
  1519  
  1520  Display system-wide information
  1521  
  1522  **Example request**:
  1523  
  1524          GET /info HTTP/1.1
  1525  
  1526  **Example response**:
  1527  
  1528          HTTP/1.1 200 OK
  1529          Content-Type: application/json
  1530  
  1531          {
  1532              "Containers": 11,
  1533              "Debug": 0,
  1534              "DockerRootDir": "/var/lib/docker",
  1535              "Driver": "btrfs",
  1536              "DriverStatus": [[""]],
  1537              "ExecutionDriver": "native-0.1",
  1538              "HttpProxy": "http://test:test@localhost:8080",
  1539              "HttpsProxy": "https://test:test@localhost:8080",
  1540              "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1541              "IPv4Forwarding": 1,
  1542              "Images": 16,
  1543              "IndexServerAddress": "https://index.docker.io/v1/",
  1544              "InitPath": "/usr/bin/docker",
  1545              "InitSha1": "",
  1546              "KernelVersion": "3.12.0-1-amd64",
  1547              "Labels": [
  1548                  "storage=ssd"
  1549              ],
  1550              "MemTotal": 2099236864,
  1551              "MemoryLimit": 1,
  1552              "NCPU": 1,
  1553              "NEventsListener": 0,
  1554              "NFd": 11,
  1555              "NGoroutines": 21,
  1556              "Name": "prod-server-42",
  1557              "NoProxy": "9.81.1.160",
  1558              "OperatingSystem": "Boot2Docker",
  1559              "RegistryConfig": {
  1560                  "IndexConfigs": {
  1561                      "docker.io": {
  1562                          "Mirrors": null,
  1563                          "Name": "docker.io",
  1564                          "Official": true,
  1565                          "Secure": true
  1566                      }
  1567                  },
  1568                  "InsecureRegistryCIDRs": [
  1569                      "127.0.0.0/8"
  1570                  ]
  1571              },
  1572              "SwapLimit": 0,
  1573              "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
  1574          }
  1575          
  1576  Status Codes:
  1577  
  1578  -   **200** – no error
  1579  -   **500** – server error
  1580  
  1581  ### Show the docker version information
  1582  
  1583  `GET /version`
  1584  
  1585  Show the docker version information
  1586  
  1587  **Example request**:
  1588  
  1589          GET /version HTTP/1.1
  1590  
  1591  **Example response**:
  1592  
  1593          HTTP/1.1 200 OK
  1594          Content-Type: application/json
  1595  
  1596          {
  1597               "Version": "1.5.0",
  1598               "Os": "linux",
  1599               "KernelVersion": "3.18.5-tinycore64",
  1600               "GoVersion": "go1.4.1",
  1601               "GitCommit": "a8a31ef",
  1602               "Arch": "amd64",
  1603               "ApiVersion": "1.18"
  1604          }
  1605  
  1606  Status Codes:
  1607  
  1608  -   **200** – no error
  1609  -   **500** – server error
  1610  
  1611  ### Ping the docker server
  1612  
  1613  `GET /_ping`
  1614  
  1615  Ping the docker server
  1616  
  1617  **Example request**:
  1618  
  1619          GET /_ping HTTP/1.1
  1620  
  1621  **Example response**:
  1622  
  1623          HTTP/1.1 200 OK
  1624          Content-Type: text/plain
  1625  
  1626          OK
  1627  
  1628  Status Codes:
  1629  
  1630  -   **200** - no error
  1631  -   **500** - server error
  1632  
  1633  ### Create a new image from a container's changes
  1634  
  1635  `POST /commit`
  1636  
  1637  Create a new image from a container's changes
  1638  
  1639  **Example request**:
  1640  
  1641          POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1642          Content-Type: application/json
  1643  
  1644          {
  1645               "Hostname": "",
  1646               "Domainname": "",
  1647               "User": "",
  1648               "AttachStdin": false,
  1649               "AttachStdout": true,
  1650               "AttachStderr": true,
  1651               "PortSpecs": null,
  1652               "Tty": false,
  1653               "OpenStdin": false,
  1654               "StdinOnce": false,
  1655               "Env": null,
  1656               "Cmd": [
  1657                       "date"
  1658               ],
  1659               "Volumes": {
  1660                       "/tmp": {}
  1661               },
  1662               "WorkingDir": "",
  1663               "NetworkDisabled": false,
  1664               "ExposedPorts": {
  1665                       "22/tcp": {}
  1666               }
  1667          }
  1668  
  1669  **Example response**:
  1670  
  1671          HTTP/1.1 201 Created
  1672          Content-Type: application/vnd.docker.raw-stream
  1673  
  1674          {"Id": "596069db4bf5"}
  1675  
  1676  Json Parameters:
  1677  
  1678  -  **config** - the container's configuration
  1679  
  1680  Query Parameters:
  1681  
  1682  -   **container** – source container
  1683  -   **repo** – repository
  1684  -   **tag** – tag
  1685  -   **comment** – commit message
  1686  -   **author** – author (e.g., "John Hannibal Smith
  1687      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1688  
  1689  Status Codes:
  1690  
  1691  -   **201** – no error
  1692  -   **404** – no such container
  1693  -   **500** – server error
  1694  
  1695  ### Monitor Docker's events
  1696  
  1697  `GET /events`
  1698  
  1699  Get container events from docker, either in real time via streaming, or via
  1700  polling (using since).
  1701  
  1702  Docker containers will report the following events:
  1703  
  1704      create, destroy, die, exec_create, exec_start, export, kill, oom, pause, restart, start, stop, unpause
  1705  
  1706  and Docker images will report:
  1707  
  1708      untag, delete
  1709  
  1710  **Example request**:
  1711  
  1712          GET /events?since=1374067924
  1713  
  1714  **Example response**:
  1715  
  1716          HTTP/1.1 200 OK
  1717          Content-Type: application/json
  1718  
  1719          {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1720          {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1721          {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1722          {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1723  
  1724  Query Parameters:
  1725  
  1726  -   **since** – timestamp used for polling
  1727  -   **until** – timestamp used for polling
  1728  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1729    -   event=&lt;string&gt; -- event to filter
  1730    -   image=&lt;string&gt; -- image to filter
  1731    -   container=&lt;string&gt; -- container to filter
  1732  
  1733  Status Codes:
  1734  
  1735  -   **200** – no error
  1736  -   **500** – server error
  1737  
  1738  ### Get a tarball containing all images in a repository
  1739  
  1740  `GET /images/(name)/get`
  1741  
  1742  Get a tarball containing all images and metadata for the repository specified
  1743  by `name`.
  1744  
  1745  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1746  (and its parents) are returned. If `name` is an image ID, similarly only that
  1747  image (and its parents) are returned, but with the exclusion of the
  1748  'repositories' file in the tarball, as there were no image names referenced.
  1749  
  1750  See the [image tarball format](#image-tarball-format) for more details.
  1751  
  1752  **Example request**
  1753  
  1754          GET /images/ubuntu/get
  1755  
  1756  **Example response**:
  1757  
  1758          HTTP/1.1 200 OK
  1759          Content-Type: application/x-tar
  1760  
  1761          Binary data stream
  1762  
  1763  Status Codes:
  1764  
  1765  -   **200** – no error
  1766  -   **500** – server error
  1767  
  1768  ### Get a tarball containing all images.
  1769  
  1770  `GET /images/get`
  1771  
  1772  Get a tarball containing all images and metadata for one or more repositories.
  1773  
  1774  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1775  ubuntu:latest), then only that image (and its parents) are returned; if it is
  1776  an image ID, similarly only that image (and its parents) are returned and there
  1777  would be no names referenced in the 'repositories' file for this image ID.
  1778  
  1779  See the [image tarball format](#image-tarball-format) for more details.
  1780  
  1781  **Example request**
  1782  
  1783          GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1784  
  1785  **Example response**:
  1786  
  1787          HTTP/1.1 200 OK
  1788          Content-Type: application/x-tar
  1789  
  1790          Binary data stream
  1791  
  1792  Status Codes:
  1793  
  1794  -   **200** – no error
  1795  -   **500** – server error
  1796  
  1797  ### Load a tarball with a set of images and tags into docker
  1798  
  1799  `POST /images/load`
  1800  
  1801  Load a set of images and tags into the docker repository.
  1802  See the [image tarball format](#image-tarball-format) for more details.
  1803  
  1804  **Example request**
  1805  
  1806          POST /images/load
  1807  
  1808          Tarball in body
  1809  
  1810  **Example response**:
  1811  
  1812          HTTP/1.1 200 OK
  1813  
  1814  Status Codes:
  1815  
  1816  -   **200** – no error
  1817  -   **500** – server error
  1818  
  1819  ### Image tarball format
  1820  
  1821  An image tarball contains one directory per image layer (named using its long ID),
  1822  each containing three files:
  1823  
  1824  1. `VERSION`: currently `1.0` - the file format version
  1825  2. `json`: detailed layer information, similar to `docker inspect layer_id`
  1826  3. `layer.tar`: A tarfile containing the filesystem changes in this layer
  1827  
  1828  The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories
  1829  for storing attribute changes and deletions.
  1830  
  1831  If the tarball defines a repository, there will also be a `repositories` file at
  1832  the root that contains a list of repository and tag names mapped to layer IDs.
  1833  
  1834  ```
  1835  {"hello-world":
  1836      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  1837  }
  1838  ```
  1839  
  1840  ### Exec Create
  1841  
  1842  `POST /containers/(id)/exec`
  1843  
  1844  Sets up an exec instance in a running container `id`
  1845  
  1846  **Example request**:
  1847  
  1848          POST /containers/e90e34656806/exec HTTP/1.1
  1849          Content-Type: application/json
  1850  
  1851          {
  1852  	     "AttachStdin": false,
  1853  	     "AttachStdout": true,
  1854  	     "AttachStderr": true,
  1855  	     "Tty": false,
  1856  	     "Cmd": [
  1857                       "date"
  1858               ],
  1859          }
  1860  
  1861  **Example response**:
  1862  
  1863          HTTP/1.1 201 OK
  1864          Content-Type: application/json
  1865  
  1866          {
  1867               "Id": "f90e34656806"
  1868               "Warnings":[]
  1869          }
  1870  
  1871  Json Parameters:
  1872  
  1873  -   **AttachStdin** - Boolean value, attaches to stdin of the exec command.
  1874  -   **AttachStdout** - Boolean value, attaches to stdout of the exec command.
  1875  -   **AttachStderr** - Boolean value, attaches to stderr of the exec command.
  1876  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1877  -   **Cmd** - Command to run specified as a string or an array of strings.
  1878  
  1879  
  1880  Status Codes:
  1881  
  1882  -   **201** – no error
  1883  -   **404** – no such container
  1884  
  1885  ### Exec Start
  1886  
  1887  `POST /exec/(id)/start`
  1888  
  1889  Starts a previously set up exec instance `id`. If `detach` is true, this API
  1890  returns after starting the `exec` command. Otherwise, this API sets up an
  1891  interactive session with the `exec` command.
  1892  
  1893  **Example request**:
  1894  
  1895          POST /exec/e90e34656806/start HTTP/1.1
  1896          Content-Type: application/json
  1897  
  1898          {
  1899  	     "Detach": false,
  1900  	     "Tty": false,
  1901          }
  1902  
  1903  **Example response**:
  1904  
  1905          HTTP/1.1 201 OK
  1906          Content-Type: application/json
  1907  
  1908          {{ STREAM }}
  1909  
  1910  Json Parameters:
  1911  
  1912  -   **Detach** - Detach from the exec command
  1913  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1914  
  1915  Status Codes:
  1916  
  1917  -   **201** – no error
  1918  -   **404** – no such exec instance
  1919  
  1920      **Stream details**:
  1921      Similar to the stream behavior of `POST /container/(id)/attach` API
  1922  
  1923  ### Exec Resize
  1924  
  1925  `POST /exec/(id)/resize`
  1926  
  1927  Resizes the tty session used by the exec command `id`.
  1928  This API is valid only if `tty` was specified as part of creating and starting the exec command.
  1929  
  1930  **Example request**:
  1931  
  1932          POST /exec/e90e34656806/resize HTTP/1.1
  1933          Content-Type: text/plain
  1934  
  1935  **Example response**:
  1936  
  1937          HTTP/1.1 201 OK
  1938          Content-Type: text/plain
  1939  
  1940  Query Parameters:
  1941  
  1942  -   **h** – height of tty session
  1943  -   **w** – width
  1944  
  1945  Status Codes:
  1946  
  1947  -   **201** – no error
  1948  -   **404** – no such exec instance
  1949  
  1950  ### Exec Inspect
  1951  
  1952  `GET /exec/(id)/json`
  1953  
  1954  Return low-level information about the exec command `id`.
  1955  
  1956  **Example request**:
  1957  
  1958          GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  1959  
  1960  **Example response**:
  1961  
  1962          HTTP/1.1 200 OK
  1963          Content-Type: plain/text
  1964  
  1965          {
  1966            "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  1967            "Running" : false,
  1968            "ExitCode" : 2,
  1969            "ProcessConfig" : {
  1970              "privileged" : false,
  1971              "user" : "",
  1972              "tty" : false,
  1973              "entrypoint" : "sh",
  1974              "arguments" : [
  1975                "-c",
  1976                "exit 2"
  1977              ]
  1978            },
  1979            "OpenStdin" : false,
  1980            "OpenStderr" : false,
  1981            "OpenStdout" : false,
  1982            "Container" : {
  1983              "State" : {
  1984                "Running" : true,
  1985                "Paused" : false,
  1986                "Restarting" : false,
  1987                "OOMKilled" : false,
  1988                "Pid" : 3650,
  1989                "ExitCode" : 0,
  1990                "Error" : "",
  1991                "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  1992                "FinishedAt" : "0001-01-01T00:00:00Z"
  1993              },
  1994              "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  1995              "Created" : "2014-11-17T22:26:03.626304998Z",
  1996              "Path" : "date",
  1997              "Args" : [],
  1998              "Config" : {
  1999                "Hostname" : "8f177a186b97",
  2000                "Domainname" : "",
  2001                "User" : "",
  2002                "AttachStdin" : false,
  2003                "AttachStdout" : false,
  2004                "AttachStderr" : false,
  2005                "PortSpecs" : null,
  2006                "ExposedPorts" : null,
  2007                "Tty" : false,
  2008                "OpenStdin" : false,
  2009                "StdinOnce" : false,
  2010                "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  2011                "Cmd" : [
  2012                  "date"
  2013                ],
  2014                "Image" : "ubuntu",
  2015                "Volumes" : null,
  2016                "WorkingDir" : "",
  2017                "Entrypoint" : null,
  2018                "NetworkDisabled" : false,
  2019                "MacAddress" : "",
  2020                "OnBuild" : null,
  2021                "SecurityOpt" : null
  2022              },
  2023              "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  2024              "NetworkSettings" : {
  2025                "IPAddress" : "172.17.0.2",
  2026                "IPPrefixLen" : 16,
  2027                "MacAddress" : "02:42:ac:11:00:02",
  2028                "Gateway" : "172.17.42.1",
  2029                "Bridge" : "docker0",
  2030                "PortMapping" : null,
  2031                "Ports" : {}
  2032              },
  2033              "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  2034              "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  2035              "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  2036              "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
  2037              "Name" : "/test",
  2038              "Driver" : "aufs",
  2039              "ExecDriver" : "native-0.2",
  2040              "MountLabel" : "",
  2041              "ProcessLabel" : "",
  2042              "AppArmorProfile" : "",
  2043              "RestartCount" : 0,
  2044              "Volumes" : {},
  2045              "VolumesRW" : {}
  2046            }
  2047          }
  2048  
  2049  Status Codes:
  2050  
  2051  -   **200** – no error
  2052  -   **404** – no such exec instance
  2053  -   **500** - server error
  2054  
  2055  # 3. Going further
  2056  
  2057  ## 3.1 Inside `docker run`
  2058  
  2059  As an example, the `docker run` command line makes the following API calls:
  2060  
  2061  - Create the container
  2062  
  2063  - If the status code is 404, it means the image doesn't exist:
  2064      - Try to pull it
  2065      - Then retry to create the container
  2066  
  2067  - Start the container
  2068  
  2069  - If you are not in detached mode:
  2070  - Attach to the container, using logs=1 (to have stdout and
  2071        stderr from the container's start) and stream=1
  2072  
  2073  - If in detached mode or only stdin is attached:
  2074  - Display the container's id
  2075  
  2076  ## 3.2 Hijacking
  2077  
  2078  In this version of the API, /attach, uses hijacking to transport stdin,
  2079  stdout and stderr on the same socket.
  2080  
  2081  To hint potential proxies about connection hijacking, Docker client sends
  2082  connection upgrade headers similarly to websocket.
  2083  
  2084      Upgrade: tcp
  2085      Connection: Upgrade
  2086  
  2087  When Docker daemon detects the `Upgrade` header, it will switch its status code
  2088  from **200 OK** to **101 UPGRADED** and resend the same headers.
  2089  
  2090  This might change in the future.
  2091  
  2092  ## 3.3 CORS Requests
  2093  
  2094  To set cross origin requests to the remote api please give values to 
  2095  "--api-cors-header" when running docker in daemon mode. Set * will allow all,
  2096  default or blank means CORS disabled
  2097  
  2098      $ docker -d -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"