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