github.com/yogeshlonkar/moby@v1.13.2-0.20201203103638-c0b64beaea94/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  -   **link** - 1/True/true or 0/False/false, Remove the specified
  1099          link associated to the container. Default `false`.
  1100  
  1101  **Status codes**:
  1102  
  1103  -   **204** – no error
  1104  -   **400** – bad parameter
  1105  -   **404** – no such container
  1106  -   **409** – conflict
  1107  -   **500** – server error
  1108  
  1109  #### Copy files or folders from a container
  1110  
  1111  `POST /containers/(id or name)/copy`
  1112  
  1113  Copy files or folders of container `id`
  1114  
  1115  **Example request**:
  1116  
  1117      POST /v1.19/containers/4fa6e0f0c678/copy HTTP/1.1
  1118      Content-Type: application/json
  1119  
  1120      {
  1121           "Resource": "test.txt"
  1122      }
  1123  
  1124  **Example response**:
  1125  
  1126      HTTP/1.1 200 OK
  1127      Content-Type: application/x-tar
  1128  
  1129      {% raw %}
  1130      {{ TAR STREAM }}
  1131      {% endraw %}
  1132  
  1133  **Status codes**:
  1134  
  1135  -   **200** – no error
  1136  -   **404** – no such container
  1137  -   **500** – server error
  1138  
  1139  ### 2.2 Images
  1140  
  1141  #### List Images
  1142  
  1143  `GET /images/json`
  1144  
  1145  **Example request**:
  1146  
  1147      GET /v1.19/images/json?all=0 HTTP/1.1
  1148  
  1149  **Example response**:
  1150  
  1151      HTTP/1.1 200 OK
  1152      Content-Type: application/json
  1153  
  1154      [
  1155        {
  1156           "RepoTags": [
  1157             "ubuntu:12.04",
  1158             "ubuntu:precise",
  1159             "ubuntu:latest"
  1160           ],
  1161           "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
  1162           "Created": 1365714795,
  1163           "Size": 131506275,
  1164           "VirtualSize": 131506275,
  1165           "Labels": {}
  1166        },
  1167        {
  1168           "RepoTags": [
  1169             "ubuntu:12.10",
  1170             "ubuntu:quantal"
  1171           ],
  1172           "ParentId": "27cf784147099545",
  1173           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1174           "Created": 1364102658,
  1175           "Size": 24653,
  1176           "VirtualSize": 180116135,
  1177           "Labels": {
  1178              "com.example.version": "v1"
  1179           }
  1180        }
  1181      ]
  1182  
  1183  **Example request, with digest information**:
  1184  
  1185      GET /v1.19/images/json?digests=1 HTTP/1.1
  1186  
  1187  **Example response, with digest information**:
  1188  
  1189      HTTP/1.1 200 OK
  1190      Content-Type: application/json
  1191  
  1192      [
  1193        {
  1194          "Created": 1420064636,
  1195          "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
  1196          "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
  1197          "RepoDigests": [
  1198            "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
  1199          ],
  1200          "RepoTags": [
  1201            "localhost:5000/test/busybox:latest",
  1202            "playdate:latest"
  1203          ],
  1204          "Size": 0,
  1205          "VirtualSize": 2429728,
  1206          "Labels": {}
  1207        }
  1208      ]
  1209  
  1210  The response shows a single image `Id` associated with two repositories
  1211  (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use
  1212  either of the `RepoTags` values `localhost:5000/test/busybox:latest` or
  1213  `playdate:latest` to reference the image.
  1214  
  1215  You can also use `RepoDigests` values to reference an image. In this response,
  1216  the array has only one reference and that is to the
  1217  `localhost:5000/test/busybox` repository; the `playdate` repository has no
  1218  digest. You can reference this digest using the value:
  1219  `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
  1220  
  1221  See the `docker run` and `docker build` commands for examples of digest and tag
  1222  references on the command line.
  1223  
  1224  **Query parameters**:
  1225  
  1226  -   **all** – 1/True/true or 0/False/false, default false
  1227  -   **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
  1228    -   `dangling=true`
  1229    -   `label=key` or `label="key=value"` of an image label
  1230  -   **filter** - only return images with the specified name
  1231  
  1232  #### Build image from a Dockerfile
  1233  
  1234  `POST /build`
  1235  
  1236  Build an image from a Dockerfile
  1237  
  1238  **Example request**:
  1239  
  1240      POST /v1.19/build HTTP/1.1
  1241  
  1242      {% raw %}
  1243      {{ TAR STREAM }}
  1244      {% endraw %}
  1245  
  1246  **Example response**:
  1247  
  1248      HTTP/1.1 200 OK
  1249      Content-Type: application/json
  1250  
  1251      {"stream": "Step 1/5..."}
  1252      {"stream": "..."}
  1253      {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1254  
  1255  The input stream must be a `tar` archive compressed with one of the
  1256  following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`.
  1257  
  1258  The archive must include a build instructions file, typically called
  1259  `Dockerfile` at the archive's root. The `dockerfile` parameter may be
  1260  used to specify a different build instructions file. To do this, its value must be
  1261  the path to the alternate build instructions file to use.
  1262  
  1263  The archive may include any number of other files,
  1264  which are accessible in the build context (See the [*ADD build
  1265  command*](../reference/builder.md#add)).
  1266  
  1267  The Docker daemon performs a preliminary validation of the `Dockerfile` before
  1268  starting the build, and returns an error if the syntax is incorrect. After that,
  1269  each instruction is run one-by-one until the ID of the new image is output.
  1270  
  1271  The build is canceled if the client drops the connection by quitting
  1272  or being killed.
  1273  
  1274  **Query parameters**:
  1275  
  1276  -   **dockerfile** - Path within the build context to the Dockerfile. This is
  1277          ignored if `remote` is specified and points to an individual filename.
  1278  -   **t** – A name and optional tag to apply to the image in the `name:tag` format.
  1279          If you omit the `tag` the default `latest` value is assumed.
  1280  -   **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the
  1281          URI specifies a filename, the file's contents are placed into a file
  1282          called `Dockerfile`.
  1283  -   **q** – Suppress verbose build output.
  1284  -   **nocache** – Do not use the cache when building the image.
  1285  -   **pull** - Attempt to pull the image even if an older image exists locally.
  1286  -   **rm** - Remove intermediate containers after a successful build (default behavior).
  1287  -   **forcerm** - Always remove intermediate containers (includes `rm`).
  1288  -   **memory** - Set memory limit for build.
  1289  -   **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap.
  1290  -   **cpushares** - CPU shares (relative weight).
  1291  -   **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`).
  1292  -   **cpuperiod** - The length of a CPU period in microseconds.
  1293  -   **cpuquota** - Microseconds of CPU time that the container can get in a CPU period.
  1294  
  1295  **Request Headers**:
  1296  
  1297  -   **Content-type** – Set to `"application/tar"`.
  1298  -   **X-Registry-Config** – base64-encoded ConfigFile object
  1299  
  1300  **Status codes**:
  1301  
  1302  -   **200** – no error
  1303  -   **500** – server error
  1304  
  1305  #### Create an image
  1306  
  1307  `POST /images/create`
  1308  
  1309  Create an image either by pulling it from the registry or by importing it
  1310  
  1311  **Example request**:
  1312  
  1313      POST /v1.19/images/create?fromImage=busybox&tag=latest HTTP/1.1
  1314  
  1315  **Example response**:
  1316  
  1317      HTTP/1.1 200 OK
  1318      Content-Type: application/json
  1319  
  1320      {"status": "Pulling..."}
  1321      {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
  1322      {"error": "Invalid..."}
  1323      ...
  1324  
  1325  When using this endpoint to pull an image from the registry, the
  1326  `X-Registry-Auth` header can be used to include
  1327  a base64-encoded AuthConfig object.
  1328  
  1329  **Query parameters**:
  1330  
  1331  -   **fromImage** – Name of the image to pull.
  1332  -   **fromSrc** – Source to import.  The value may be a URL from which the image
  1333          can be retrieved or `-` to read the image from the request body.
  1334  -   **repo** – Repository name.
  1335  -   **tag** – Tag. If empty when pulling an image, this causes all tags
  1336          for the given image to be pulled.
  1337  
  1338  **Request Headers**:
  1339  
  1340  -   **X-Registry-Auth** – base64-encoded AuthConfig object
  1341  
  1342  **Status codes**:
  1343  
  1344  -   **200** – no error
  1345  -   **404** - repository does not exist or no read access
  1346  -   **500** – server error
  1347  
  1348  
  1349  
  1350  #### Inspect an image
  1351  
  1352  `GET /images/(name)/json`
  1353  
  1354  Return low-level information on the image `name`
  1355  
  1356  **Example request**:
  1357  
  1358      GET /v1.19/images/ubuntu/json HTTP/1.1
  1359  
  1360  **Example response**:
  1361  
  1362      HTTP/1.1 200 OK
  1363      Content-Type: application/json
  1364  
  1365      {
  1366         "Created": "2013-03-23T22:24:18.818426-07:00",
  1367         "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  1368         "ContainerConfig": {
  1369            "Hostname": "",
  1370            "User": "",
  1371            "AttachStdin": false,
  1372            "AttachStdout": false,
  1373            "AttachStderr": false,
  1374            "Tty": true,
  1375            "OpenStdin": true,
  1376            "StdinOnce": false,
  1377            "Env": null,
  1378            "Cmd": ["/bin/bash"],
  1379            "Dns": null,
  1380            "Image": "ubuntu",
  1381            "Labels": {
  1382               "com.example.vendor": "Acme",
  1383               "com.example.license": "GPL",
  1384               "com.example.version": "1.0"
  1385            },
  1386            "Volumes": null,
  1387            "VolumesFrom": "",
  1388            "WorkingDir": ""
  1389         },
  1390         "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1391         "Parent": "27cf784147099545",
  1392         "Size": 6824592
  1393      }
  1394  
  1395  **Status codes**:
  1396  
  1397  -   **200** – no error
  1398  -   **404** – no such image
  1399  -   **500** – server error
  1400  
  1401  #### Get the history of an image
  1402  
  1403  `GET /images/(name)/history`
  1404  
  1405  Return the history of the image `name`
  1406  
  1407  **Example request**:
  1408  
  1409      GET /v1.19/images/ubuntu/history HTTP/1.1
  1410  
  1411  **Example response**:
  1412  
  1413      HTTP/1.1 200 OK
  1414      Content-Type: application/json
  1415  
  1416      [
  1417          {
  1418              "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710",
  1419              "Created": 1398108230,
  1420              "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /",
  1421              "Tags": [
  1422                  "ubuntu:lucid",
  1423                  "ubuntu:10.04"
  1424              ],
  1425              "Size": 182964289,
  1426              "Comment": ""
  1427          },
  1428          {
  1429              "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8",
  1430              "Created": 1398108222,
  1431              "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/",
  1432              "Tags": null,
  1433              "Size": 0,
  1434              "Comment": ""
  1435          },
  1436          {
  1437              "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158",
  1438              "Created": 1371157430,
  1439              "CreatedBy": "",
  1440              "Tags": [
  1441                  "scratch12:latest",
  1442                  "scratch:latest"
  1443              ],
  1444              "Size": 0,
  1445              "Comment": "Imported from -"
  1446          }
  1447      ]
  1448  
  1449  **Status codes**:
  1450  
  1451  -   **200** – no error
  1452  -   **404** – no such image
  1453  -   **500** – server error
  1454  
  1455  #### Push an image on the registry
  1456  
  1457  `POST /images/(name)/push`
  1458  
  1459  Push the image `name` on the registry
  1460  
  1461  **Example request**:
  1462  
  1463      POST /v1.19/images/test/push HTTP/1.1
  1464  
  1465  **Example response**:
  1466  
  1467      HTTP/1.1 200 OK
  1468      Content-Type: application/json
  1469  
  1470      {"status": "Pushing..."}
  1471      {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1472      {"error": "Invalid..."}
  1473      ...
  1474  
  1475  If you wish to push an image on to a private registry, that image must already have a tag
  1476  into a repository which references that registry `hostname` and `port`.  This repository name should
  1477  then be used in the URL. This duplicates the command line's flow.
  1478  
  1479  **Example request**:
  1480  
  1481      POST /v1.19/images/registry.acme.com:5000/test/push HTTP/1.1
  1482  
  1483  
  1484  **Query parameters**:
  1485  
  1486  -   **tag** – The tag to associate with the image on the registry. This is optional.
  1487  
  1488  **Request Headers**:
  1489  
  1490  -   **X-Registry-Auth** – base64-encoded AuthConfig object.
  1491  
  1492  **Status codes**:
  1493  
  1494  -   **200** – no error
  1495  -   **404** – no such image
  1496  -   **500** – server error
  1497  
  1498  #### Tag an image into a repository
  1499  
  1500  `POST /images/(name)/tag`
  1501  
  1502  Tag the image `name` into a repository
  1503  
  1504  **Example request**:
  1505  
  1506      POST /v1.19/images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1507  
  1508  **Example response**:
  1509  
  1510      HTTP/1.1 201 Created
  1511  
  1512  **Query parameters**:
  1513  
  1514  -   **repo** – The repository to tag in
  1515  -   **force** – 1/True/true or 0/False/false, default false
  1516  -   **tag** - The new tag name
  1517  
  1518  **Status codes**:
  1519  
  1520  -   **201** – no error
  1521  -   **400** – bad parameter
  1522  -   **404** – no such image
  1523  -   **409** – conflict
  1524  -   **500** – server error
  1525  
  1526  #### Remove an image
  1527  
  1528  `DELETE /images/(name)`
  1529  
  1530  Remove the image `name` from the filesystem
  1531  
  1532  **Example request**:
  1533  
  1534      DELETE /v1.19/images/test HTTP/1.1
  1535  
  1536  **Example response**:
  1537  
  1538      HTTP/1.1 200 OK
  1539      Content-type: application/json
  1540  
  1541      [
  1542       {"Untagged": "3e2f21a89f"},
  1543       {"Deleted": "3e2f21a89f"},
  1544       {"Deleted": "53b4f83ac9"}
  1545      ]
  1546  
  1547  **Query parameters**:
  1548  
  1549  -   **force** – 1/True/true or 0/False/false, default false
  1550  -   **noprune** – 1/True/true or 0/False/false, default false
  1551  
  1552  **Status codes**:
  1553  
  1554  -   **200** – no error
  1555  -   **404** – no such image
  1556  -   **409** – conflict
  1557  -   **500** – server error
  1558  
  1559  #### Search images
  1560  
  1561  `GET /images/search`
  1562  
  1563  Search for an image on [Docker Hub](https://hub.docker.com). This API
  1564  returns both `is_trusted` and `is_automated` images. Currently, they
  1565  are considered identical. In the future, the `is_trusted` property will
  1566  be deprecated and replaced by the `is_automated` property.
  1567  
  1568  > **Note**:
  1569  > The response keys have changed from API v1.6 to reflect the JSON
  1570  > sent by the registry server to the docker daemon's request.
  1571  
  1572  **Example request**:
  1573  
  1574      GET /v1.19/images/search?term=sshd HTTP/1.1
  1575  
  1576  **Example response**:
  1577  
  1578      HTTP/1.1 200 OK
  1579      Content-Type: application/json
  1580  
  1581      [
  1582              {
  1583                  "star_count": 12,
  1584                  "is_official": false,
  1585                  "name": "wma55/u1210sshd",
  1586                  "is_trusted": false,
  1587                  "is_automated": false,
  1588                  "description": ""
  1589              },
  1590              {
  1591                  "star_count": 10,
  1592                  "is_official": false,
  1593                  "name": "jdswinbank/sshd",
  1594                  "is_trusted": false,
  1595                  "is_automated": false,
  1596                  "description": ""
  1597              },
  1598              {
  1599                  "star_count": 18,
  1600                  "is_official": false,
  1601                  "name": "vgauthier/sshd",
  1602                  "is_trusted": false,
  1603                  "is_automated": false,
  1604                  "description": ""
  1605              }
  1606      ...
  1607      ]
  1608  
  1609  **Query parameters**:
  1610  
  1611  -   **term** – term to search
  1612  
  1613  **Status codes**:
  1614  
  1615  -   **200** – no error
  1616  -   **500** – server error
  1617  
  1618  ### 2.3 Misc
  1619  
  1620  #### Check auth configuration
  1621  
  1622  `POST /auth`
  1623  
  1624  Get the default username and email
  1625  
  1626  **Example request**:
  1627  
  1628      POST /v1.19/auth HTTP/1.1
  1629      Content-Type: application/json
  1630  
  1631      {
  1632           "username": "hannibal",
  1633           "password": "xxxx",
  1634           "email": "hannibal@a-team.com",
  1635           "serveraddress": "https://index.docker.io/v1/"
  1636      }
  1637  
  1638  **Example response**:
  1639  
  1640      HTTP/1.1 200 OK
  1641  
  1642  **Status codes**:
  1643  
  1644  -   **200** – no error
  1645  -   **204** – no error
  1646  -   **500** – server error
  1647  
  1648  #### Display system-wide information
  1649  
  1650  `GET /info`
  1651  
  1652  Display system-wide information
  1653  
  1654  **Example request**:
  1655  
  1656      GET /v1.19/info HTTP/1.1
  1657  
  1658  **Example response**:
  1659  
  1660      HTTP/1.1 200 OK
  1661      Content-Type: application/json
  1662  
  1663      {
  1664          "Containers": 11,
  1665          "CpuCfsPeriod": true,
  1666          "CpuCfsQuota": true,
  1667          "Debug": false,
  1668          "DockerRootDir": "/var/lib/docker",
  1669          "Driver": "btrfs",
  1670          "DriverStatus": [[""]],
  1671          "ExecutionDriver": "native-0.1",
  1672          "ExperimentalBuild": false,
  1673          "HttpProxy": "http://test:test@localhost:8080",
  1674          "HttpsProxy": "https://test:test@localhost:8080",
  1675          "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1676          "IPv4Forwarding": true,
  1677          "Images": 16,
  1678          "IndexServerAddress": "https://index.docker.io/v1/",
  1679          "InitPath": "/usr/bin/docker",
  1680          "InitSha1": "",
  1681          "KernelVersion": "3.12.0-1-amd64",
  1682          "Labels": [
  1683              "storage=ssd"
  1684          ],
  1685          "MemTotal": 2099236864,
  1686          "MemoryLimit": true,
  1687          "NCPU": 1,
  1688          "NEventsListener": 0,
  1689          "NFd": 11,
  1690          "NGoroutines": 21,
  1691          "Name": "prod-server-42",
  1692          "NoProxy": "9.81.1.160",
  1693          "OomKillDisable": true,
  1694          "OperatingSystem": "Boot2Docker",
  1695          "RegistryConfig": {
  1696              "IndexConfigs": {
  1697                  "docker.io": {
  1698                      "Mirrors": null,
  1699                      "Name": "docker.io",
  1700                      "Official": true,
  1701                      "Secure": true
  1702                  }
  1703              },
  1704              "InsecureRegistryCIDRs": [
  1705                  "127.0.0.0/8"
  1706              ]
  1707          },
  1708          "SwapLimit": false,
  1709          "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
  1710      }
  1711  
  1712  **Status codes**:
  1713  
  1714  -   **200** – no error
  1715  -   **500** – server error
  1716  
  1717  #### Show the docker version information
  1718  
  1719  `GET /version`
  1720  
  1721  Show the docker version information
  1722  
  1723  **Example request**:
  1724  
  1725      GET /v1.19/version HTTP/1.1
  1726  
  1727  **Example response**:
  1728  
  1729      HTTP/1.1 200 OK
  1730      Content-Type: application/json
  1731  
  1732      {
  1733           "Version": "1.5.0",
  1734           "Os": "linux",
  1735           "KernelVersion": "3.18.5-tinycore64",
  1736           "GoVersion": "go1.4.1",
  1737           "GitCommit": "a8a31ef",
  1738           "Arch": "amd64",
  1739           "ApiVersion": "1.19"
  1740      }
  1741  
  1742  **Status codes**:
  1743  
  1744  -   **200** – no error
  1745  -   **500** – server error
  1746  
  1747  #### Ping the docker server
  1748  
  1749  `GET /_ping`
  1750  
  1751  Ping the docker server
  1752  
  1753  **Example request**:
  1754  
  1755      GET /v1.19/_ping HTTP/1.1
  1756  
  1757  **Example response**:
  1758  
  1759      HTTP/1.1 200 OK
  1760      Content-Type: text/plain
  1761  
  1762      OK
  1763  
  1764  **Status codes**:
  1765  
  1766  -   **200** - no error
  1767  -   **500** - server error
  1768  
  1769  #### Create a new image from a container's changes
  1770  
  1771  `POST /commit`
  1772  
  1773  Create a new image from a container's changes
  1774  
  1775  **Example request**:
  1776  
  1777      POST /v1.19/commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1778      Content-Type: application/json
  1779  
  1780      {
  1781           "Hostname": "",
  1782           "Domainname": "",
  1783           "User": "",
  1784           "AttachStdin": false,
  1785           "AttachStdout": true,
  1786           "AttachStderr": true,
  1787           "PortSpecs": null,
  1788           "Tty": false,
  1789           "OpenStdin": false,
  1790           "StdinOnce": false,
  1791           "Env": null,
  1792           "Cmd": [
  1793                   "date"
  1794           ],
  1795           "Volumes": {
  1796                   "/tmp": {}
  1797           },
  1798           "Labels": {
  1799                   "key1": "value1",
  1800                   "key2": "value2"
  1801            },
  1802           "WorkingDir": "",
  1803           "NetworkDisabled": false,
  1804           "ExposedPorts": {
  1805                   "22/tcp": {}
  1806           }
  1807      }
  1808  
  1809  **Example response**:
  1810  
  1811      HTTP/1.1 201 Created
  1812      Content-Type: application/json
  1813  
  1814      {"Id": "596069db4bf5"}
  1815  
  1816  **JSON parameters**:
  1817  
  1818  -  **config** - the container's configuration
  1819  
  1820  **Query parameters**:
  1821  
  1822  -   **container** – source container
  1823  -   **repo** – repository
  1824  -   **tag** – tag
  1825  -   **comment** – commit message
  1826  -   **author** – author (e.g., "John Hannibal Smith
  1827      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1828  
  1829  **Status codes**:
  1830  
  1831  -   **201** – no error
  1832  -   **404** – no such container
  1833  -   **500** – server error
  1834  
  1835  #### Monitor Docker's events
  1836  
  1837  `GET /events`
  1838  
  1839  Get container events from docker, in real time via streaming.
  1840  
  1841  Docker containers report the following events:
  1842  
  1843      attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause
  1844  
  1845  Docker images report the following events:
  1846  
  1847      untag, delete
  1848  
  1849  **Example request**:
  1850  
  1851      GET /v1.19/events?since=1374067924
  1852  
  1853  **Example response**:
  1854  
  1855      HTTP/1.1 200 OK
  1856      Content-Type: application/json
  1857  
  1858      {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1859      {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1860      {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1861      {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1862  
  1863  **Query parameters**:
  1864  
  1865  -   **since** – Timestamp. Show all events created since timestamp and then stream
  1866  -   **until** – Timestamp. Show events created until given timestamp and stop streaming
  1867  -   **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1868    -   `container=<string>`; -- container to filter
  1869    -   `event=<string>`; -- event to filter
  1870    -   `image=<string>`; -- image to filter
  1871  
  1872  **Status codes**:
  1873  
  1874  -   **200** – no error
  1875  -   **500** – server error
  1876  
  1877  #### Get a tarball containing all images in a repository
  1878  
  1879  `GET /images/(name)/get`
  1880  
  1881  Get a tarball containing all images and metadata for the repository specified
  1882  by `name`.
  1883  
  1884  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1885  (and its parents) are returned. If `name` is an image ID, similarly only that
  1886  image (and its parents) are returned, but with the exclusion of the
  1887  'repositories' file in the tarball, as there were no image names referenced.
  1888  
  1889  See the [image tarball format](#image-tarball-format) for more details.
  1890  
  1891  **Example request**
  1892  
  1893      GET /v1.19/images/ubuntu/get
  1894  
  1895  **Example response**:
  1896  
  1897      HTTP/1.1 200 OK
  1898      Content-Type: application/x-tar
  1899  
  1900      Binary data stream
  1901  
  1902  **Status codes**:
  1903  
  1904  -   **200** – no error
  1905  -   **500** – server error
  1906  
  1907  #### Get a tarball containing all images
  1908  
  1909  `GET /images/get`
  1910  
  1911  Get a tarball containing all images and metadata for one or more repositories.
  1912  
  1913  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1914  `ubuntu:latest`), then only that image (and its parents) are returned; if it is
  1915  an image ID, similarly only that image (and its parents) are returned and there
  1916  would be no names referenced in the 'repositories' file for this image ID.
  1917  
  1918  See the [image tarball format](#image-tarball-format) for more details.
  1919  
  1920  **Example request**
  1921  
  1922      GET /v1.19/images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1923  
  1924  **Example response**:
  1925  
  1926      HTTP/1.1 200 OK
  1927      Content-Type: application/x-tar
  1928  
  1929      Binary data stream
  1930  
  1931  **Status codes**:
  1932  
  1933  -   **200** – no error
  1934  -   **500** – server error
  1935  
  1936  #### Load a tarball with a set of images and tags into docker
  1937  
  1938  `POST /images/load`
  1939  
  1940  Load a set of images and tags into a Docker repository.
  1941  See the [image tarball format](#image-tarball-format) for more details.
  1942  
  1943  **Example request**
  1944  
  1945      POST /v1.19/images/load
  1946      Content-Type: application/x-tar
  1947  
  1948      Tarball in body
  1949  
  1950  **Example response**:
  1951  
  1952      HTTP/1.1 200 OK
  1953  
  1954  **Status codes**:
  1955  
  1956  -   **200** – no error
  1957  -   **500** – server error
  1958  
  1959  #### Image tarball format
  1960  
  1961  An image tarball contains one directory per image layer (named using its long ID),
  1962  each containing these files:
  1963  
  1964  - `VERSION`: currently `1.0` - the file format version
  1965  - `json`: detailed layer information, similar to `docker inspect layer_id`
  1966  - `layer.tar`: A tarfile containing the filesystem changes in this layer
  1967  
  1968  The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories
  1969  for storing attribute changes and deletions.
  1970  
  1971  If the tarball defines a repository, the tarball should also include a `repositories` file at
  1972  the root that contains a list of repository and tag names mapped to layer IDs.
  1973  
  1974  ```
  1975  {"hello-world":
  1976      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  1977  }
  1978  ```
  1979  
  1980  #### Exec Create
  1981  
  1982  `POST /containers/(id or name)/exec`
  1983  
  1984  Sets up an exec instance in a running container `id`
  1985  
  1986  **Example request**:
  1987  
  1988      POST /v1.19/containers/e90e34656806/exec HTTP/1.1
  1989      Content-Type: application/json
  1990  
  1991      {
  1992        "AttachStdin": true,
  1993        "AttachStdout": true,
  1994        "AttachStderr": true,
  1995        "Cmd": ["sh"],
  1996        "Tty": true,
  1997        "User": "123:456"
  1998      }
  1999  
  2000  **Example response**:
  2001  
  2002      HTTP/1.1 201 Created
  2003      Content-Type: application/json
  2004  
  2005      {
  2006           "Id": "f90e34656806",
  2007           "Warnings":[]
  2008      }
  2009  
  2010  **JSON parameters**:
  2011  
  2012  -   **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command.
  2013  -   **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command.
  2014  -   **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command.
  2015  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2016  -   **Cmd** - Command to run specified as a string or an array of strings.
  2017  -   **User** - A string value specifying the user, and optionally, group to run
  2018          the exec process inside the container. Format is one of: `"user"`,
  2019          `"user:group"`, `"uid"`, or `"uid:gid"`.
  2020  
  2021  **Status codes**:
  2022  
  2023  -   **201** – no error
  2024  -   **404** – no such container
  2025  
  2026  #### Exec Start
  2027  
  2028  `POST /exec/(id)/start`
  2029  
  2030  Starts a previously set up `exec` instance `id`. If `detach` is true, this API
  2031  returns after starting the `exec` command. Otherwise, this API sets up an
  2032  interactive session with the `exec` command.
  2033  
  2034  **Example request**:
  2035  
  2036      POST /v1.19/exec/e90e34656806/start HTTP/1.1
  2037      Content-Type: application/json
  2038  
  2039      {
  2040       "Detach": false,
  2041       "Tty": false
  2042      }
  2043  
  2044  **Example response**:
  2045  
  2046      HTTP/1.1 200 OK
  2047      Content-Type: application/vnd.docker.raw-stream
  2048  
  2049      {% raw %}
  2050      {{ STREAM }}
  2051      {% endraw %}
  2052  
  2053  **JSON parameters**:
  2054  
  2055  -   **Detach** - Detach from the `exec` command.
  2056  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2057  
  2058  **Status codes**:
  2059  
  2060  -   **200** – no error
  2061  -   **404** – no such exec instance
  2062  
  2063  **Stream details**:
  2064  
  2065  Similar to the stream behavior of `POST /containers/(id or name)/attach` API
  2066  
  2067  #### Exec Resize
  2068  
  2069  `POST /exec/(id)/resize`
  2070  
  2071  Resizes the `tty` session used by the `exec` command `id`.  The unit is number of characters.
  2072  This API is valid only if `tty` was specified as part of creating and starting the `exec` command.
  2073  
  2074  **Example request**:
  2075  
  2076      POST /v1.19/exec/e90e34656806/resize?h=40&w=80 HTTP/1.1
  2077      Content-Type: text/plain
  2078  
  2079  **Example response**:
  2080  
  2081      HTTP/1.1 201 Created
  2082      Content-Type: text/plain
  2083  
  2084  **Query parameters**:
  2085  
  2086  -   **h** – height of `tty` session
  2087  -   **w** – width
  2088  
  2089  **Status codes**:
  2090  
  2091  -   **201** – no error
  2092  -   **404** – no such exec instance
  2093  
  2094  #### Exec Inspect
  2095  
  2096  `GET /exec/(id)/json`
  2097  
  2098  Return low-level information about the `exec` command `id`.
  2099  
  2100  **Example request**:
  2101  
  2102      GET /v1.19/exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  2103  
  2104  **Example response**:
  2105  
  2106      HTTP/1.1 200 OK
  2107      Content-Type: plain/text
  2108  
  2109      {
  2110        "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  2111        "Running" : false,
  2112        "ExitCode" : 2,
  2113        "ProcessConfig" : {
  2114          "privileged" : false,
  2115          "user" : "",
  2116          "tty" : false,
  2117          "entrypoint" : "sh",
  2118          "arguments" : [
  2119            "-c",
  2120            "exit 2"
  2121          ]
  2122        },
  2123        "OpenStdin" : false,
  2124        "OpenStderr" : false,
  2125        "OpenStdout" : false,
  2126        "Container" : {
  2127          "State" : {
  2128            "Running" : true,
  2129            "Paused" : false,
  2130            "Restarting" : false,
  2131            "OOMKilled" : false,
  2132            "Pid" : 3650,
  2133            "ExitCode" : 0,
  2134            "Error" : "",
  2135            "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  2136            "FinishedAt" : "0001-01-01T00:00:00Z"
  2137          },
  2138          "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  2139          "Created" : "2014-11-17T22:26:03.626304998Z",
  2140          "Path" : "date",
  2141          "Args" : [],
  2142          "Config" : {
  2143            "Hostname" : "8f177a186b97",
  2144            "Domainname" : "",
  2145            "User" : "",
  2146            "AttachStdin" : false,
  2147            "AttachStdout" : false,
  2148            "AttachStderr" : false,
  2149            "PortSpecs": null,
  2150            "ExposedPorts" : null,
  2151            "Tty" : false,
  2152            "OpenStdin" : false,
  2153            "StdinOnce" : false,
  2154            "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  2155            "Cmd" : [
  2156              "date"
  2157            ],
  2158            "Image" : "ubuntu",
  2159            "Volumes" : null,
  2160            "WorkingDir" : "",
  2161            "Entrypoint" : null,
  2162            "NetworkDisabled" : false,
  2163            "MacAddress" : "",
  2164            "OnBuild" : null,
  2165            "SecurityOpt" : null
  2166          },
  2167          "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  2168          "NetworkSettings" : {
  2169            "IPAddress" : "172.17.0.2",
  2170            "IPPrefixLen" : 16,
  2171            "MacAddress" : "02:42:ac:11:00:02",
  2172            "Gateway" : "172.17.42.1",
  2173            "Bridge" : "docker0",
  2174            "PortMapping" : null,
  2175            "Ports" : {}
  2176          },
  2177          "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  2178          "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  2179          "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  2180          "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
  2181          "Name" : "/test",
  2182          "Driver" : "aufs",
  2183          "ExecDriver" : "native-0.2",
  2184          "MountLabel" : "",
  2185          "ProcessLabel" : "",
  2186          "AppArmorProfile" : "",
  2187          "RestartCount" : 0,
  2188          "Volumes" : {},
  2189          "VolumesRW" : {}
  2190        }
  2191      }
  2192  
  2193  **Status codes**:
  2194  
  2195  -   **200** – no error
  2196  -   **404** – no such exec instance
  2197  -   **500** - server error
  2198  
  2199  ## 3. Going further
  2200  
  2201  ### 3.1 Inside `docker run`
  2202  
  2203  As an example, the `docker run` command line makes the following API calls:
  2204  
  2205  - Create the container
  2206  
  2207  - If the status code is 404, it means the image doesn't exist:
  2208      - Try to pull it.
  2209      - Then, retry to create the container.
  2210  
  2211  - Start the container.
  2212  
  2213  - If you are not in detached mode:
  2214  - Attach to the container, using `logs=1` (to have `stdout` and
  2215        `stderr` from the container's start) and `stream=1`
  2216  
  2217  - If in detached mode or only `stdin` is attached, display the container's id.
  2218  
  2219  ### 3.2 Hijacking
  2220  
  2221  In this version of the API, `/attach`, uses hijacking to transport `stdin`,
  2222  `stdout`, and `stderr` on the same socket.
  2223  
  2224  To hint potential proxies about connection hijacking, Docker client sends
  2225  connection upgrade headers similarly to websocket.
  2226  
  2227      Upgrade: tcp
  2228      Connection: Upgrade
  2229  
  2230  When Docker daemon detects the `Upgrade` header, it switches its status code
  2231  from **200 OK** to **101 UPGRADED** and resends the same headers.
  2232  
  2233  
  2234  ### 3.3 CORS Requests
  2235  
  2236  To set cross origin requests to the Engine API please give values to
  2237  `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all,
  2238  default or blank means CORS disabled
  2239  
  2240      $ docker -d -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"