github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/docs/api/v1.19.md (about)

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