github.com/kobeld/docker@v1.12.0-rc1/docs/reference/api/docker_remote_api_v1.22.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API v1.22"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent="engine_remoteapi"
     8  weight=-3
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API v1.22
    13  
    14  ## 1. Brief introduction
    15  
    16   - The Remote API has replaced `rcli`.
    17   - The daemon listens on `unix:///var/run/docker.sock` but you can
    18     [Bind Docker to another host/port or a Unix socket](../commandline/dockerd.md#bind-docker-to-another-host-port-or-a-unix-socket).
    19   - The API tends to be REST. However, for some complex commands, like `attach`
    20     or `pull`, the HTTP connection is hijacked to transport `stdout`,
    21     `stdin` and `stderr`.
    22   - When the client API version is newer than the daemon's, these calls return an HTTP
    23     `400 Bad Request` error message.
    24  
    25  # 2. Endpoints
    26  
    27  ## 2.1 Containers
    28  
    29  ### List containers
    30  
    31  `GET /containers/json`
    32  
    33  List containers
    34  
    35  **Example request**:
    36  
    37      GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    38  
    39  **Example response**:
    40  
    41      HTTP/1.1 200 OK
    42      Content-Type: application/json
    43  
    44      [
    45           {
    46                   "Id": "8dfafdbc3a40",
    47                   "Names":["/boring_feynman"],
    48                   "Image": "ubuntu:latest",
    49                   "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
    50                   "Command": "echo 1",
    51                   "Created": 1367854155,
    52                   "Status": "Exit 0",
    53                   "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    54                   "Labels": {
    55                           "com.example.vendor": "Acme",
    56                           "com.example.license": "GPL",
    57                           "com.example.version": "1.0"
    58                   },
    59                   "SizeRw": 12288,
    60                   "SizeRootFs": 0,
    61                   "HostConfig": {
    62                           "NetworkMode": "default"
    63                   },
    64                   "NetworkSettings": {
    65                           "Networks": {
    66                                   "bridge": {
    67                                            "IPAMConfig": null,
    68                                            "Links": null,
    69                                            "Aliases": null,
    70                                            "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
    71                                            "EndpointID": "2cdc4edb1ded3631c81f57966563e5c8525b81121bb3706a9a9a3ae102711f3f",
    72                                            "Gateway": "172.17.0.1",
    73                                            "IPAddress": "172.17.0.2",
    74                                            "IPPrefixLen": 16,
    75                                            "IPv6Gateway": "",
    76                                            "GlobalIPv6Address": "",
    77                                            "GlobalIPv6PrefixLen": 0,
    78                                            "MacAddress": "02:42:ac:11:00:02"
    79                                    }
    80                           }
    81                   }
    82           },
    83           {
    84                   "Id": "9cd87474be90",
    85                   "Names":["/coolName"],
    86                   "Image": "ubuntu:latest",
    87                   "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
    88                   "Command": "echo 222222",
    89                   "Created": 1367854155,
    90                   "Status": "Exit 0",
    91                   "Ports": [],
    92                   "Labels": {},
    93                   "SizeRw": 12288,
    94                   "SizeRootFs": 0,
    95                   "HostConfig": {
    96                           "NetworkMode": "default"
    97                   },
    98                   "NetworkSettings": {
    99                           "Networks": {
   100                                   "bridge": {
   101                                            "IPAMConfig": null,
   102                                            "Links": null,
   103                                            "Aliases": null,
   104                                            "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
   105                                            "EndpointID": "88eaed7b37b38c2a3f0c4bc796494fdf51b270c2d22656412a2ca5d559a64d7a",
   106                                            "Gateway": "172.17.0.1",
   107                                            "IPAddress": "172.17.0.8",
   108                                            "IPPrefixLen": 16,
   109                                            "IPv6Gateway": "",
   110                                            "GlobalIPv6Address": "",
   111                                            "GlobalIPv6PrefixLen": 0,
   112                                            "MacAddress": "02:42:ac:11:00:08"
   113                                    }
   114                           }
   115                   }
   116  
   117           },
   118           {
   119                   "Id": "3176a2479c92",
   120                   "Names":["/sleepy_dog"],
   121                   "Image": "ubuntu:latest",
   122                   "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
   123                   "Command": "echo 3333333333333333",
   124                   "Created": 1367854154,
   125                   "Status": "Exit 0",
   126                   "Ports":[],
   127                   "Labels": {},
   128                   "SizeRw":12288,
   129                   "SizeRootFs":0,
   130                   "HostConfig": {
   131                           "NetworkMode": "default"
   132                   },
   133                   "NetworkSettings": {
   134                           "Networks": {
   135                                   "bridge": {
   136                                            "IPAMConfig": null,
   137                                            "Links": null,
   138                                            "Aliases": null,
   139                                            "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
   140                                            "EndpointID": "8b27c041c30326d59cd6e6f510d4f8d1d570a228466f956edf7815508f78e30d",
   141                                            "Gateway": "172.17.0.1",
   142                                            "IPAddress": "172.17.0.6",
   143                                            "IPPrefixLen": 16,
   144                                            "IPv6Gateway": "",
   145                                            "GlobalIPv6Address": "",
   146                                            "GlobalIPv6PrefixLen": 0,
   147                                            "MacAddress": "02:42:ac:11:00:06"
   148                                    }
   149                           }
   150                   }
   151  
   152           },
   153           {
   154                   "Id": "4cb07b47f9fb",
   155                   "Names":["/running_cat"],
   156                   "Image": "ubuntu:latest",
   157                   "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
   158                   "Command": "echo 444444444444444444444444444444444",
   159                   "Created": 1367854152,
   160                   "Status": "Exit 0",
   161                   "Ports": [],
   162                   "Labels": {},
   163                   "SizeRw": 12288,
   164                   "SizeRootFs": 0,
   165                   "HostConfig": {
   166                           "NetworkMode": "default"
   167                   },
   168                   "NetworkSettings": {
   169                           "Networks": {
   170                                   "bridge": {
   171                                            "IPAMConfig": null,
   172                                            "Links": null,
   173                                            "Aliases": null,
   174                                            "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
   175                                            "EndpointID": "d91c7b2f0644403d7ef3095985ea0e2370325cd2332ff3a3225c4247328e66e9",
   176                                            "Gateway": "172.17.0.1",
   177                                            "IPAddress": "172.17.0.5",
   178                                            "IPPrefixLen": 16,
   179                                            "IPv6Gateway": "",
   180                                            "GlobalIPv6Address": "",
   181                                            "GlobalIPv6PrefixLen": 0,
   182                                            "MacAddress": "02:42:ac:11:00:05"
   183                                    }
   184                           }
   185                   }
   186  
   187           }
   188      ]
   189  
   190  Query Parameters:
   191  
   192  -   **all** – 1/True/true or 0/False/false, Show all containers.
   193          Only running containers are shown by default (i.e., this defaults to false)
   194  -   **limit** – Show `limit` last created
   195          containers, include non-running ones.
   196  -   **since** – Show only containers created since Id, include
   197          non-running ones.
   198  -   **before** – Show only containers created before Id, include
   199          non-running ones.
   200  -   **size** – 1/True/true or 0/False/false, Show the containers
   201          sizes
   202  -   **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters:
   203    -   `exited=<int>`; -- containers with exit code of  `<int>` ;
   204    -   `status=`(`created`|`restarting`|`running`|`paused`|`exited`|`dead`)
   205    -   `label=key` or `label="key=value"` of a container label
   206    -   `isolation=`(`default`|`process`|`hyperv`)   (Windows daemon only)
   207  
   208  Status Codes:
   209  
   210  -   **200** – no error
   211  -   **400** – bad parameter
   212  -   **500** – server error
   213  
   214  ### Create a container
   215  
   216  `POST /containers/create`
   217  
   218  Create a container
   219  
   220  **Example request**:
   221  
   222      POST /containers/create HTTP/1.1
   223      Content-Type: application/json
   224  
   225      {
   226             "Hostname": "",
   227             "Domainname": "",
   228             "User": "",
   229             "AttachStdin": false,
   230             "AttachStdout": true,
   231             "AttachStderr": true,
   232             "Tty": false,
   233             "OpenStdin": false,
   234             "StdinOnce": false,
   235             "Env": [
   236                     "FOO=bar",
   237                     "BAZ=quux"
   238             ],
   239             "Cmd": [
   240                     "date"
   241             ],
   242             "Entrypoint": "",
   243             "Image": "ubuntu",
   244             "Labels": {
   245                     "com.example.vendor": "Acme",
   246                     "com.example.license": "GPL",
   247                     "com.example.version": "1.0"
   248             },
   249             "Volumes": {
   250               "/volumes/data": {}
   251             },
   252             "WorkingDir": "",
   253             "NetworkDisabled": false,
   254             "MacAddress": "12:34:56:78:9a:bc",
   255             "ExposedPorts": {
   256                     "22/tcp": {}
   257             },
   258             "StopSignal": "SIGTERM",
   259             "HostConfig": {
   260               "Binds": ["/tmp:/tmp"],
   261               "Links": ["redis3:redis"],
   262               "Memory": 0,
   263               "MemorySwap": 0,
   264               "MemoryReservation": 0,
   265               "KernelMemory": 0,
   266               "CpuShares": 512,
   267               "CpuPeriod": 100000,
   268               "CpuQuota": 50000,
   269               "CpusetCpus": "0,1",
   270               "CpusetMems": "0,1",
   271               "BlkioWeight": 300,
   272               "BlkioWeightDevice": [{}],
   273               "BlkioDeviceReadBps": [{}],
   274               "BlkioDeviceReadIOps": [{}],
   275               "BlkioDeviceWriteBps": [{}],
   276               "BlkioDeviceWriteIOps": [{}],
   277               "MemorySwappiness": 60,
   278               "OomKillDisable": false,
   279               "OomScoreAdj": 500,
   280               "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   281               "PublishAllPorts": false,
   282               "Privileged": false,
   283               "ReadonlyRootfs": false,
   284               "Dns": ["8.8.8.8"],
   285               "DnsOptions": [""],
   286               "DnsSearch": [""],
   287               "ExtraHosts": null,
   288               "VolumesFrom": ["parent", "other:ro"],
   289               "CapAdd": ["NET_ADMIN"],
   290               "CapDrop": ["MKNOD"],
   291               "GroupAdd": ["newgroup"],
   292               "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   293               "NetworkMode": "bridge",
   294               "Devices": [],
   295               "Ulimits": [{}],
   296               "LogConfig": { "Type": "json-file", "Config": {} },
   297               "SecurityOpt": [],
   298               "CgroupParent": "",
   299               "VolumeDriver": "",
   300               "ShmSize": 67108864
   301            },
   302            "NetworkingConfig": {
   303            "EndpointsConfig": {
   304                "isolated_nw" : {
   305                    "IPAMConfig": {
   306                        "IPv4Address":"172.20.30.33",
   307                        "IPv6Address":"2001:db8:abcd::3033"
   308                    },
   309                    "Links":["container_1", "container_2"],
   310                    "Aliases":["server_x", "server_y"]
   311                }
   312            }
   313        }
   314  
   315  **Example response**:
   316  
   317        HTTP/1.1 201 Created
   318        Content-Type: application/json
   319  
   320        {
   321             "Id":"e90e34656806",
   322             "Warnings":[]
   323        }
   324  
   325  Json Parameters:
   326  
   327  -   **Hostname** - A string value containing the hostname to use for the
   328        container.
   329  -   **Domainname** - A string value containing the domain name to use
   330        for the container.
   331  -   **User** - A string value specifying the user inside the container.
   332  -   **AttachStdin** - Boolean value, attaches to `stdin`.
   333  -   **AttachStdout** - Boolean value, attaches to `stdout`.
   334  -   **AttachStderr** - Boolean value, attaches to `stderr`.
   335  -   **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed.
   336  -   **OpenStdin** - Boolean value, opens stdin,
   337  -   **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects.
   338  -   **Env** - A list of environment variables in the form of `["VAR=value"[,"VAR2=value2"]]`
   339  -   **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}`
   340  -   **Cmd** - Command to run specified as a string or an array of strings.
   341  -   **Entrypoint** - Set the entry point for the container as a string or an array
   342        of strings.
   343  -   **Image** - A string specifying the image name to use for the container.
   344  -   **Volumes** - An object mapping mount point paths (strings) inside the
   345        container to empty objects.
   346  -   **WorkingDir** - A string specifying the working directory for commands to
   347        run in.
   348  -   **NetworkDisabled** - Boolean value, when true disables networking for the
   349        container
   350  -   **ExposedPorts** - An object mapping ports to an empty object in the form of:
   351        `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
   352  -   **StopSignal** - Signal to stop a container as a string or unsigned integer. `SIGTERM` by default.
   353  -   **HostConfig**
   354      -   **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
   355             + `host_path:container_path` to bind-mount a host path into the container
   356             + `host_path:container_path:ro` to make the bind-mount read-only inside the container.
   357             + `volume_name:container_path` to bind-mount a volume managed by a volume plugin into the container.
   358             + `volume_name:container_path:ro` to make the bind mount read-only inside the container.
   359      -   **Links** - A list of links for the container. Each link entry should be
   360            in the form of `container_name:alias`.
   361      -   **Memory** - Memory limit in bytes.
   362      -   **MemorySwap** - Total memory limit (memory + swap); set `-1` to enable unlimited swap.
   363            You must use this with `memory` and make the swap value larger than `memory`.
   364      -   **MemoryReservation** - Memory soft limit in bytes.
   365      -   **KernelMemory** - Kernel memory limit in bytes.
   366      -   **CpuShares** - An integer value containing the container's CPU Shares
   367            (ie. the relative weight vs other containers).
   368      -   **CpuPeriod** - The length of a CPU period in microseconds.
   369      -   **CpuQuota** - Microseconds of CPU time that the container can get in a CPU period.
   370      -   **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use.
   371      -   **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
   372      -   **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000.
   373      -   **BlkioWeightDevice** - Block IO weight (relative device weight) in the form of:        `"BlkioWeightDevice": [{"Path": "device_path", "Weight": weight}]`
   374      -   **BlkioDeviceReadBps** - Limit read rate (bytes per second) from a device in the form of:	`"BlkioDeviceReadBps": [{"Path": "device_path", "Rate": rate}]`, for example:
   375          `"BlkioDeviceReadBps": [{"Path": "/dev/sda", "Rate": "1024"}]"`
   376      -   **BlkioDeviceWriteBps** - Limit write rate (bytes per second) to a device in the form of:	`"BlkioDeviceWriteBps": [{"Path": "device_path", "Rate": rate}]`, for example:
   377          `"BlkioDeviceWriteBps": [{"Path": "/dev/sda", "Rate": "1024"}]"`
   378      -   **BlkioDeviceReadIOps** - Limit read rate (IO per second) from a device in the form of:	`"BlkioDeviceReadIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
   379          `"BlkioDeviceReadIOps": [{"Path": "/dev/sda", "Rate": "1000"}]`
   380      -   **BlkioDeviceWiiteIOps** - Limit write rate (IO per second) to a device in the form of:	`"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
   381          `"BlkioDeviceWriteIOps": [{"Path": "/dev/sda", "Rate": "1000"}]`
   382      -   **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
   383      -   **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
   384      -   **OomScoreAdj** - An integer value containing the score given to the container in order to tune OOM killer preferences.
   385      -   **PortBindings** - A map of exposed container ports and the host port they
   386            should map to. A JSON object in the form
   387            `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   388            Take note that `port` is specified as a string and not an integer value.
   389      -   **PublishAllPorts** - Allocates a random host port for all of a container's
   390            exposed ports. Specified as a boolean value.
   391      -   **Privileged** - Gives the container full access to the host. Specified as
   392            a boolean value.
   393      -   **ReadonlyRootfs** - Mount the container's root filesystem as read only.
   394            Specified as a boolean value.
   395      -   **Dns** - A list of DNS servers for the container to use.
   396      -   **DnsOptions** - A list of DNS options
   397      -   **DnsSearch** - A list of DNS search domains
   398      -   **ExtraHosts** - A list of hostnames/IP mappings to add to the
   399          container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
   400      -   **VolumesFrom** - A list of volumes to inherit from another container.
   401            Specified in the form `<container name>[:<ro|rw>]`
   402      -   **CapAdd** - A list of kernel capabilities to add to the container.
   403      -   **Capdrop** - A list of kernel capabilities to drop from the container.
   404      -   **GroupAdd** - A list of additional groups that the container process will run as
   405      -   **RestartPolicy** – The behavior to apply when the container exits.  The
   406              value is an object with a `Name` property of either `"always"` to
   407              always restart, `"unless-stopped"` to restart always except when
   408              user has manually stopped the container or `"on-failure"` to restart only when the container
   409              exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   410              controls the number of times to retry before giving up.
   411              The default is not to restart. (optional)
   412              An ever increasing delay (double the previous delay, starting at 100mS)
   413              is added before each restart to prevent flooding the server.
   414      -   **NetworkMode** - Sets the networking mode for the container. Supported
   415            standard values are: `bridge`, `host`, `none`, and `container:<name|id>`. Any other value is taken
   416            as a custom network's name to which this container should connect to.
   417      -   **Devices** - A list of devices to add to the container specified as a JSON object in the
   418        form
   419            `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   420      -   **Ulimits** - A list of ulimits to set in the container, specified as
   421            `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
   422            `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }`
   423      -   **SecurityOpt**: A list of string values to customize labels for MLS
   424          systems, such as SELinux.
   425      -   **LogConfig** - Log configuration for the container, specified as a JSON object in the form
   426            `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
   427            Available types: `json-file`, `syslog`, `journald`, `gelf`, `awslogs`, `splunk`, `none`.
   428            `json-file` logging driver.
   429      -   **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.
   430      -   **VolumeDriver** - Driver that this container users to mount volumes.
   431      -   **ShmSize** - Size of `/dev/shm` in bytes. The size must be greater than 0.  If omitted the system uses 64MB.
   432  
   433  Query Parameters:
   434  
   435  -   **name** – Assign the specified name to the container. Must
   436      match `/?[a-zA-Z0-9_-]+`.
   437  
   438  Status Codes:
   439  
   440  -   **201** – no error
   441  -   **400** – bad parameter
   442  -   **404** – no such container
   443  -   **406** – impossible to attach (container not running)
   444  -   **500** – server error
   445  
   446  ### Inspect a container
   447  
   448  `GET /containers/(id or name)/json`
   449  
   450  Return low-level information on the container `id`
   451  
   452  
   453  **Example request**:
   454  
   455        GET /containers/4fa6e0f0c678/json HTTP/1.1
   456  
   457  **Example response**:
   458  
   459      HTTP/1.1 200 OK
   460      Content-Type: application/json
   461  
   462      {
   463  		"AppArmorProfile": "",
   464  		"Args": [
   465  			"-c",
   466  			"exit 9"
   467  		],
   468  		"Config": {
   469  			"AttachStderr": true,
   470  			"AttachStdin": false,
   471  			"AttachStdout": true,
   472  			"Cmd": [
   473  				"/bin/sh",
   474  				"-c",
   475  				"exit 9"
   476  			],
   477  			"Domainname": "",
   478  			"Entrypoint": null,
   479  			"Env": [
   480  				"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   481  			],
   482  			"ExposedPorts": null,
   483  			"Hostname": "ba033ac44011",
   484  			"Image": "ubuntu",
   485  			"Labels": {
   486  				"com.example.vendor": "Acme",
   487  				"com.example.license": "GPL",
   488  				"com.example.version": "1.0"
   489  			},
   490  			"MacAddress": "",
   491  			"NetworkDisabled": false,
   492  			"OnBuild": null,
   493  			"OpenStdin": false,
   494  			"StdinOnce": false,
   495  			"Tty": false,
   496  			"User": "",
   497  			"Volumes": {
   498                            "/volumes/data": {}
   499                          },
   500  			"WorkingDir": "",
   501  			"StopSignal": "SIGTERM"
   502  		},
   503  		"Created": "2015-01-06T15:47:31.485331387Z",
   504  		"Driver": "devicemapper",
   505  		"ExecDriver": "native-0.2",
   506  		"ExecIDs": null,
   507  		"HostConfig": {
   508  			"Binds": null,
   509  			"BlkioWeight": 0,
   510  			"BlkioWeightDevice": [{}],
   511  			"BlkioDeviceReadBps": [{}],
   512  			"BlkioDeviceWriteBps": [{}],
   513  			"BlkioDeviceReadIOps": [{}],
   514  			"BlkioDeviceWriteIOps": [{}],
   515  			"CapAdd": null,
   516  			"CapDrop": null,
   517  			"ContainerIDFile": "",
   518  			"CpusetCpus": "",
   519  			"CpusetMems": "",
   520  			"CpuShares": 0,
   521  			"CpuPeriod": 100000,
   522  			"Devices": [],
   523  			"Dns": null,
   524  			"DnsOptions": null,
   525  			"DnsSearch": null,
   526  			"ExtraHosts": null,
   527  			"IpcMode": "",
   528  			"Links": null,
   529  			"LxcConf": [],
   530  			"Memory": 0,
   531  			"MemorySwap": 0,
   532  			"MemoryReservation": 0,
   533  			"KernelMemory": 0,
   534  			"OomKillDisable": false,
   535  			"OomScoreAdj": 500,
   536  			"NetworkMode": "bridge",
   537  			"PortBindings": {},
   538  			"Privileged": false,
   539  			"ReadonlyRootfs": false,
   540  			"PublishAllPorts": false,
   541  			"RestartPolicy": {
   542  				"MaximumRetryCount": 2,
   543  				"Name": "on-failure"
   544  			},
   545  			"LogConfig": {
   546  				"Config": null,
   547  				"Type": "json-file"
   548  			},
   549  			"SecurityOpt": null,
   550  			"VolumesFrom": null,
   551  			"Ulimits": [{}],
   552  			"VolumeDriver": "",
   553  			"ShmSize": 67108864
   554  		},
   555  		"HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
   556  		"HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
   557  		"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
   558  		"Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
   559  		"Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
   560  		"MountLabel": "",
   561  		"Name": "/boring_euclid",
   562  		"NetworkSettings": {
   563  			"Bridge": "",
   564  			"SandboxID": "",
   565  			"HairpinMode": false,
   566  			"LinkLocalIPv6Address": "",
   567  			"LinkLocalIPv6PrefixLen": 0,
   568  			"Ports": null,
   569  			"SandboxKey": "",
   570  			"SecondaryIPAddresses": null,
   571  			"SecondaryIPv6Addresses": null,
   572  			"EndpointID": "",
   573  			"Gateway": "",
   574  			"GlobalIPv6Address": "",
   575  			"GlobalIPv6PrefixLen": 0,
   576  			"IPAddress": "",
   577  			"IPPrefixLen": 0,
   578  			"IPv6Gateway": "",
   579  			"MacAddress": "",
   580  			"Networks": {
   581  				"bridge": {
   582  					"NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
   583  					"EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d",
   584  					"Gateway": "172.17.0.1",
   585  					"IPAddress": "172.17.0.2",
   586  					"IPPrefixLen": 16,
   587  					"IPv6Gateway": "",
   588  					"GlobalIPv6Address": "",
   589  					"GlobalIPv6PrefixLen": 0,
   590  					"MacAddress": "02:42:ac:12:00:02"
   591  				}
   592  			}
   593  		},
   594  		"Path": "/bin/sh",
   595  		"ProcessLabel": "",
   596  		"ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
   597  		"RestartCount": 1,
   598  		"State": {
   599  			"Error": "",
   600  			"ExitCode": 9,
   601  			"FinishedAt": "2015-01-06T15:47:32.080254511Z",
   602  			"OOMKilled": false,
   603  			"Dead": false,
   604  			"Paused": false,
   605  			"Pid": 0,
   606  			"Restarting": false,
   607  			"Running": true,
   608  			"StartedAt": "2015-01-06T15:47:32.072697474Z",
   609  			"Status": "running"
   610  		},
   611  		"Mounts": [
   612  			{
   613  				"Name": "fac362...80535",
   614  				"Source": "/data",
   615  				"Destination": "/data",
   616  				"Driver": "local",
   617  				"Mode": "ro,Z",
   618  				"RW": false,
   619  				"Propagation": ""
   620  			}
   621  		]
   622  	}
   623  
   624  **Example request, with size information**:
   625  
   626      GET /containers/4fa6e0f0c678/json?size=1 HTTP/1.1
   627  
   628  **Example response, with size information**:
   629  
   630      HTTP/1.1 200 OK
   631      Content-Type: application/json
   632  
   633      {
   634      ....
   635      "SizeRw": 0,
   636      "SizeRootFs": 972,
   637      ....
   638      }
   639  
   640  Query Parameters:
   641  
   642  -   **size** – 1/True/true or 0/False/false, return container size information. Default is `false`.
   643  
   644  Status Codes:
   645  
   646  -   **200** – no error
   647  -   **404** – no such container
   648  -   **500** – server error
   649  
   650  ### List processes running inside a container
   651  
   652  `GET /containers/(id or name)/top`
   653  
   654  List processes running inside the container `id`. On Unix systems this
   655  is done by running the `ps` command. This endpoint is not
   656  supported on Windows.
   657  
   658  **Example request**:
   659  
   660      GET /containers/4fa6e0f0c678/top HTTP/1.1
   661  
   662  **Example response**:
   663  
   664      HTTP/1.1 200 OK
   665      Content-Type: application/json
   666  
   667      {
   668         "Titles" : [
   669           "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD"
   670         ],
   671         "Processes" : [
   672           [
   673             "root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash"
   674           ],
   675           [
   676             "root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10"
   677           ]
   678         ]
   679      }
   680  
   681  **Example request**:
   682  
   683      GET /containers/4fa6e0f0c678/top?ps_args=aux HTTP/1.1
   684  
   685  **Example response**:
   686  
   687      HTTP/1.1 200 OK
   688      Content-Type: application/json
   689  
   690      {
   691        "Titles" : [
   692          "USER","PID","%CPU","%MEM","VSZ","RSS","TTY","STAT","START","TIME","COMMAND"
   693        ]
   694        "Processes" : [
   695          [
   696            "root","13642","0.0","0.1","18172","3184","pts/0","Ss","17:03","0:00","/bin/bash"
   697          ],
   698          [
   699            "root","13895","0.0","0.0","4348","692","pts/0","S+","17:15","0:00","sleep 10"
   700          ]
   701        ],
   702      }
   703  
   704  Query Parameters:
   705  
   706  -   **ps_args** – `ps` arguments to use (e.g., `aux`), defaults to `-ef`
   707  
   708  Status Codes:
   709  
   710  -   **200** – no error
   711  -   **404** – no such container
   712  -   **500** – server error
   713  
   714  ### Get container logs
   715  
   716  `GET /containers/(id or name)/logs`
   717  
   718  Get `stdout` and `stderr` logs from the container ``id``
   719  
   720  > **Note**:
   721  > This endpoint works only for containers with the `json-file` or `journald` logging drivers.
   722  
   723  **Example request**:
   724  
   725       GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1&timestamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1
   726  
   727  **Example response**:
   728  
   729       HTTP/1.1 101 UPGRADED
   730       Content-Type: application/vnd.docker.raw-stream
   731       Connection: Upgrade
   732       Upgrade: tcp
   733  
   734       {{ STREAM }}
   735  
   736  Query Parameters:
   737  
   738  -   **follow** – 1/True/true or 0/False/false, return stream. Default `false`.
   739  -   **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`.
   740  -   **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`.
   741  -   **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp
   742      will only output log-entries since that timestamp. Default: 0 (unfiltered)
   743  -   **timestamps** – 1/True/true or 0/False/false, print timestamps for
   744          every log line. Default `false`.
   745  -   **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all.
   746  
   747  Status Codes:
   748  
   749  -   **101** – no error, hints proxy about hijacking
   750  -   **200** – no error, no upgrade header found
   751  -   **404** – no such container
   752  -   **500** – server error
   753  
   754  ### Inspect changes on a container's filesystem
   755  
   756  `GET /containers/(id or name)/changes`
   757  
   758  Inspect changes on container `id`'s filesystem
   759  
   760  **Example request**:
   761  
   762      GET /containers/4fa6e0f0c678/changes HTTP/1.1
   763  
   764  **Example response**:
   765  
   766      HTTP/1.1 200 OK
   767      Content-Type: application/json
   768  
   769      [
   770           {
   771                   "Path": "/dev",
   772                   "Kind": 0
   773           },
   774           {
   775                   "Path": "/dev/kmsg",
   776                   "Kind": 1
   777           },
   778           {
   779                   "Path": "/test",
   780                   "Kind": 1
   781           }
   782      ]
   783  
   784  Values for `Kind`:
   785  
   786  - `0`: Modify
   787  - `1`: Add
   788  - `2`: Delete
   789  
   790  Status Codes:
   791  
   792  -   **200** – no error
   793  -   **404** – no such container
   794  -   **500** – server error
   795  
   796  ### Export a container
   797  
   798  `GET /containers/(id or name)/export`
   799  
   800  Export the contents of container `id`
   801  
   802  **Example request**:
   803  
   804      GET /containers/4fa6e0f0c678/export HTTP/1.1
   805  
   806  **Example response**:
   807  
   808      HTTP/1.1 200 OK
   809      Content-Type: application/octet-stream
   810  
   811      {{ TAR STREAM }}
   812  
   813  Status Codes:
   814  
   815  -   **200** – no error
   816  -   **404** – no such container
   817  -   **500** – server error
   818  
   819  ### Get container stats based on resource usage
   820  
   821  `GET /containers/(id or name)/stats`
   822  
   823  This endpoint returns a live stream of a container's resource usage statistics.
   824  
   825  **Example request**:
   826  
   827      GET /containers/redis1/stats HTTP/1.1
   828  
   829  **Example response**:
   830  
   831        HTTP/1.1 200 OK
   832        Content-Type: application/json
   833  
   834        {
   835           "read" : "2015-01-08T22:57:31.547920715Z",
   836           "networks": {
   837                   "eth0": {
   838                       "rx_bytes": 5338,
   839                       "rx_dropped": 0,
   840                       "rx_errors": 0,
   841                       "rx_packets": 36,
   842                       "tx_bytes": 648,
   843                       "tx_dropped": 0,
   844                       "tx_errors": 0,
   845                       "tx_packets": 8
   846                   },
   847                   "eth5": {
   848                       "rx_bytes": 4641,
   849                       "rx_dropped": 0,
   850                       "rx_errors": 0,
   851                       "rx_packets": 26,
   852                       "tx_bytes": 690,
   853                       "tx_dropped": 0,
   854                       "tx_errors": 0,
   855                       "tx_packets": 9
   856                   }
   857           },
   858           "memory_stats" : {
   859              "stats" : {
   860                 "total_pgmajfault" : 0,
   861                 "cache" : 0,
   862                 "mapped_file" : 0,
   863                 "total_inactive_file" : 0,
   864                 "pgpgout" : 414,
   865                 "rss" : 6537216,
   866                 "total_mapped_file" : 0,
   867                 "writeback" : 0,
   868                 "unevictable" : 0,
   869                 "pgpgin" : 477,
   870                 "total_unevictable" : 0,
   871                 "pgmajfault" : 0,
   872                 "total_rss" : 6537216,
   873                 "total_rss_huge" : 6291456,
   874                 "total_writeback" : 0,
   875                 "total_inactive_anon" : 0,
   876                 "rss_huge" : 6291456,
   877                 "hierarchical_memory_limit" : 67108864,
   878                 "total_pgfault" : 964,
   879                 "total_active_file" : 0,
   880                 "active_anon" : 6537216,
   881                 "total_active_anon" : 6537216,
   882                 "total_pgpgout" : 414,
   883                 "total_cache" : 0,
   884                 "inactive_anon" : 0,
   885                 "active_file" : 0,
   886                 "pgfault" : 964,
   887                 "inactive_file" : 0,
   888                 "total_pgpgin" : 477
   889              },
   890              "max_usage" : 6651904,
   891              "usage" : 6537216,
   892              "failcnt" : 0,
   893              "limit" : 67108864
   894           },
   895           "blkio_stats" : {},
   896           "cpu_stats" : {
   897              "cpu_usage" : {
   898                 "percpu_usage" : [
   899                    8646879,
   900                    24472255,
   901                    36438778,
   902                    30657443
   903                 ],
   904                 "usage_in_usermode" : 50000000,
   905                 "total_usage" : 100215355,
   906                 "usage_in_kernelmode" : 30000000
   907              },
   908              "system_cpu_usage" : 739306590000000,
   909              "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0}
   910           },
   911           "precpu_stats" : {
   912              "cpu_usage" : {
   913                 "percpu_usage" : [
   914                    8646879,
   915                    24350896,
   916                    36438778,
   917                    30657443
   918                 ],
   919                 "usage_in_usermode" : 50000000,
   920                 "total_usage" : 100093996,
   921                 "usage_in_kernelmode" : 30000000
   922              },
   923              "system_cpu_usage" : 9492140000000,
   924              "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0}
   925           }
   926        }
   927  
   928  The precpu_stats is the cpu statistic of last read, which is used for calculating the cpu usage percent. It is not the exact copy of the “cpu_stats” field.
   929  
   930  Query Parameters:
   931  
   932  -   **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`.
   933  
   934  Status Codes:
   935  
   936  -   **200** – no error
   937  -   **404** – no such container
   938  -   **500** – server error
   939  
   940  ### Resize a container TTY
   941  
   942  `POST /containers/(id or name)/resize`
   943  
   944  Resize the TTY for container with  `id`. The unit is number of characters. You must restart the container for the resize to take effect.
   945  
   946  **Example request**:
   947  
   948        POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   949  
   950  **Example response**:
   951  
   952        HTTP/1.1 200 OK
   953        Content-Length: 0
   954        Content-Type: text/plain; charset=utf-8
   955  
   956  Query Parameters:
   957  
   958  -   **h** – height of `tty` session
   959  -   **w** – width
   960  
   961  Status Codes:
   962  
   963  -   **200** – no error
   964  -   **404** – No such container
   965  -   **500** – Cannot resize container
   966  
   967  ### Start a container
   968  
   969  `POST /containers/(id or name)/start`
   970  
   971  Start the container `id`
   972  
   973  > **Note**:
   974  > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
   975  > See [create a container](#create-a-container) for details.
   976  
   977  **Example request**:
   978  
   979      POST /containers/e90e34656806/start HTTP/1.1
   980  
   981  **Example response**:
   982  
   983      HTTP/1.1 204 No Content
   984  
   985  Query Parameters:
   986  
   987  -   **detachKeys** – Override the key sequence for detaching a
   988          container. Format is a single character `[a-Z]` or `ctrl-<value>`
   989          where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
   990  
   991  Status Codes:
   992  
   993  -   **204** – no error
   994  -   **304** – container already started
   995  -   **404** – no such container
   996  -   **500** – server error
   997  
   998  ### Stop a container
   999  
  1000  `POST /containers/(id or name)/stop`
  1001  
  1002  Stop the container `id`
  1003  
  1004  **Example request**:
  1005  
  1006      POST /containers/e90e34656806/stop?t=5 HTTP/1.1
  1007  
  1008  **Example response**:
  1009  
  1010      HTTP/1.1 204 No Content
  1011  
  1012  Query Parameters:
  1013  
  1014  -   **t** – number of seconds to wait before killing the container
  1015  
  1016  Status Codes:
  1017  
  1018  -   **204** – no error
  1019  -   **304** – container already stopped
  1020  -   **404** – no such container
  1021  -   **500** – server error
  1022  
  1023  ### Restart a container
  1024  
  1025  `POST /containers/(id or name)/restart`
  1026  
  1027  Restart the container `id`
  1028  
  1029  **Example request**:
  1030  
  1031      POST /containers/e90e34656806/restart?t=5 HTTP/1.1
  1032  
  1033  **Example response**:
  1034  
  1035      HTTP/1.1 204 No Content
  1036  
  1037  Query Parameters:
  1038  
  1039  -   **t** – number of seconds to wait before killing the container
  1040  
  1041  Status Codes:
  1042  
  1043  -   **204** – no error
  1044  -   **404** – no such container
  1045  -   **500** – server error
  1046  
  1047  ### Kill a container
  1048  
  1049  `POST /containers/(id or name)/kill`
  1050  
  1051  Kill the container `id`
  1052  
  1053  **Example request**:
  1054  
  1055      POST /containers/e90e34656806/kill HTTP/1.1
  1056  
  1057  **Example response**:
  1058  
  1059      HTTP/1.1 204 No Content
  1060  
  1061  Query Parameters
  1062  
  1063  -   **signal** - Signal to send to the container: integer or string like `SIGINT`.
  1064          When not set, `SIGKILL` is assumed and the call waits for the container to exit.
  1065  
  1066  Status Codes:
  1067  
  1068  -   **204** – no error
  1069  -   **404** – no such container
  1070  -   **500** – server error
  1071  
  1072  ### Update a container
  1073  
  1074  `POST /containers/(id or name)/update`
  1075  
  1076  Update resource configs of one or more containers.
  1077  
  1078  **Example request**:
  1079  
  1080         POST /containers/e90e34656806/update HTTP/1.1
  1081         Content-Type: application/json
  1082  
  1083         {
  1084           "BlkioWeight": 300,
  1085           "CpuShares": 512,
  1086           "CpuPeriod": 100000,
  1087           "CpuQuota": 50000,
  1088           "CpusetCpus": "0,1",
  1089           "CpusetMems": "0",
  1090           "Memory": 314572800,
  1091           "MemorySwap": 514288000,
  1092           "MemoryReservation": 209715200,
  1093           "KernelMemory": 52428800,
  1094         }
  1095  
  1096  **Example response**:
  1097  
  1098         HTTP/1.1 200 OK
  1099         Content-Type: application/json
  1100  
  1101         {
  1102             "Warnings": []
  1103         }
  1104  
  1105  Status Codes:
  1106  
  1107  -   **200** – no error
  1108  -   **400** – bad parameter
  1109  -   **404** – no such container
  1110  -   **500** – server error
  1111  
  1112  ### Rename a container
  1113  
  1114  `POST /containers/(id or name)/rename`
  1115  
  1116  Rename the container `id` to a `new_name`
  1117  
  1118  **Example request**:
  1119  
  1120      POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
  1121  
  1122  **Example response**:
  1123  
  1124      HTTP/1.1 204 No Content
  1125  
  1126  Query Parameters:
  1127  
  1128  -   **name** – new name for the container
  1129  
  1130  Status Codes:
  1131  
  1132  -   **204** – no error
  1133  -   **404** – no such container
  1134  -   **409** - conflict name already assigned
  1135  -   **500** – server error
  1136  
  1137  ### Pause a container
  1138  
  1139  `POST /containers/(id or name)/pause`
  1140  
  1141  Pause the container `id`
  1142  
  1143  **Example request**:
  1144  
  1145      POST /containers/e90e34656806/pause HTTP/1.1
  1146  
  1147  **Example response**:
  1148  
  1149      HTTP/1.1 204 No Content
  1150  
  1151  Status Codes:
  1152  
  1153  -   **204** – no error
  1154  -   **404** – no such container
  1155  -   **500** – server error
  1156  
  1157  ### Unpause a container
  1158  
  1159  `POST /containers/(id or name)/unpause`
  1160  
  1161  Unpause the container `id`
  1162  
  1163  **Example request**:
  1164  
  1165      POST /containers/e90e34656806/unpause HTTP/1.1
  1166  
  1167  **Example response**:
  1168  
  1169      HTTP/1.1 204 No Content
  1170  
  1171  Status Codes:
  1172  
  1173  -   **204** – no error
  1174  -   **404** – no such container
  1175  -   **500** – server error
  1176  
  1177  ### Attach to a container
  1178  
  1179  `POST /containers/(id or name)/attach`
  1180  
  1181  Attach to the container `id`
  1182  
  1183  **Example request**:
  1184  
  1185      POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
  1186  
  1187  **Example response**:
  1188  
  1189      HTTP/1.1 101 UPGRADED
  1190      Content-Type: application/vnd.docker.raw-stream
  1191      Connection: Upgrade
  1192      Upgrade: tcp
  1193  
  1194      {{ STREAM }}
  1195  
  1196  Query Parameters:
  1197  
  1198  -   **detachKeys** – Override the key sequence for detaching a
  1199          container. Format is a single character `[a-Z]` or `ctrl-<value>`
  1200          where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
  1201  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
  1202  -   **stream** – 1/True/true or 0/False/false, return stream.
  1203          Default `false`.
  1204  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
  1205          to `stdin`. Default `false`.
  1206  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
  1207          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
  1208  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
  1209          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
  1210  
  1211  Status Codes:
  1212  
  1213  -   **101** – no error, hints proxy about hijacking
  1214  -   **200** – no error, no upgrade header found
  1215  -   **400** – bad parameter
  1216  -   **404** – no such container
  1217  -   **500** – server error
  1218  
  1219      **Stream details**:
  1220  
  1221      When using the TTY setting is enabled in
  1222      [`POST /containers/create`
  1223      ](#create-a-container),
  1224      the stream is the raw data from the process PTY and client's `stdin`.
  1225      When the TTY is disabled, then the stream is multiplexed to separate
  1226      `stdout` and `stderr`.
  1227  
  1228      The format is a **Header** and a **Payload** (frame).
  1229  
  1230      **HEADER**
  1231  
  1232      The header contains the information which the stream writes (`stdout` or
  1233      `stderr`). It also contains the size of the associated frame encoded in the
  1234      last four bytes (`uint32`).
  1235  
  1236      It is encoded on the first eight bytes like this:
  1237  
  1238          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
  1239  
  1240      `STREAM_TYPE` can be:
  1241  
  1242  -   0: `stdin` (is written on `stdout`)
  1243  -   1: `stdout`
  1244  -   2: `stderr`
  1245  
  1246      `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of
  1247      the `uint32` size encoded as big endian.
  1248  
  1249      **PAYLOAD**
  1250  
  1251      The payload is the raw stream.
  1252  
  1253      **IMPLEMENTATION**
  1254  
  1255      The simplest way to implement the Attach protocol is the following:
  1256  
  1257      1.  Read eight bytes.
  1258      2.  Choose `stdout` or `stderr` depending on the first byte.
  1259      3.  Extract the frame size from the last four bytes.
  1260      4.  Read the extracted size and output it on the correct output.
  1261      5.  Goto 1.
  1262  
  1263  ### Attach to a container (websocket)
  1264  
  1265  `GET /containers/(id or name)/attach/ws`
  1266  
  1267  Attach to the container `id` via websocket
  1268  
  1269  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
  1270  
  1271  **Example request**
  1272  
  1273      GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
  1274  
  1275  **Example response**
  1276  
  1277      {{ STREAM }}
  1278  
  1279  Query Parameters:
  1280  
  1281  -   **detachKeys** – Override the key sequence for detaching a
  1282          container. Format is a single character `[a-Z]` or `ctrl-<value>`
  1283          where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
  1284  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
  1285  -   **stream** – 1/True/true or 0/False/false, return stream.
  1286          Default `false`.
  1287  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
  1288          to `stdin`. Default `false`.
  1289  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
  1290          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
  1291  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
  1292          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
  1293  
  1294  Status Codes:
  1295  
  1296  -   **200** – no error
  1297  -   **400** – bad parameter
  1298  -   **404** – no such container
  1299  -   **500** – server error
  1300  
  1301  ### Wait a container
  1302  
  1303  `POST /containers/(id or name)/wait`
  1304  
  1305  Block until container `id` stops, then returns the exit code
  1306  
  1307  **Example request**:
  1308  
  1309      POST /containers/16253994b7c4/wait HTTP/1.1
  1310  
  1311  **Example response**:
  1312  
  1313      HTTP/1.1 200 OK
  1314      Content-Type: application/json
  1315  
  1316      {"StatusCode": 0}
  1317  
  1318  Status Codes:
  1319  
  1320  -   **200** – no error
  1321  -   **404** – no such container
  1322  -   **500** – server error
  1323  
  1324  ### Remove a container
  1325  
  1326  `DELETE /containers/(id or name)`
  1327  
  1328  Remove the container `id` from the filesystem
  1329  
  1330  **Example request**:
  1331  
  1332      DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  1333  
  1334  **Example response**:
  1335  
  1336      HTTP/1.1 204 No Content
  1337  
  1338  Query Parameters:
  1339  
  1340  -   **v** – 1/True/true or 0/False/false, Remove the volumes
  1341          associated to the container. Default `false`.
  1342  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
  1343          Default `false`.
  1344  
  1345  Status Codes:
  1346  
  1347  -   **204** – no error
  1348  -   **400** – bad parameter
  1349  -   **404** – no such container
  1350  -   **500** – server error
  1351  
  1352  ### Copy files or folders from a container
  1353  
  1354  `POST /containers/(id or name)/copy`
  1355  
  1356  Copy files or folders of container `id`
  1357  
  1358  **Deprecated** in favor of the `archive` endpoint below.
  1359  
  1360  **Example request**:
  1361  
  1362      POST /containers/4fa6e0f0c678/copy HTTP/1.1
  1363      Content-Type: application/json
  1364  
  1365      {
  1366           "Resource": "test.txt"
  1367      }
  1368  
  1369  **Example response**:
  1370  
  1371      HTTP/1.1 200 OK
  1372      Content-Type: application/x-tar
  1373  
  1374      {{ TAR STREAM }}
  1375  
  1376  Status Codes:
  1377  
  1378  -   **200** – no error
  1379  -   **404** – no such container
  1380  -   **500** – server error
  1381  
  1382  ### Retrieving information about files and folders in a container
  1383  
  1384  `HEAD /containers/(id or name)/archive`
  1385  
  1386  See the description of the `X-Docker-Container-Path-Stat` header in the
  1387  following section.
  1388  
  1389  ### Get an archive of a filesystem resource in a container
  1390  
  1391  `GET /containers/(id or name)/archive`
  1392  
  1393  Get a tar archive of a resource in the filesystem of container `id`.
  1394  
  1395  Query Parameters:
  1396  
  1397  - **path** - resource in the container's filesystem to archive. Required.
  1398  
  1399      If not an absolute path, it is relative to the container's root directory.
  1400      The resource specified by **path** must exist. To assert that the resource
  1401      is expected to be a directory, **path** should end in `/` or  `/.`
  1402      (assuming a path separator of `/`). If **path** ends in `/.` then this
  1403      indicates that only the contents of the **path** directory should be
  1404      copied. A symlink is always resolved to its target.
  1405  
  1406      **Note**: It is not possible to copy certain system files such as resources
  1407      under `/proc`, `/sys`, `/dev`, and mounts created by the user in the
  1408      container.
  1409  
  1410  **Example request**:
  1411  
  1412          GET /containers/8cce319429b2/archive?path=/root HTTP/1.1
  1413  
  1414  **Example response**:
  1415  
  1416          HTTP/1.1 200 OK
  1417          Content-Type: application/x-tar
  1418          X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
  1419  
  1420          {{ TAR STREAM }}
  1421  
  1422  On success, a response header `X-Docker-Container-Path-Stat` will be set to a
  1423  base64-encoded JSON object containing some filesystem header information about
  1424  the archived resource. The above example value would decode to the following
  1425  JSON object (whitespace added for readability):
  1426  
  1427          {
  1428              "name": "root",
  1429              "size": 4096,
  1430              "mode": 2147484096,
  1431              "mtime": "2014-02-27T20:51:23Z",
  1432              "linkTarget": ""
  1433          }
  1434  
  1435  A `HEAD` request can also be made to this endpoint if only this information is
  1436  desired.
  1437  
  1438  Status Codes:
  1439  
  1440  - **200** - success, returns archive of copied resource
  1441  - **400** - client error, bad parameter, details in JSON response body, one of:
  1442      - must specify path parameter (**path** cannot be empty)
  1443      - not a directory (**path** was asserted to be a directory but exists as a
  1444        file)
  1445  - **404** - client error, resource not found, one of:
  1446      – no such container (container `id` does not exist)
  1447      - no such file or directory (**path** does not exist)
  1448  - **500** - server error
  1449  
  1450  ### Extract an archive of files or folders to a directory in a container
  1451  
  1452  `PUT /containers/(id or name)/archive`
  1453  
  1454  Upload a tar archive to be extracted to a path in the filesystem of container
  1455  `id`.
  1456  
  1457  Query Parameters:
  1458  
  1459  - **path** - path to a directory in the container
  1460      to extract the archive's contents into. Required.
  1461  
  1462      If not an absolute path, it is relative to the container's root directory.
  1463      The **path** resource must exist.
  1464  - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error
  1465      if unpacking the given content would cause an existing directory to be
  1466      replaced with a non-directory and vice versa.
  1467  
  1468  **Example request**:
  1469  
  1470      PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
  1471      Content-Type: application/x-tar
  1472  
  1473      {{ TAR STREAM }}
  1474  
  1475  **Example response**:
  1476  
  1477      HTTP/1.1 200 OK
  1478  
  1479  Status Codes:
  1480  
  1481  - **200** – the content was extracted successfully
  1482  - **400** - client error, bad parameter, details in JSON response body, one of:
  1483      - must specify path parameter (**path** cannot be empty)
  1484      - not a directory (**path** should be a directory but exists as a file)
  1485      - unable to overwrite existing directory with non-directory
  1486        (if **noOverwriteDirNonDir**)
  1487      - unable to overwrite existing non-directory with directory
  1488        (if **noOverwriteDirNonDir**)
  1489  - **403** - client error, permission denied, the volume
  1490      or container rootfs is marked as read-only.
  1491  - **404** - client error, resource not found, one of:
  1492      – no such container (container `id` does not exist)
  1493      - no such file or directory (**path** resource does not exist)
  1494  - **500** – server error
  1495  
  1496  ## 2.2 Images
  1497  
  1498  ### List Images
  1499  
  1500  `GET /images/json`
  1501  
  1502  **Example request**:
  1503  
  1504      GET /images/json?all=0 HTTP/1.1
  1505  
  1506  **Example response**:
  1507  
  1508      HTTP/1.1 200 OK
  1509      Content-Type: application/json
  1510  
  1511      [
  1512        {
  1513           "RepoTags": [
  1514             "ubuntu:12.04",
  1515             "ubuntu:precise",
  1516             "ubuntu:latest"
  1517           ],
  1518           "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
  1519           "Created": 1365714795,
  1520           "Size": 131506275,
  1521           "VirtualSize": 131506275,
  1522           "Labels": {}
  1523        },
  1524        {
  1525           "RepoTags": [
  1526             "ubuntu:12.10",
  1527             "ubuntu:quantal"
  1528           ],
  1529           "ParentId": "27cf784147099545",
  1530           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1531           "Created": 1364102658,
  1532           "Size": 24653,
  1533           "VirtualSize": 180116135,
  1534           "Labels": {
  1535              "com.example.version": "v1"
  1536           }
  1537        }
  1538      ]
  1539  
  1540  **Example request, with digest information**:
  1541  
  1542      GET /images/json?digests=1 HTTP/1.1
  1543  
  1544  **Example response, with digest information**:
  1545  
  1546      HTTP/1.1 200 OK
  1547      Content-Type: application/json
  1548  
  1549      [
  1550        {
  1551          "Created": 1420064636,
  1552          "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
  1553          "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
  1554          "RepoDigests": [
  1555            "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
  1556          ],
  1557          "RepoTags": [
  1558            "localhost:5000/test/busybox:latest",
  1559            "playdate:latest"
  1560          ],
  1561          "Size": 0,
  1562          "VirtualSize": 2429728,
  1563          "Labels": {}
  1564        }
  1565      ]
  1566  
  1567  The response shows a single image `Id` associated with two repositories
  1568  (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use
  1569  either of the `RepoTags` values `localhost:5000/test/busybox:latest` or
  1570  `playdate:latest` to reference the image.
  1571  
  1572  You can also use `RepoDigests` values to reference an image. In this response,
  1573  the array has only one reference and that is to the
  1574  `localhost:5000/test/busybox` repository; the `playdate` repository has no
  1575  digest. You can reference this digest using the value:
  1576  `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
  1577  
  1578  See the `docker run` and `docker build` commands for examples of digest and tag
  1579  references on the command line.
  1580  
  1581  Query Parameters:
  1582  
  1583  -   **all** – 1/True/true or 0/False/false, default false
  1584  -   **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
  1585    -   `dangling=true`
  1586    -   `label=key` or `label="key=value"` of an image label
  1587  -   **filter** - only return images with the specified name
  1588  
  1589  ### Build image from a Dockerfile
  1590  
  1591  `POST /build`
  1592  
  1593  Build an image from a Dockerfile
  1594  
  1595  **Example request**:
  1596  
  1597      POST /build HTTP/1.1
  1598  
  1599      {{ TAR STREAM }}
  1600  
  1601  **Example response**:
  1602  
  1603      HTTP/1.1 200 OK
  1604      Content-Type: application/json
  1605  
  1606      {"stream": "Step 1..."}
  1607      {"stream": "..."}
  1608      {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1609  
  1610  The input stream must be a `tar` archive compressed with one of the
  1611  following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`.
  1612  
  1613  The archive must include a build instructions file, typically called
  1614  `Dockerfile` at the archive's root. The `dockerfile` parameter may be
  1615  used to specify a different build instructions file. To do this, its value must be
  1616  the path to the alternate build instructions file to use.
  1617  
  1618  The archive may include any number of other files,
  1619  which are accessible in the build context (See the [*ADD build
  1620  command*](../../reference/builder.md#dockerbuilder)).
  1621  
  1622  The build is canceled if the client drops the connection by quitting
  1623  or being killed.
  1624  
  1625  Query Parameters:
  1626  
  1627  -   **dockerfile** - Path within the build context to the Dockerfile. This is
  1628          ignored if `remote` is specified and points to an individual filename.
  1629  -   **t** – A name and optional tag to apply to the image in the `name:tag` format.
  1630          If you omit the `tag` the default `latest` value is assumed.
  1631          You can provide one or more `t` parameters.
  1632  -   **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the
  1633          URI specifies a filename, the file's contents are placed into a file
  1634  		called `Dockerfile`.
  1635  -   **q** – Suppress verbose build output.
  1636  -   **nocache** – Do not use the cache when building the image.
  1637  -   **pull** - Attempt to pull the image even if an older image exists locally.
  1638  -   **rm** - Remove intermediate containers after a successful build (default behavior).
  1639  -   **forcerm** - Always remove intermediate containers (includes `rm`).
  1640  -   **memory** - Set memory limit for build.
  1641  -   **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap.
  1642  -   **cpushares** - CPU shares (relative weight).
  1643  -   **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`).
  1644  -   **cpuperiod** - The length of a CPU period in microseconds.
  1645  -   **cpuquota** - Microseconds of CPU time that the container can get in a CPU period.
  1646  -   **buildargs** – JSON map of string pairs for build-time variables. Users pass
  1647          these values at build-time. Docker uses the `buildargs` as the environment
  1648          context for command(s) run via the Dockerfile's `RUN` instruction or for
  1649          variable expansion in other Dockerfile instructions. This is not meant for
  1650          passing secret values. [Read more about the buildargs instruction](../../reference/builder.md#arg)
  1651  -   **shmsize** - Size of `/dev/shm` in bytes. The size must be greater than 0.  If omitted the system uses 64MB.
  1652  
  1653      Request Headers:
  1654  
  1655  -   **Content-type** – Set to `"application/tar"`.
  1656  -   **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
  1657          object with the following structure:
  1658  
  1659              {
  1660                  "docker.example.com": {
  1661                      "username": "janedoe",
  1662                      "password": "hunter2"
  1663                  },
  1664                  "https://index.docker.io/v1/": {
  1665                      "username": "mobydock",
  1666                      "password": "conta1n3rize14"
  1667                  }
  1668              }
  1669  
  1670      This object maps the hostname of a registry to an object containing the
  1671      "username" and "password" for that registry. Multiple registries may
  1672      be specified as the build may be based on an image requiring
  1673      authentication to pull from any arbitrary registry. Only the registry
  1674      domain name (and port if not the default "443") are required. However
  1675      (for legacy reasons) the "official" Docker, Inc. hosted registry must
  1676      be specified with both a "https://" prefix and a "/v1/" suffix even
  1677      though Docker will prefer to use the v2 registry API.
  1678  
  1679  Status Codes:
  1680  
  1681  -   **200** – no error
  1682  -   **500** – server error
  1683  
  1684  ### Create an image
  1685  
  1686  `POST /images/create`
  1687  
  1688  Create an image either by pulling it from the registry or by importing it
  1689  
  1690  **Example request**:
  1691  
  1692      POST /images/create?fromImage=ubuntu HTTP/1.1
  1693  
  1694  **Example response**:
  1695  
  1696      HTTP/1.1 200 OK
  1697      Content-Type: application/json
  1698  
  1699      {"status": "Pulling..."}
  1700      {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
  1701      {"error": "Invalid..."}
  1702      ...
  1703  
  1704  When using this endpoint to pull an image from the registry, the
  1705  `X-Registry-Auth` header can be used to include
  1706  a base64-encoded AuthConfig object.
  1707  
  1708  Query Parameters:
  1709  
  1710  -   **fromImage** – Name of the image to pull. The name may include a tag or
  1711          digest. This parameter may only be used when pulling an image.
  1712          The pull is cancelled if the HTTP connection is closed.
  1713  -   **fromSrc** – Source to import.  The value may be a URL from which the image
  1714          can be retrieved or `-` to read the image from the request body.
  1715          This parameter may only be used when importing an image.
  1716  -   **repo** – Repository name given to an image when it is imported.
  1717          The repo may include a tag. This parameter may only be used when importing
  1718          an image.
  1719  -   **tag** – Tag or digest.
  1720  
  1721      Request Headers:
  1722  
  1723  -   **X-Registry-Auth** – base64-encoded AuthConfig object, containing either login information, or a token
  1724      - Credential based login:
  1725  
  1726          ```
  1727      {
  1728              "username": "jdoe",
  1729              "password": "secret",
  1730              "email": "jdoe@acme.com",
  1731      }
  1732          ```
  1733  
  1734      - Token based login:
  1735  
  1736          ```
  1737      {
  1738              "registrytoken": "9cbaf023786cd7..."
  1739      }
  1740          ```
  1741  
  1742  Status Codes:
  1743  
  1744  -   **200** – no error
  1745  -   **500** – server error
  1746  
  1747  
  1748  
  1749  ### Inspect an image
  1750  
  1751  `GET /images/(name)/json`
  1752  
  1753  Return low-level information on the image `name`
  1754  
  1755  **Example request**:
  1756  
  1757      GET /images/example/json HTTP/1.1
  1758  
  1759  **Example response**:
  1760  
  1761      HTTP/1.1 200 OK
  1762      Content-Type: application/json
  1763  
  1764      {
  1765         "Id" : "85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c",
  1766         "Container" : "cb91e48a60d01f1e27028b4fc6819f4f290b3cf12496c8176ec714d0d390984a",
  1767         "Comment" : "",
  1768         "Os" : "linux",
  1769         "Architecture" : "amd64",
  1770         "Parent" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
  1771         "ContainerConfig" : {
  1772            "Tty" : false,
  1773            "Hostname" : "e611e15f9c9d",
  1774            "Volumes" : null,
  1775            "Domainname" : "",
  1776            "AttachStdout" : false,
  1777            "PublishService" : "",
  1778            "AttachStdin" : false,
  1779            "OpenStdin" : false,
  1780            "StdinOnce" : false,
  1781            "NetworkDisabled" : false,
  1782            "OnBuild" : [],
  1783            "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
  1784            "User" : "",
  1785            "WorkingDir" : "",
  1786            "Entrypoint" : null,
  1787            "MacAddress" : "",
  1788            "AttachStderr" : false,
  1789            "Labels" : {
  1790               "com.example.license" : "GPL",
  1791               "com.example.version" : "1.0",
  1792               "com.example.vendor" : "Acme"
  1793            },
  1794            "Env" : [
  1795               "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  1796            ],
  1797            "ExposedPorts" : null,
  1798            "Cmd" : [
  1799               "/bin/sh",
  1800               "-c",
  1801               "#(nop) LABEL com.example.vendor=Acme com.example.license=GPL com.example.version=1.0"
  1802            ]
  1803         },
  1804         "DockerVersion" : "1.9.0-dev",
  1805         "VirtualSize" : 188359297,
  1806         "Size" : 0,
  1807         "Author" : "",
  1808         "Created" : "2015-09-10T08:30:53.26995814Z",
  1809         "GraphDriver" : {
  1810            "Name" : "aufs",
  1811            "Data" : null
  1812         },
  1813         "RepoDigests" : [
  1814            "localhost:5000/test/busybox/example@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
  1815         ],
  1816         "RepoTags" : [
  1817            "example:1.0",
  1818            "example:latest",
  1819            "example:stable"
  1820         ],
  1821         "Config" : {
  1822            "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
  1823            "NetworkDisabled" : false,
  1824            "OnBuild" : [],
  1825            "StdinOnce" : false,
  1826            "PublishService" : "",
  1827            "AttachStdin" : false,
  1828            "OpenStdin" : false,
  1829            "Domainname" : "",
  1830            "AttachStdout" : false,
  1831            "Tty" : false,
  1832            "Hostname" : "e611e15f9c9d",
  1833            "Volumes" : null,
  1834            "Cmd" : [
  1835               "/bin/bash"
  1836            ],
  1837            "ExposedPorts" : null,
  1838            "Env" : [
  1839               "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  1840            ],
  1841            "Labels" : {
  1842               "com.example.vendor" : "Acme",
  1843               "com.example.version" : "1.0",
  1844               "com.example.license" : "GPL"
  1845            },
  1846            "Entrypoint" : null,
  1847            "MacAddress" : "",
  1848            "AttachStderr" : false,
  1849            "WorkingDir" : "",
  1850            "User" : ""
  1851         }
  1852      }
  1853  
  1854  Status Codes:
  1855  
  1856  -   **200** – no error
  1857  -   **404** – no such image
  1858  -   **500** – server error
  1859  
  1860  ### Get the history of an image
  1861  
  1862  `GET /images/(name)/history`
  1863  
  1864  Return the history of the image `name`
  1865  
  1866  **Example request**:
  1867  
  1868      GET /images/ubuntu/history HTTP/1.1
  1869  
  1870  **Example response**:
  1871  
  1872      HTTP/1.1 200 OK
  1873      Content-Type: application/json
  1874  
  1875      [
  1876          {
  1877              "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710",
  1878              "Created": 1398108230,
  1879              "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /",
  1880              "Tags": [
  1881                  "ubuntu:lucid",
  1882                  "ubuntu:10.04"
  1883              ],
  1884              "Size": 182964289,
  1885              "Comment": ""
  1886          },
  1887          {
  1888              "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8",
  1889              "Created": 1398108222,
  1890              "CreatedBy": "/bin/sh -c #(nop) MAINTAINER Tianon Gravi <admwiggin@gmail.com> - mkimage-debootstrap.sh -i iproute,iputils-ping,ubuntu-minimal -t lucid.tar.xz lucid http://archive.ubuntu.com/ubuntu/",
  1891              "Tags": null,
  1892              "Size": 0,
  1893              "Comment": ""
  1894          },
  1895          {
  1896              "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158",
  1897              "Created": 1371157430,
  1898              "CreatedBy": "",
  1899              "Tags": [
  1900                  "scratch12:latest",
  1901                  "scratch:latest"
  1902              ],
  1903              "Size": 0,
  1904              "Comment": "Imported from -"
  1905          }
  1906      ]
  1907  
  1908  Status Codes:
  1909  
  1910  -   **200** – no error
  1911  -   **404** – no such image
  1912  -   **500** – server error
  1913  
  1914  ### Push an image on the registry
  1915  
  1916  `POST /images/(name)/push`
  1917  
  1918  Push the image `name` on the registry
  1919  
  1920  **Example request**:
  1921  
  1922      POST /images/test/push HTTP/1.1
  1923  
  1924  **Example response**:
  1925  
  1926      HTTP/1.1 200 OK
  1927      Content-Type: application/json
  1928  
  1929      {"status": "Pushing..."}
  1930      {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1931      {"error": "Invalid..."}
  1932      ...
  1933  
  1934  If you wish to push an image on to a private registry, that image must already have a tag
  1935  into a repository which references that registry `hostname` and `port`.  This repository name should
  1936  then be used in the URL. This duplicates the command line's flow.
  1937  
  1938  The push is cancelled if the HTTP connection is closed.
  1939  
  1940  **Example request**:
  1941  
  1942      POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1943  
  1944  
  1945  Query Parameters:
  1946  
  1947  -   **tag** – The tag to associate with the image on the registry. This is optional.
  1948  
  1949  Request Headers:
  1950  
  1951  -   **X-Registry-Auth** – base64-encoded AuthConfig object, containing either login information, or a token
  1952      - Credential based login:
  1953  
  1954          ```
  1955      {
  1956              "username": "jdoe",
  1957              "password": "secret",
  1958              "email": "jdoe@acme.com",
  1959      }
  1960          ```
  1961  
  1962      - Token based login:
  1963  
  1964          ```
  1965      {
  1966              "registrytoken": "9cbaf023786cd7..."
  1967      }
  1968          ```
  1969  
  1970  Status Codes:
  1971  
  1972  -   **200** – no error
  1973  -   **404** – no such image
  1974  -   **500** – server error
  1975  
  1976  ### Tag an image into a repository
  1977  
  1978  `POST /images/(name)/tag`
  1979  
  1980  Tag the image `name` into a repository
  1981  
  1982  **Example request**:
  1983  
  1984      POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1985  
  1986  **Example response**:
  1987  
  1988      HTTP/1.1 201 Created
  1989  
  1990  Query Parameters:
  1991  
  1992  -   **repo** – The repository to tag in
  1993  -   **force** – 1/True/true or 0/False/false, default false
  1994  -   **tag** - The new tag name
  1995  
  1996  Status Codes:
  1997  
  1998  -   **201** – no error
  1999  -   **400** – bad parameter
  2000  -   **404** – no such image
  2001  -   **409** – conflict
  2002  -   **500** – server error
  2003  
  2004  ### Remove an image
  2005  
  2006  `DELETE /images/(name)`
  2007  
  2008  Remove the image `name` from the filesystem
  2009  
  2010  **Example request**:
  2011  
  2012      DELETE /images/test HTTP/1.1
  2013  
  2014  **Example response**:
  2015  
  2016      HTTP/1.1 200 OK
  2017      Content-type: application/json
  2018  
  2019      [
  2020       {"Untagged": "3e2f21a89f"},
  2021       {"Deleted": "3e2f21a89f"},
  2022       {"Deleted": "53b4f83ac9"}
  2023      ]
  2024  
  2025  Query Parameters:
  2026  
  2027  -   **force** – 1/True/true or 0/False/false, default false
  2028  -   **noprune** – 1/True/true or 0/False/false, default false
  2029  
  2030  Status Codes:
  2031  
  2032  -   **200** – no error
  2033  -   **404** – no such image
  2034  -   **409** – conflict
  2035  -   **500** – server error
  2036  
  2037  ### Search images
  2038  
  2039  `GET /images/search`
  2040  
  2041  Search for an image on [Docker Hub](https://hub.docker.com).
  2042  
  2043  > **Note**:
  2044  > The response keys have changed from API v1.6 to reflect the JSON
  2045  > sent by the registry server to the docker daemon's request.
  2046  
  2047  **Example request**:
  2048  
  2049      GET /images/search?term=sshd HTTP/1.1
  2050  
  2051  **Example response**:
  2052  
  2053      HTTP/1.1 200 OK
  2054      Content-Type: application/json
  2055  
  2056      [
  2057              {
  2058                  "description": "",
  2059                  "is_official": false,
  2060                  "is_automated": false,
  2061                  "name": "wma55/u1210sshd",
  2062                  "star_count": 0
  2063              },
  2064              {
  2065                  "description": "",
  2066                  "is_official": false,
  2067                  "is_automated": false,
  2068                  "name": "jdswinbank/sshd",
  2069                  "star_count": 0
  2070              },
  2071              {
  2072                  "description": "",
  2073                  "is_official": false,
  2074                  "is_automated": false,
  2075                  "name": "vgauthier/sshd",
  2076                  "star_count": 0
  2077              }
  2078      ...
  2079      ]
  2080  
  2081  Query Parameters:
  2082  
  2083  -   **term** – term to search
  2084  
  2085  Status Codes:
  2086  
  2087  -   **200** – no error
  2088  -   **500** – server error
  2089  
  2090  ## 2.3 Misc
  2091  
  2092  ### Check auth configuration
  2093  
  2094  `POST /auth`
  2095  
  2096  Get the default username and email
  2097  
  2098  **Example request**:
  2099  
  2100      POST /auth HTTP/1.1
  2101      Content-Type: application/json
  2102  
  2103      {
  2104           "username":" hannibal",
  2105           "password: "xxxx",
  2106           "email": "hannibal@a-team.com",
  2107           "serveraddress": "https://index.docker.io/v1/"
  2108      }
  2109  
  2110  **Example response**:
  2111  
  2112      HTTP/1.1 200 OK
  2113  
  2114  Status Codes:
  2115  
  2116  -   **200** – no error
  2117  -   **204** – no error
  2118  -   **500** – server error
  2119  
  2120  ### Display system-wide information
  2121  
  2122  `GET /info`
  2123  
  2124  Display system-wide information
  2125  
  2126  **Example request**:
  2127  
  2128      GET /info HTTP/1.1
  2129  
  2130  **Example response**:
  2131  
  2132      HTTP/1.1 200 OK
  2133      Content-Type: application/json
  2134  
  2135      {
  2136          "Architecture": "x86_64",
  2137          "ClusterStore": "etcd://localhost:2379",
  2138          "Containers": 11,
  2139          "ContainersRunning": 7,
  2140          "ContainersStopped": 3,
  2141          "ContainersPaused": 1,
  2142          "CpuCfsPeriod": true,
  2143          "CpuCfsQuota": true,
  2144          "Debug": false,
  2145          "DockerRootDir": "/var/lib/docker",
  2146          "Driver": "btrfs",
  2147          "DriverStatus": [[""]],
  2148          "ExecutionDriver": "native-0.1",
  2149          "ExperimentalBuild": false,
  2150          "HttpProxy": "http://test:test@localhost:8080",
  2151          "HttpsProxy": "https://test:test@localhost:8080",
  2152          "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  2153          "IPv4Forwarding": true,
  2154          "Images": 16,
  2155          "IndexServerAddress": "https://index.docker.io/v1/",
  2156          "InitPath": "/usr/bin/docker",
  2157          "InitSha1": "",
  2158          "KernelVersion": "3.12.0-1-amd64",
  2159          "Labels": [
  2160              "storage=ssd"
  2161          ],
  2162          "MemTotal": 2099236864,
  2163          "MemoryLimit": true,
  2164          "NCPU": 1,
  2165          "NEventsListener": 0,
  2166          "NFd": 11,
  2167          "NGoroutines": 21,
  2168          "Name": "prod-server-42",
  2169          "NoProxy": "9.81.1.160",
  2170          "OomKillDisable": true,
  2171          "OSType": "linux",
  2172          "OperatingSystem": "Boot2Docker",
  2173          "Plugins": {
  2174              "Volume": [
  2175                  "local"
  2176              ],
  2177              "Network": [
  2178                  "null",
  2179                  "host",
  2180                  "bridge"
  2181              ]
  2182          },
  2183          "RegistryConfig": {
  2184              "IndexConfigs": {
  2185                  "docker.io": {
  2186                      "Mirrors": null,
  2187                      "Name": "docker.io",
  2188                      "Official": true,
  2189                      "Secure": true
  2190                  }
  2191              },
  2192              "InsecureRegistryCIDRs": [
  2193                  "127.0.0.0/8"
  2194              ]
  2195          },
  2196          "ServerVersion": "1.9.0",
  2197          "SwapLimit": false,
  2198          "SystemStatus": [["State", "Healthy"]],
  2199          "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
  2200      }
  2201  
  2202  Status Codes:
  2203  
  2204  -   **200** – no error
  2205  -   **500** – server error
  2206  
  2207  ### Show the docker version information
  2208  
  2209  `GET /version`
  2210  
  2211  Show the docker version information
  2212  
  2213  **Example request**:
  2214  
  2215      GET /version HTTP/1.1
  2216  
  2217  **Example response**:
  2218  
  2219      HTTP/1.1 200 OK
  2220      Content-Type: application/json
  2221  
  2222      {
  2223           "Version": "1.10.0-dev",
  2224           "Os": "linux",
  2225           "KernelVersion": "3.19.0-23-generic",
  2226           "GoVersion": "go1.4.2",
  2227           "GitCommit": "e75da4b",
  2228           "Arch": "amd64",
  2229           "ApiVersion": "1.22",
  2230           "BuildTime": "2015-12-01T07:09:13.444803460+00:00",
  2231           "Experimental": true
  2232      }
  2233  
  2234  Status Codes:
  2235  
  2236  -   **200** – no error
  2237  -   **500** – server error
  2238  
  2239  ### Ping the docker server
  2240  
  2241  `GET /_ping`
  2242  
  2243  Ping the docker server
  2244  
  2245  **Example request**:
  2246  
  2247      GET /_ping HTTP/1.1
  2248  
  2249  **Example response**:
  2250  
  2251      HTTP/1.1 200 OK
  2252      Content-Type: text/plain
  2253  
  2254      OK
  2255  
  2256  Status Codes:
  2257  
  2258  -   **200** - no error
  2259  -   **500** - server error
  2260  
  2261  ### Create a new image from a container's changes
  2262  
  2263  `POST /commit`
  2264  
  2265  Create a new image from a container's changes
  2266  
  2267  **Example request**:
  2268  
  2269      POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  2270      Content-Type: application/json
  2271  
  2272      {
  2273           "Hostname": "",
  2274           "Domainname": "",
  2275           "User": "",
  2276           "AttachStdin": false,
  2277           "AttachStdout": true,
  2278           "AttachStderr": true,
  2279           "Tty": false,
  2280           "OpenStdin": false,
  2281           "StdinOnce": false,
  2282           "Env": null,
  2283           "Cmd": [
  2284                   "date"
  2285           ],
  2286           "Mounts": [
  2287             {
  2288               "Source": "/data",
  2289               "Destination": "/data",
  2290               "Mode": "ro,Z",
  2291               "RW": false
  2292             }
  2293           ],
  2294           "Labels": {
  2295                   "key1": "value1",
  2296                   "key2": "value2"
  2297            },
  2298           "WorkingDir": "",
  2299           "NetworkDisabled": false,
  2300           "ExposedPorts": {
  2301                   "22/tcp": {}
  2302           }
  2303      }
  2304  
  2305  **Example response**:
  2306  
  2307      HTTP/1.1 201 Created
  2308      Content-Type: application/json
  2309  
  2310      {"Id": "596069db4bf5"}
  2311  
  2312  Json Parameters:
  2313  
  2314  -  **config** - the container's configuration
  2315  
  2316  Query Parameters:
  2317  
  2318  -   **container** – source container
  2319  -   **repo** – repository
  2320  -   **tag** – tag
  2321  -   **comment** – commit message
  2322  -   **author** – author (e.g., "John Hannibal Smith
  2323      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  2324  -   **pause** – 1/True/true or 0/False/false, whether to pause the container before committing
  2325  -   **changes** – Dockerfile instructions to apply while committing
  2326  
  2327  Status Codes:
  2328  
  2329  -   **201** – no error
  2330  -   **404** – no such container
  2331  -   **500** – server error
  2332  
  2333  ### Monitor Docker's events
  2334  
  2335  `GET /events`
  2336  
  2337  Get container events from docker, either in real time via streaming, or via polling (using since).
  2338  
  2339  Docker containers report the following events:
  2340  
  2341      attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
  2342  
  2343  Docker images report the following events:
  2344  
  2345      delete, import, pull, push, tag, untag
  2346  
  2347  Docker volumes report the following events:
  2348  
  2349      create, mount, unmount, destroy
  2350  
  2351  Docker networks report the following events:
  2352  
  2353      create, connect, disconnect, destroy
  2354  
  2355  **Example request**:
  2356  
  2357      GET /events?since=1374067924
  2358  
  2359  **Example response**:
  2360  
  2361      HTTP/1.1 200 OK
  2362      Content-Type: application/json
  2363      Server: Docker/1.10.0 (linux)
  2364      Date: Fri, 29 Apr 2016 15:18:06 GMT
  2365      Transfer-Encoding: chunked
  2366  
  2367      {
  2368        "status": "pull",
  2369        "id": "alpine:latest",
  2370        "Type": "image",
  2371        "Action": "pull",
  2372        "Actor": {
  2373          "ID": "alpine:latest",
  2374          "Attributes": {
  2375            "name": "alpine"
  2376          }
  2377        },
  2378        "time": 1461943101,
  2379        "timeNano": 1461943101301854122
  2380      }
  2381      {
  2382        "status": "create",
  2383        "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2384        "from": "alpine",
  2385        "Type": "container",
  2386        "Action": "create",
  2387        "Actor": {
  2388          "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2389          "Attributes": {
  2390            "com.example.some-label": "some-label-value",
  2391            "image": "alpine",
  2392            "name": "my-container"
  2393          }
  2394        },
  2395        "time": 1461943101,
  2396        "timeNano": 1461943101381709551
  2397      }
  2398      {
  2399        "status": "attach",
  2400        "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2401        "from": "alpine",
  2402        "Type": "container",
  2403        "Action": "attach",
  2404        "Actor": {
  2405          "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2406          "Attributes": {
  2407            "com.example.some-label": "some-label-value",
  2408            "image": "alpine",
  2409            "name": "my-container"
  2410          }
  2411        },
  2412        "time": 1461943101,
  2413        "timeNano": 1461943101383858412
  2414      }
  2415      {
  2416        "Type": "network",
  2417        "Action": "connect",
  2418        "Actor": {
  2419          "ID": "7dc8ac97d5d29ef6c31b6052f3938c1e8f2749abbd17d1bd1febf2608db1b474",
  2420          "Attributes": {
  2421            "container": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2422            "name": "bridge",
  2423            "type": "bridge"
  2424          }
  2425        },
  2426        "time": 1461943101,
  2427        "timeNano": 1461943101394865557
  2428      }
  2429      {
  2430        "status": "start",
  2431        "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2432        "from": "alpine",
  2433        "Type": "container",
  2434        "Action": "start",
  2435        "Actor": {
  2436          "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2437          "Attributes": {
  2438            "com.example.some-label": "some-label-value",
  2439            "image": "alpine",
  2440            "name": "my-container"
  2441          }
  2442        },
  2443        "time": 1461943101,
  2444        "timeNano": 1461943101607533796
  2445      }
  2446      {
  2447        "status": "resize",
  2448        "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2449        "from": "alpine",
  2450        "Type": "container",
  2451        "Action": "resize",
  2452        "Actor": {
  2453          "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2454          "Attributes": {
  2455            "com.example.some-label": "some-label-value",
  2456            "height": "46",
  2457            "image": "alpine",
  2458            "name": "my-container",
  2459            "width": "204"
  2460          }
  2461        },
  2462        "time": 1461943101,
  2463        "timeNano": 1461943101610269268
  2464      }
  2465      {
  2466        "status": "die",
  2467        "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2468        "from": "alpine",
  2469        "Type": "container",
  2470        "Action": "die",
  2471        "Actor": {
  2472          "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2473          "Attributes": {
  2474            "com.example.some-label": "some-label-value",
  2475            "exitCode": "0",
  2476            "image": "alpine",
  2477            "name": "my-container"
  2478          }
  2479        },
  2480        "time": 1461943105,
  2481        "timeNano": 1461943105079144137
  2482      }
  2483      {
  2484        "Type": "network",
  2485        "Action": "disconnect",
  2486        "Actor": {
  2487          "ID": "7dc8ac97d5d29ef6c31b6052f3938c1e8f2749abbd17d1bd1febf2608db1b474",
  2488          "Attributes": {
  2489            "container": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2490            "name": "bridge",
  2491            "type": "bridge"
  2492          }
  2493        },
  2494        "time": 1461943105,
  2495        "timeNano": 1461943105230860245
  2496      }
  2497      {
  2498        "status": "destroy",
  2499        "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2500        "from": "alpine",
  2501        "Type": "container",
  2502        "Action": "destroy",
  2503        "Actor": {
  2504          "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
  2505          "Attributes": {
  2506            "com.example.some-label": "some-label-value",
  2507            "image": "alpine",
  2508            "name": "my-container"
  2509          }
  2510        },
  2511        "time": 1461943105,
  2512        "timeNano": 1461943105338056026
  2513      }
  2514  
  2515  Query Parameters:
  2516  
  2517  -   **since** – Timestamp used for polling
  2518  -   **until** – Timestamp used for polling
  2519  -   **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  2520    -   `container=<string>`; -- container to filter
  2521    -   `event=<string>`; -- event to filter
  2522    -   `image=<string>`; -- image to filter
  2523    -   `label=<string>`; -- image and container label to filter
  2524    -   `type=<string>`; -- either `container` or `image` or `volume` or `network`
  2525    -   `volume=<string>`; -- volume to filter
  2526    -   `network=<string>`; -- network to filter
  2527  
  2528  Status Codes:
  2529  
  2530  -   **200** – no error
  2531  -   **500** – server error
  2532  
  2533  ### Get a tarball containing all images in a repository
  2534  
  2535  `GET /images/(name)/get`
  2536  
  2537  Get a tarball containing all images and metadata for the repository specified
  2538  by `name`.
  2539  
  2540  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  2541  (and its parents) are returned. If `name` is an image ID, similarly only that
  2542  image (and its parents) are returned, but with the exclusion of the
  2543  'repositories' file in the tarball, as there were no image names referenced.
  2544  
  2545  See the [image tarball format](#image-tarball-format) for more details.
  2546  
  2547  **Example request**
  2548  
  2549      GET /images/ubuntu/get
  2550  
  2551  **Example response**:
  2552  
  2553      HTTP/1.1 200 OK
  2554      Content-Type: application/x-tar
  2555  
  2556      Binary data stream
  2557  
  2558  Status Codes:
  2559  
  2560  -   **200** – no error
  2561  -   **500** – server error
  2562  
  2563  ### Get a tarball containing all images.
  2564  
  2565  `GET /images/get`
  2566  
  2567  Get a tarball containing all images and metadata for one or more repositories.
  2568  
  2569  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  2570  `ubuntu:latest`), then only that image (and its parents) are returned; if it is
  2571  an image ID, similarly only that image (and its parents) are returned and there
  2572  would be no names referenced in the 'repositories' file for this image ID.
  2573  
  2574  See the [image tarball format](#image-tarball-format) for more details.
  2575  
  2576  **Example request**
  2577  
  2578      GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  2579  
  2580  **Example response**:
  2581  
  2582      HTTP/1.1 200 OK
  2583      Content-Type: application/x-tar
  2584  
  2585      Binary data stream
  2586  
  2587  Status Codes:
  2588  
  2589  -   **200** – no error
  2590  -   **500** – server error
  2591  
  2592  ### Load a tarball with a set of images and tags into docker
  2593  
  2594  `POST /images/load`
  2595  
  2596  Load a set of images and tags into a Docker repository.
  2597  See the [image tarball format](#image-tarball-format) for more details.
  2598  
  2599  **Example request**
  2600  
  2601      POST /images/load
  2602  
  2603      Tarball in body
  2604  
  2605  **Example response**:
  2606  
  2607      HTTP/1.1 200 OK
  2608  
  2609  Status Codes:
  2610  
  2611  -   **200** – no error
  2612  -   **500** – server error
  2613  
  2614  ### Image tarball format
  2615  
  2616  An image tarball contains one directory per image layer (named using its long ID),
  2617  each containing these files:
  2618  
  2619  - `VERSION`: currently `1.0` - the file format version
  2620  - `json`: detailed layer information, similar to `docker inspect layer_id`
  2621  - `layer.tar`: A tarfile containing the filesystem changes in this layer
  2622  
  2623  The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories
  2624  for storing attribute changes and deletions.
  2625  
  2626  If the tarball defines a repository, the tarball should also include a `repositories` file at
  2627  the root that contains a list of repository and tag names mapped to layer IDs.
  2628  
  2629  ```
  2630  {"hello-world":
  2631      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  2632  }
  2633  ```
  2634  
  2635  ### Exec Create
  2636  
  2637  `POST /containers/(id or name)/exec`
  2638  
  2639  Sets up an exec instance in a running container `id`
  2640  
  2641  **Example request**:
  2642  
  2643      POST /containers/e90e34656806/exec HTTP/1.1
  2644      Content-Type: application/json
  2645  
  2646        {
  2647         "AttachStdin": false,
  2648         "AttachStdout": true,
  2649         "AttachStderr": true,
  2650         "DetachKeys": "ctrl-p,ctrl-q",
  2651         "Tty": false,
  2652         "Cmd": [
  2653                       "date"
  2654               ]
  2655        }
  2656  
  2657  **Example response**:
  2658  
  2659      HTTP/1.1 201 Created
  2660      Content-Type: application/json
  2661  
  2662      {
  2663           "Id": "f90e34656806",
  2664           "Warnings":[]
  2665      }
  2666  
  2667  Json Parameters:
  2668  
  2669  -   **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command.
  2670  -   **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command.
  2671  -   **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command.
  2672  -   **DetachKeys** – Override the key sequence for detaching a
  2673          container. Format is a single character `[a-Z]` or `ctrl-<value>`
  2674          where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
  2675  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2676  -   **Cmd** - Command to run specified as a string or an array of strings.
  2677  
  2678  
  2679  Status Codes:
  2680  
  2681  -   **201** – no error
  2682  -   **404** – no such container
  2683  -   **409** - container is paused
  2684  -   **500** - server error
  2685  
  2686  ### Exec Start
  2687  
  2688  `POST /exec/(id)/start`
  2689  
  2690  Starts a previously set up `exec` instance `id`. If `detach` is true, this API
  2691  returns after starting the `exec` command. Otherwise, this API sets up an
  2692  interactive session with the `exec` command.
  2693  
  2694  **Example request**:
  2695  
  2696      POST /exec/e90e34656806/start HTTP/1.1
  2697      Content-Type: application/json
  2698  
  2699      {
  2700       "Detach": false,
  2701       "Tty": false
  2702      }
  2703  
  2704  **Example response**:
  2705  
  2706      HTTP/1.1 200 OK
  2707      Content-Type: application/vnd.docker.raw-stream
  2708  
  2709      {{ STREAM }}
  2710  
  2711  Json Parameters:
  2712  
  2713  -   **Detach** - Detach from the `exec` command.
  2714  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2715  
  2716  Status Codes:
  2717  
  2718  -   **200** – no error
  2719  -   **404** – no such exec instance
  2720  -   **409** - container is paused
  2721  
  2722      **Stream details**:
  2723      Similar to the stream behavior of `POST /containers/(id or name)/attach` API
  2724  
  2725  ### Exec Resize
  2726  
  2727  `POST /exec/(id)/resize`
  2728  
  2729  Resizes the `tty` session used by the `exec` command `id`.  The unit is number of characters.
  2730  This API is valid only if `tty` was specified as part of creating and starting the `exec` command.
  2731  
  2732  **Example request**:
  2733  
  2734      POST /exec/e90e34656806/resize?h=40&w=80 HTTP/1.1
  2735      Content-Type: text/plain
  2736  
  2737  **Example response**:
  2738  
  2739      HTTP/1.1 201 Created
  2740      Content-Type: text/plain
  2741  
  2742  Query Parameters:
  2743  
  2744  -   **h** – height of `tty` session
  2745  -   **w** – width
  2746  
  2747  Status Codes:
  2748  
  2749  -   **201** – no error
  2750  -   **404** – no such exec instance
  2751  
  2752  ### Exec Inspect
  2753  
  2754  `GET /exec/(id)/json`
  2755  
  2756  Return low-level information about the `exec` command `id`.
  2757  
  2758  **Example request**:
  2759  
  2760      GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  2761  
  2762  **Example response**:
  2763  
  2764      HTTP/1.1 200 OK
  2765      Content-Type: application/json
  2766  
  2767      {
  2768          "CanRemove": false,
  2769          "ContainerID": "b53ee82b53a40c7dca428523e34f741f3abc51d9f297a14ff874bf761b995126",
  2770          "DetachKeys": "",
  2771          "ExitCode": 2,
  2772          "ID": "f33bbfb39f5b142420f4759b2348913bd4a8d1a6d7fd56499cb41a1bb91d7b3b",
  2773          "OpenStderr": true,
  2774          "OpenStdin": true,
  2775          "OpenStdout": true,
  2776          "ProcessConfig": {
  2777              "arguments": [
  2778                  "-c",
  2779                  "exit 2"
  2780              ],
  2781              "entrypoint": "sh",
  2782              "privileged": false,
  2783              "tty": true,
  2784              "user": "1000"
  2785          },
  2786          "Running": false
  2787      }
  2788  
  2789  Status Codes:
  2790  
  2791  -   **200** – no error
  2792  -   **404** – no such exec instance
  2793  -   **500** - server error
  2794  
  2795  ## 2.4 Volumes
  2796  
  2797  ### List volumes
  2798  
  2799  `GET /volumes`
  2800  
  2801  **Example request**:
  2802  
  2803      GET /volumes HTTP/1.1
  2804  
  2805  **Example response**:
  2806  
  2807      HTTP/1.1 200 OK
  2808      Content-Type: application/json
  2809  
  2810      {
  2811        "Volumes": [
  2812          {
  2813            "Name": "tardis",
  2814            "Driver": "local",
  2815            "Mountpoint": "/var/lib/docker/volumes/tardis"
  2816          }
  2817        ],
  2818        "Warnings": []
  2819      }
  2820  
  2821  Query Parameters:
  2822  
  2823  - **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the volumes list. There is one available filter: `dangling=true`
  2824  
  2825  Status Codes:
  2826  
  2827  -   **200** - no error
  2828  -   **500** - server error
  2829  
  2830  ### Create a volume
  2831  
  2832  `POST /volumes/create`
  2833  
  2834  Create a volume
  2835  
  2836  **Example request**:
  2837  
  2838      POST /volumes/create HTTP/1.1
  2839      Content-Type: application/json
  2840  
  2841      {
  2842        "Name": "tardis"
  2843      }
  2844  
  2845  **Example response**:
  2846  
  2847      HTTP/1.1 201 Created
  2848      Content-Type: application/json
  2849  
  2850      {
  2851        "Name": "tardis",
  2852        "Driver": "local",
  2853        "Mountpoint": "/var/lib/docker/volumes/tardis"
  2854      }
  2855  
  2856  Status Codes:
  2857  
  2858  - **201** - no error
  2859  - **500**  - server error
  2860  
  2861  JSON Parameters:
  2862  
  2863  - **Name** - The new volume's name. If not specified, Docker generates a name.
  2864  - **Driver** - Name of the volume driver to use. Defaults to `local` for the name.
  2865  - **DriverOpts** - A mapping of driver options and values. These options are
  2866      passed directly to the driver and are driver specific.
  2867  
  2868  ### Inspect a volume
  2869  
  2870  `GET /volumes/(name)`
  2871  
  2872  Return low-level information on the volume `name`
  2873  
  2874  **Example request**:
  2875  
  2876      GET /volumes/tardis
  2877  
  2878  **Example response**:
  2879  
  2880      HTTP/1.1 200 OK
  2881      Content-Type: application/json
  2882  
  2883      {
  2884        "Name": "tardis",
  2885        "Driver": "local",
  2886        "Mountpoint": "/var/lib/docker/volumes/tardis"
  2887      }
  2888  
  2889  Status Codes:
  2890  
  2891  -   **200** - no error
  2892  -   **404** - no such volume
  2893  -   **500** - server error
  2894  
  2895  ### Remove a volume
  2896  
  2897  `DELETE /volumes/(name)`
  2898  
  2899  Instruct the driver to remove the volume (`name`).
  2900  
  2901  **Example request**:
  2902  
  2903      DELETE /volumes/tardis HTTP/1.1
  2904  
  2905  **Example response**:
  2906  
  2907      HTTP/1.1 204 No Content
  2908  
  2909  Status Codes
  2910  
  2911  -   **204** - no error
  2912  -   **404** - no such volume or volume driver
  2913  -   **409** - volume is in use and cannot be removed
  2914  -   **500** - server error
  2915  
  2916  ## 2.5 Networks
  2917  
  2918  ### List networks
  2919  
  2920  `GET /networks`
  2921  
  2922  **Example request**:
  2923  
  2924      GET /networks?filters={"type":{"custom":true}} HTTP/1.1
  2925  
  2926  **Example response**:
  2927  
  2928  ```
  2929  HTTP/1.1 200 OK
  2930  Content-Type: application/json
  2931  
  2932  [
  2933    {
  2934      "Name": "bridge",
  2935      "Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566",
  2936      "Scope": "local",
  2937      "Driver": "bridge",
  2938      "IPAM": {
  2939        "Driver": "default",
  2940        "Config": [
  2941          {
  2942            "Subnet": "172.17.0.0/16"
  2943          }
  2944        ]
  2945      },
  2946      "Containers": {
  2947        "39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": {
  2948          "EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda",
  2949          "MacAddress": "02:42:ac:11:00:02",
  2950          "IPv4Address": "172.17.0.2/16",
  2951          "IPv6Address": ""
  2952        }
  2953      },
  2954      "Options": {
  2955        "com.docker.network.bridge.default_bridge": "true",
  2956        "com.docker.network.bridge.enable_icc": "true",
  2957        "com.docker.network.bridge.enable_ip_masquerade": "true",
  2958        "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
  2959        "com.docker.network.bridge.name": "docker0",
  2960        "com.docker.network.driver.mtu": "1500"
  2961      }
  2962    },
  2963    {
  2964      "Name": "none",
  2965      "Id": "e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794",
  2966      "Scope": "local",
  2967      "Driver": "null",
  2968      "IPAM": {
  2969        "Driver": "default",
  2970        "Config": []
  2971      },
  2972      "Containers": {},
  2973      "Options": {}
  2974    },
  2975    {
  2976      "Name": "host",
  2977      "Id": "13e871235c677f196c4e1ecebb9dc733b9b2d2ab589e30c539efeda84a24215e",
  2978      "Scope": "local",
  2979      "Driver": "host",
  2980      "IPAM": {
  2981        "Driver": "default",
  2982        "Config": []
  2983      },
  2984      "Containers": {},
  2985      "Options": {}
  2986    }
  2987  ]
  2988  ```
  2989  
  2990  Query Parameters:
  2991  
  2992  - **filters** - JSON encoded network list filter. The filter value is one of:
  2993    -   `name=<network-name>` Matches all or part of a network name.
  2994    -   `id=<network-id>` Matches all or part of a network id.
  2995    -   `type=["custom"|"builtin"]` Filters networks by type. The `custom` keyword returns all user-defined networks.
  2996  
  2997  Status Codes:
  2998  
  2999  -   **200** - no error
  3000  -   **500** - server error
  3001  
  3002  ### Inspect network
  3003  
  3004  `GET /networks/<network-id>`
  3005  
  3006  **Example request**:
  3007  
  3008      GET /networks/7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99 HTTP/1.1
  3009  
  3010  **Example response**:
  3011  
  3012  ```
  3013  HTTP/1.1 200 OK
  3014  Content-Type: application/json
  3015  
  3016  {
  3017    "Name": "net01",
  3018    "Id": "7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99",
  3019    "Scope": "local",
  3020    "Driver": "bridge",
  3021    "IPAM": {
  3022      "Driver": "default",
  3023      "Config": [
  3024        {
  3025          "Subnet": "172.19.0.0/16",
  3026          "Gateway": "172.19.0.1/16"
  3027        }
  3028      ],
  3029      "Options": {
  3030          "foo": "bar"
  3031      }
  3032    },
  3033    "Containers": {
  3034      "19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c": {
  3035        "Name": "test",
  3036        "EndpointID": "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a",
  3037        "MacAddress": "02:42:ac:13:00:02",
  3038        "IPv4Address": "172.19.0.2/16",
  3039        "IPv6Address": ""
  3040      }
  3041    },
  3042    "Options": {
  3043      "com.docker.network.bridge.default_bridge": "true",
  3044      "com.docker.network.bridge.enable_icc": "true",
  3045      "com.docker.network.bridge.enable_ip_masquerade": "true",
  3046      "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
  3047      "com.docker.network.bridge.name": "docker0",
  3048      "com.docker.network.driver.mtu": "1500"
  3049    }
  3050  }
  3051  ```
  3052  
  3053  Status Codes:
  3054  
  3055  -   **200** - no error
  3056  -   **404** - network not found
  3057  
  3058  ### Create a network
  3059  
  3060  `POST /networks/create`
  3061  
  3062  Create a network
  3063  
  3064  **Example request**:
  3065  
  3066  ```
  3067  POST /networks/create HTTP/1.1
  3068  Content-Type: application/json
  3069  
  3070  {
  3071    "Name":"isolated_nw",
  3072    "Driver":"bridge",
  3073    "IPAM":{
  3074      "Config":[
  3075         {
  3076            "Subnet":"172.20.0.0/16",
  3077            "IPRange":"172.20.10.0/24",
  3078            "Gateway":"172.20.10.11"
  3079          },
  3080          {
  3081            "Subnet":"2001:db8:abcd::/64",
  3082            "Gateway":"2001:db8:abcd::1011"
  3083          }
  3084      ],
  3085      "Options": {
  3086          "foo": "bar"
  3087      }
  3088    },
  3089    "Internal":true
  3090  }
  3091  ```
  3092  
  3093  **Example response**:
  3094  
  3095  ```
  3096  HTTP/1.1 201 Created
  3097  Content-Type: application/json
  3098  
  3099  {
  3100    "Id": "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30",
  3101    "Warning": ""
  3102  }
  3103  ```
  3104  
  3105  Status Codes:
  3106  
  3107  - **201** - no error
  3108  - **404** - plugin not found
  3109  - **500** - server error
  3110  
  3111  JSON Parameters:
  3112  
  3113  - **Name** - The new network's name. this is a mandatory field
  3114  - **Driver** - Name of the network driver plugin to use. Defaults to `bridge` driver
  3115  - **IPAM** - Optional custom IP scheme for the network
  3116  - **Options** - Network specific options to be used by the drivers
  3117  - **CheckDuplicate** - Requests daemon to check for networks with same name
  3118  
  3119  ### Connect a container to a network
  3120  
  3121  `POST /networks/(id)/connect`
  3122  
  3123  Connect a container to a network
  3124  
  3125  **Example request**:
  3126  
  3127  ```
  3128  POST /networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/connect HTTP/1.1
  3129  Content-Type: application/json
  3130  
  3131  {
  3132    "Container":"3613f73ba0e4",
  3133    "EndpointConfig": {
  3134      "IPAMConfig": {
  3135          "IPv4Address":"172.24.56.89",
  3136          "IPv6Address":"2001:db8::5689"
  3137      }
  3138    }
  3139  }
  3140  ```
  3141  
  3142  **Example response**:
  3143  
  3144      HTTP/1.1 200 OK
  3145  
  3146  Status Codes:
  3147  
  3148  - **200** - no error
  3149  - **404** - network or container is not found
  3150  - **500** - Internal Server Error
  3151  
  3152  JSON Parameters:
  3153  
  3154  - **container** - container-id/name to be connected to the network
  3155  
  3156  ### Disconnect a container from a network
  3157  
  3158  `POST /networks/(id)/disconnect`
  3159  
  3160  Disconnect a container from a network
  3161  
  3162  **Example request**:
  3163  
  3164  ```
  3165  POST /networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/disconnect HTTP/1.1
  3166  Content-Type: application/json
  3167  
  3168  {
  3169    "Container":"3613f73ba0e4",
  3170    "Force":false
  3171  }
  3172  ```
  3173  
  3174  **Example response**:
  3175  
  3176      HTTP/1.1 200 OK
  3177  
  3178  Status Codes:
  3179  
  3180  - **200** - no error
  3181  - **404** - network or container not found
  3182  - **500** - Internal Server Error
  3183  
  3184  JSON Parameters:
  3185  
  3186  - **Container** - container-id/name to be disconnected from a network
  3187  - **Force** - Force the container to disconnect from a network
  3188  
  3189  ### Remove a network
  3190  
  3191  `DELETE /networks/(id)`
  3192  
  3193  Instruct the driver to remove the network (`id`).
  3194  
  3195  **Example request**:
  3196  
  3197      DELETE /networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30 HTTP/1.1
  3198  
  3199  **Example response**:
  3200  
  3201      HTTP/1.1 200 OK
  3202  
  3203  Status Codes
  3204  
  3205  -   **200** - no error
  3206  -   **404** - no such network
  3207  -   **500** - server error
  3208  
  3209  # 3. Going further
  3210  
  3211  ## 3.1 Inside `docker run`
  3212  
  3213  As an example, the `docker run` command line makes the following API calls:
  3214  
  3215  - Create the container
  3216  
  3217  - If the status code is 404, it means the image doesn't exist:
  3218      - Try to pull it.
  3219      - Then, retry to create the container.
  3220  
  3221  - Start the container.
  3222  
  3223  - If you are not in detached mode:
  3224  - Attach to the container, using `logs=1` (to have `stdout` and
  3225        `stderr` from the container's start) and `stream=1`
  3226  
  3227  - If in detached mode or only `stdin` is attached, display the container's id.
  3228  
  3229  ## 3.2 Hijacking
  3230  
  3231  In this version of the API, `/attach`, uses hijacking to transport `stdin`,
  3232  `stdout`, and `stderr` on the same socket.
  3233  
  3234  To hint potential proxies about connection hijacking, Docker client sends
  3235  connection upgrade headers similarly to websocket.
  3236  
  3237      Upgrade: tcp
  3238      Connection: Upgrade
  3239  
  3240  When Docker daemon detects the `Upgrade` header, it switches its status code
  3241  from **200 OK** to **101 UPGRADED** and resends the same headers.
  3242  
  3243  
  3244  ## 3.3 CORS Requests
  3245  
  3246  To set cross origin requests to the remote api please give values to
  3247  `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all,
  3248  default or blank means CORS disabled
  3249  
  3250      $ docker daemon -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"