github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/docs/api/v1.18.md (about)

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