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