2 title: "Engine API v1.21"
3 description: "API Documentation for Docker"
4 keywords: "API, Docker, rcli, REST, documentation"
6 - /engine/reference/api/docker_remote_api_v1.21/
7 - /reference/api/docker_remote_api_v1.21/
10 <!-- This file is maintained within the docker/docker Github
11 repository at https://github.com/docker/docker/. Make all
12 pull requests against that repo. If you see this file in
13 another repository, consider it read-only there, as it will
14 periodically be overwritten by the definitive file. Pull
15 requests which include edits to this file in other repositories
19 ## 1. Brief introduction
21 - The daemon listens on `unix:///var/run/docker.sock` but you can
22 [Bind Docker to another host/port or a Unix socket](../reference/commandline/dockerd.md#bind-docker-to-another-host-port-or-a-unix-socket).
23 - The API tends to be REST. However, for some complex commands, like `attach`
24 or `pull`, the HTTP connection is hijacked to transport `stdout`,
26 - When the client API version is newer than the daemon's, these calls return an HTTP
27 `400 Bad Request` error message.
35 `GET /containers/json`
41 GET /v1.21/containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
46 Content-Type: application/json
51 "Names":["/boring_feynman"],
52 "Image": "ubuntu:latest",
53 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
55 "Created": 1367854155,
57 "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
59 "com.example.vendor": "Acme",
60 "com.example.license": "GPL",
61 "com.example.version": "1.0"
68 "Names":["/coolName"],
69 "Image": "ubuntu:latest",
70 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
71 "Command": "echo 222222",
72 "Created": 1367854155,
81 "Names":["/sleepy_dog"],
82 "Image": "ubuntu:latest",
83 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
84 "Command": "echo 3333333333333333",
85 "Created": 1367854154,
94 "Names":["/running_cat"],
95 "Image": "ubuntu:latest",
96 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82",
97 "Command": "echo 444444444444444444444444444444444",
98 "Created": 1367854152,
107 **Query parameters**:
109 - **all** – 1/True/true or 0/False/false, Show all containers.
110 Only running containers are shown by default (i.e., this defaults to false)
111 - **limit** – Show `limit` last created
112 containers, include non-running ones.
113 - **since** – Show only containers created since Id, include
115 - **before** – Show only containers created before Id, include
117 - **size** – 1/True/true or 0/False/false, Show the containers
119 - **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters:
120 - `exited=<int>`; -- containers with exit code of `<int>` ;
121 - `status=`(`created`|`restarting`|`running`|`paused`|`exited`)
122 - `label=key` or `label="key=value"` of a container label
127 - **400** – bad parameter
128 - **500** – server error
130 #### Create a container
132 `POST /containers/create`
138 POST /v1.21/containers/create HTTP/1.1
139 Content-Type: application/json
145 "AttachStdin": false,
146 "AttachStdout": true,
147 "AttachStderr": true,
161 "com.example.vendor": "Acme",
162 "com.example.license": "GPL",
163 "com.example.version": "1.0"
169 "NetworkDisabled": false,
170 "MacAddress": "12:34:56:78:9a:bc",
174 "StopSignal": "SIGTERM",
176 "Binds": ["/tmp:/tmp"],
177 "Links": ["redis3:redis"],
178 "LxcConf": {"lxc.utsname":"docker"},
181 "MemoryReservation": 0,
189 "MemorySwappiness": 60,
190 "OomKillDisable": false,
192 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
193 "PublishAllPorts": false,
195 "ReadonlyRootfs": false,
200 "VolumesFrom": ["parent", "other:ro"],
201 "CapAdd": ["NET_ADMIN"],
202 "CapDrop": ["MKNOD"],
203 "GroupAdd": ["newgroup"],
204 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
205 "NetworkMode": "bridge",
208 "LogConfig": { "Type": "json-file", "Config": {} },
215 **Example response**:
218 Content-Type: application/json
227 - **Hostname** - A string value containing the hostname to use for the
229 - **Domainname** - A string value containing the domain name to use
231 - **User** - A string value specifying the user inside the container.
232 - **AttachStdin** - Boolean value, attaches to `stdin`.
233 - **AttachStdout** - Boolean value, attaches to `stdout`.
234 - **AttachStderr** - Boolean value, attaches to `stderr`.
235 - **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed.
236 - **OpenStdin** - Boolean value, opens `stdin`,
237 - **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects.
238 - **Env** - A list of environment variables in the form of `["VAR=value", ...]`
239 - **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value", ... }`
240 - **Cmd** - Command to run specified as a string or an array of strings.
241 - **Entrypoint** - Set the entry point for the container as a string or an array
243 - **Image** - A string specifying the image name to use for the container.
244 - **Volumes** - An object mapping mount point paths (strings) inside the
245 container to empty objects.
246 - **WorkingDir** - A string specifying the working directory for commands to
248 - **NetworkDisabled** - Boolean value, when true disables networking for the
250 - **ExposedPorts** - An object mapping ports to an empty object in the form of:
251 `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
252 - **StopSignal** - Signal to stop a container as a string or unsigned integer. `SIGTERM` by default.
254 - **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
255 + `host-src:container-dest` to bind-mount a host path into the
256 container. Both `host-src`, and `container-dest` must be an
258 + `host-src:container-dest:ro` to make the bind-mount read-only
259 inside the container. Both `host-src`, and `container-dest` must be
261 + `volume-name:container-dest` to bind-mount a volume managed by a
262 volume driver into the container. `container-dest` must be an
264 + `volume-name:container-dest:ro` to mount the volume read-only
265 inside the container. `container-dest` must be an _absolute_ path.
266 - **Links** - A list of links for the container. Each link entry should be
267 in the form of `container_name:alias`.
268 - **LxcConf** - LXC specific configurations. These configurations only
269 work when using the `lxc` execution driver.
270 - **Memory** - Memory limit in bytes.
271 - **MemorySwap** - Total memory limit (memory + swap); set `-1` to enable unlimited swap.
272 You must use this with `memory` and make the swap value larger than `memory`.
273 - **MemoryReservation** - Memory soft limit in bytes.
274 - **KernelMemory** - Kernel memory limit in bytes.
275 - **CpuShares** - An integer value containing the container's CPU Shares
276 (ie. the relative weight vs other containers).
277 - **CpuPeriod** - The length of a CPU period in microseconds.
278 - **CpuQuota** - Microseconds of CPU time that the container can get in a CPU period.
279 - **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use.
280 - **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
281 - **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000.
282 - **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
283 - **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
284 - **PidMode** - Set the PID (Process) Namespace mode for the container;
285 `"container:<name|id>"`: joins another container's PID namespace
286 `"host"`: use the host's PID namespace inside the container
287 - **PortBindings** - A map of exposed container ports and the host port they
288 should map to. A JSON object in the form
289 `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
290 Take note that `port` is specified as a string and not an integer value.
291 - **PublishAllPorts** - Allocates a random host port for all of a container's
292 exposed ports. Specified as a boolean value.
293 - **Privileged** - Gives the container full access to the host. Specified as
295 - **ReadonlyRootfs** - Mount the container's root filesystem as read only.
296 Specified as a boolean value.
297 - **Dns** - A list of DNS servers for the container to use.
298 - **DnsOptions** - A list of DNS options
299 - **DnsSearch** - A list of DNS search domains
300 - **ExtraHosts** - A list of hostnames/IP mappings to add to the
301 container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
302 - **VolumesFrom** - A list of volumes to inherit from another container.
303 Specified in the form `<container name>[:<ro|rw>]`
304 - **CapAdd** - A list of kernel capabilities to add to the container.
305 - **Capdrop** - A list of kernel capabilities to drop from the container.
306 - **GroupAdd** - A list of additional groups that the container process will run as
307 - **RestartPolicy** – The behavior to apply when the container exits. The
308 value is an object with a `Name` property of either `"always"` to
309 always restart, `"unless-stopped"` to restart always except when
310 user has manually stopped the container or `"on-failure"` to restart only when the container
311 exit code is non-zero. If `on-failure` is used, `MaximumRetryCount`
312 controls the number of times to retry before giving up.
313 The default is not to restart. (optional)
314 An ever increasing delay (double the previous delay, starting at 100mS)
315 is added before each restart to prevent flooding the server.
316 - **NetworkMode** - Sets the networking mode for the container. Supported
317 standard values are: `bridge`, `host`, `none`, and `container:<name|id>`. Any other value is taken
318 as a custom network's name to which this container should connect to.
319 - **Devices** - A list of devices to add to the container specified as a JSON object in the
321 `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
322 - **Ulimits** - A list of ulimits to set in the container, specified as
323 `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
324 `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }`
325 - **SecurityOpt**: A list of string values to customize labels for MLS
326 systems, such as SELinux.
327 - **LogConfig** - Log configuration for the container, specified as a JSON object in the form
328 `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
329 Available types: `json-file`, `syslog`, `journald`, `gelf`, `awslogs`, `none`.
330 `json-file` logging driver.
331 - **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.
332 - **VolumeDriver** - Driver that this container users to mount volumes.
334 **Query parameters**:
336 - **name** – Assign the specified name to the container. Must
337 match `/?[a-zA-Z0-9_-]+`.
342 - **400** – bad parameter
343 - **404** – no such container
344 - **406** – impossible to attach (container not running)
346 - **500** – server error
348 #### Inspect a container
350 `GET /containers/(id or name)/json`
352 Return low-level information on the container `id`
356 GET /v1.21/containers/4fa6e0f0c678/json HTTP/1.1
358 **Example response**:
361 Content-Type: application/json
364 "AppArmorProfile": "",
370 "AttachStderr": true,
371 "AttachStdin": false,
372 "AttachStdout": true,
381 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
383 "ExposedPorts": null,
384 "Hostname": "ba033ac44011",
387 "com.example.vendor": "Acme",
388 "com.example.license": "GPL",
389 "com.example.version": "1.0"
392 "NetworkDisabled": false,
400 "StopSignal": "SIGTERM"
402 "Created": "2015-01-06T15:47:31.485331387Z",
403 "Driver": "devicemapper",
404 "ExecDriver": "native-0.2",
411 "ContainerIDFile": "",
426 "MemoryReservation": 0,
428 "OomKillDisable": false,
429 "NetworkMode": "bridge",
433 "ReadonlyRootfs": false,
434 "PublishAllPorts": false,
436 "MaximumRetryCount": 2,
448 "HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
449 "HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
450 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
451 "Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
452 "Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
454 "Name": "/boring_euclid",
458 "HairpinMode": false,
459 "LinkLocalIPv6Address": "",
460 "LinkLocalIPv6PrefixLen": 0,
463 "SecondaryIPAddresses": null,
464 "SecondaryIPv6Addresses": null,
467 "GlobalIPv6Address": "",
468 "GlobalIPv6PrefixLen": 0,
475 "EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d",
476 "Gateway": "172.17.0.1",
477 "IPAddress": "172.17.0.2",
480 "GlobalIPv6Address": "",
481 "GlobalIPv6PrefixLen": 0,
482 "MacAddress": "02:42:ac:12:00:02"
488 "ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
493 "FinishedAt": "2015-01-06T15:47:32.080254511Z",
499 "StartedAt": "2015-01-06T15:47:32.072697474Z",
505 "Destination": "/data",
512 **Example request, with size information**:
514 GET /v1.21/containers/4fa6e0f0c678/json?size=1 HTTP/1.1
516 **Example response, with size information**:
519 Content-Type: application/json
528 **Query parameters**:
530 - **size** – 1/True/true or 0/False/false, return container size information. Default is `false`.
535 - **404** – no such container
536 - **500** – server error
538 #### List processes running inside a container
540 `GET /containers/(id or name)/top`
542 List processes running inside the container `id`. On Unix systems this
543 is done by running the `ps` command. This endpoint is not
544 supported on Windows.
548 GET /v1.21/containers/4fa6e0f0c678/top HTTP/1.1
550 **Example response**:
553 Content-Type: application/json
557 "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD"
561 "root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash"
564 "root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10"
571 GET /v1.21/containers/4fa6e0f0c678/top?ps_args=aux HTTP/1.1
573 **Example response**:
576 Content-Type: application/json
580 "USER","PID","%CPU","%MEM","VSZ","RSS","TTY","STAT","START","TIME","COMMAND"
584 "root","13642","0.0","0.1","18172","3184","pts/0","Ss","17:03","0:00","/bin/bash"
587 "root","13895","0.0","0.0","4348","692","pts/0","S+","17:15","0:00","sleep 10"
592 **Query parameters**:
594 - **ps_args** – `ps` arguments to use (e.g., `aux`), defaults to `-ef`
599 - **404** – no such container
600 - **500** – server error
602 #### Get container logs
604 `GET /containers/(id or name)/logs`
606 Get `stdout` and `stderr` logs from the container ``id``
609 > This endpoint works only for containers with the `json-file` or `journald` logging drivers.
613 GET /v1.21/containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1
615 **Example response**:
617 HTTP/1.1 101 UPGRADED
618 Content-Type: application/vnd.docker.raw-stream
626 **Query parameters**:
628 - **follow** – 1/True/true or 0/False/false, return stream. Default `false`.
629 - **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`.
630 - **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`.
631 - **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp
632 will only output log-entries since that timestamp. Default: 0 (unfiltered)
633 - **timestamps** – 1/True/true or 0/False/false, print timestamps for
634 every log line. Default `false`.
635 - **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all.
639 - **101** – no error, hints proxy about hijacking
640 - **200** – no error, no upgrade header found
641 - **404** – no such container
642 - **500** – server error
644 #### Inspect changes on a container's filesystem
646 `GET /containers/(id or name)/changes`
648 Inspect changes on container `id`'s filesystem
652 GET /v1.21/containers/4fa6e0f0c678/changes HTTP/1.1
654 **Example response**:
657 Content-Type: application/json
683 - **404** – no such container
684 - **500** – server error
686 #### Export a container
688 `GET /containers/(id or name)/export`
690 Export the contents of container `id`
694 GET /v1.21/containers/4fa6e0f0c678/export HTTP/1.1
696 **Example response**:
699 Content-Type: application/octet-stream
708 - **404** – no such container
709 - **500** – server error
711 #### Get container stats based on resource usage
713 `GET /containers/(id or name)/stats`
715 This endpoint returns a live stream of a container's resource usage statistics.
719 GET /v1.21/containers/redis1/stats HTTP/1.1
721 **Example response**:
724 Content-Type: application/json
727 "read" : "2015-01-08T22:57:31.547920715Z",
752 "total_pgmajfault" : 0,
755 "total_inactive_file" : 0,
758 "total_mapped_file" : 0,
762 "total_unevictable" : 0,
764 "total_rss" : 6537216,
765 "total_rss_huge" : 6291456,
766 "total_writeback" : 0,
767 "total_inactive_anon" : 0,
768 "rss_huge" : 6291456,
769 "hierarchical_memory_limit" : 67108864,
770 "total_pgfault" : 964,
771 "total_active_file" : 0,
772 "active_anon" : 6537216,
773 "total_active_anon" : 6537216,
774 "total_pgpgout" : 414,
782 "max_usage" : 6651904,
796 "usage_in_usermode" : 50000000,
797 "total_usage" : 100215355,
798 "usage_in_kernelmode" : 30000000
800 "system_cpu_usage" : 739306590000000,
801 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0}
811 "usage_in_usermode" : 50000000,
812 "total_usage" : 100093996,
813 "usage_in_kernelmode" : 30000000
815 "system_cpu_usage" : 9492140000000,
816 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0}
820 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.
822 **Query parameters**:
824 - **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`.
829 - **404** – no such container
830 - **500** – server error
832 #### Resize a container TTY
834 `POST /containers/(id or name)/resize`
836 Resize the TTY for container with `id`. The unit is number of characters. You must restart the container for the resize to take effect.
840 POST /v1.21/containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
842 **Example response**:
846 Content-Type: text/plain; charset=utf-8
848 **Query parameters**:
850 - **h** – height of `tty` session
856 - **404** – No such container
857 - **500** – Cannot resize container
859 #### Start a container
861 `POST /containers/(id or name)/start`
863 Start the container `id`
866 > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
867 > See [create a container](#create-a-container) for details.
871 POST /v1.21/containers/e90e34656806/start HTTP/1.1
873 **Example response**:
875 HTTP/1.1 204 No Content
880 - **304** – container already started
881 - **404** – no such container
882 - **500** – server error
884 #### Stop a container
886 `POST /containers/(id or name)/stop`
888 Stop the container `id`
892 POST /v1.21/containers/e90e34656806/stop?t=5 HTTP/1.1
894 **Example response**:
896 HTTP/1.1 204 No Content
898 **Query parameters**:
900 - **t** – number of seconds to wait before killing the container
905 - **304** – container already stopped
906 - **404** – no such container
907 - **500** – server error
909 #### Restart a container
911 `POST /containers/(id or name)/restart`
913 Restart the container `id`
917 POST /v1.21/containers/e90e34656806/restart?t=5 HTTP/1.1
919 **Example response**:
921 HTTP/1.1 204 No Content
923 **Query parameters**:
925 - **t** – number of seconds to wait before killing the container
930 - **404** – no such container
931 - **500** – server error
933 #### Kill a container
935 `POST /containers/(id or name)/kill`
937 Kill the container `id`
941 POST /v1.21/containers/e90e34656806/kill HTTP/1.1
943 **Example response**:
945 HTTP/1.1 204 No Content
947 **Query parameters**:
949 - **signal** - Signal to send to the container: integer or string like `SIGINT`.
950 When not set, `SIGKILL` is assumed and the call waits for the container to exit.
955 - **404** – no such container
956 - **500** – server error
958 #### Rename a container
960 `POST /containers/(id or name)/rename`
962 Rename the container `id` to a `new_name`
966 POST /v1.21/containers/e90e34656806/rename?name=new_name HTTP/1.1
968 **Example response**:
970 HTTP/1.1 204 No Content
972 **Query parameters**:
974 - **name** – new name for the container
979 - **404** – no such container
980 - **409** - conflict name already assigned
981 - **500** – server error
983 #### Pause a container
985 `POST /containers/(id or name)/pause`
987 Pause the container `id`
991 POST /v1.21/containers/e90e34656806/pause HTTP/1.1
993 **Example response**:
995 HTTP/1.1 204 No Content
1000 - **404** – no such container
1001 - **500** – server error
1003 #### Unpause a container
1005 `POST /containers/(id or name)/unpause`
1007 Unpause the container `id`
1009 **Example request**:
1011 POST /v1.21/containers/e90e34656806/unpause HTTP/1.1
1013 **Example response**:
1015 HTTP/1.1 204 No Content
1019 - **204** – no error
1020 - **404** – no such container
1021 - **500** – server error
1023 #### Attach to a container
1025 `POST /containers/(id or name)/attach`
1027 Attach to the container `id`
1029 **Example request**:
1031 POST /v1.21/containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
1033 **Example response**:
1035 HTTP/1.1 101 UPGRADED
1036 Content-Type: application/vnd.docker.raw-stream
1044 **Query parameters**:
1046 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
1047 - **stream** – 1/True/true or 0/False/false, return stream.
1049 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
1050 to `stdin`. Default `false`.
1051 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
1052 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
1053 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
1054 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
1058 - **101** – no error, hints proxy about hijacking
1059 - **200** – no error, no upgrade header found
1060 - **400** – bad parameter
1061 - **404** – no such container
1062 - **500** – server error
1066 When using the TTY setting is enabled in
1067 [`POST /containers/create`
1068 ](#create-a-container),
1069 the stream is the raw data from the process PTY and client's `stdin`.
1070 When the TTY is disabled, then the stream is multiplexed to separate
1071 `stdout` and `stderr`.
1073 The format is a **Header** and a **Payload** (frame).
1077 The header contains the information which the stream writes (`stdout` or
1078 `stderr`). It also contains the size of the associated frame encoded in the
1079 last four bytes (`uint32`).
1081 It is encoded on the first eight bytes like this:
1083 header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
1085 `STREAM_TYPE` can be:
1087 - 0: `stdin` (is written on `stdout`)
1091 `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of
1092 the `uint32` size encoded as big endian.
1096 The payload is the raw stream.
1100 The simplest way to implement the Attach protocol is the following:
1102 1. Read eight bytes.
1103 2. Choose `stdout` or `stderr` depending on the first byte.
1104 3. Extract the frame size from the last four bytes.
1105 4. Read the extracted size and output it on the correct output.
1108 #### Attach to a container (websocket)
1110 `GET /containers/(id or name)/attach/ws`
1112 Attach to the container `id` via websocket
1114 Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
1118 GET /v1.21/containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
1120 **Example response**
1126 **Query parameters**:
1128 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
1129 - **stream** – 1/True/true or 0/False/false, return stream.
1131 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
1132 to `stdin`. Default `false`.
1133 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
1134 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
1135 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
1136 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
1140 - **200** – no error
1141 - **400** – bad parameter
1142 - **404** – no such container
1143 - **500** – server error
1145 #### Wait a container
1147 `POST /containers/(id or name)/wait`
1149 Block until container `id` stops, then returns the exit code
1151 **Example request**:
1153 POST /v1.21/containers/16253994b7c4/wait HTTP/1.1
1155 **Example response**:
1158 Content-Type: application/json
1164 - **200** – no error
1165 - **404** – no such container
1166 - **500** – server error
1168 #### Remove a container
1170 `DELETE /containers/(id or name)`
1172 Remove the container `id` from the filesystem
1174 **Example request**:
1176 DELETE /v1.21/containers/16253994b7c4?v=1 HTTP/1.1
1178 **Example response**:
1180 HTTP/1.1 204 No Content
1182 **Query parameters**:
1184 - **v** – 1/True/true or 0/False/false, Remove the volumes
1185 associated to the container. Default `false`.
1186 - **force** - 1/True/true or 0/False/false, Kill then remove the container.
1188 - **link** - 1/True/true or 0/False/false, Remove the specified
1189 link associated to the container. Default `false`.
1193 - **204** – no error
1194 - **400** – bad parameter
1195 - **404** – no such container
1196 - **409** – conflict
1197 - **500** – server error
1199 #### Copy files or folders from a container
1201 `POST /containers/(id or name)/copy`
1203 Copy files or folders of container `id`
1205 **Deprecated** in favor of the `archive` endpoint below.
1207 **Example request**:
1209 POST /v1.21/containers/4fa6e0f0c678/copy HTTP/1.1
1210 Content-Type: application/json
1213 "Resource": "test.txt"
1216 **Example response**:
1219 Content-Type: application/x-tar
1227 - **200** – no error
1228 - **404** – no such container
1229 - **500** – server error
1231 #### Retrieving information about files and folders in a container
1233 `HEAD /containers/(id or name)/archive`
1235 See the description of the `X-Docker-Container-Path-Stat` header in the
1238 #### Get an archive of a filesystem resource in a container
1240 `GET /containers/(id or name)/archive`
1242 Get a tar archive of a resource in the filesystem of container `id`.
1244 **Query parameters**:
1246 - **path** - resource in the container's filesystem to archive. Required.
1248 If not an absolute path, it is relative to the container's root directory.
1249 The resource specified by **path** must exist. To assert that the resource
1250 is expected to be a directory, **path** should end in `/` or `/.`
1251 (assuming a path separator of `/`). If **path** ends in `/.` then this
1252 indicates that only the contents of the **path** directory should be
1253 copied. A symlink is always resolved to its target.
1255 > **Note**: It is not possible to copy certain system files such as resources
1256 > under `/proc`, `/sys`, `/dev`, and mounts created by the user in the
1259 **Example request**:
1261 GET /v1.21/containers/8cce319429b2/archive?path=/root HTTP/1.1
1263 **Example response**:
1266 Content-Type: application/x-tar
1267 X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
1273 On success, a response header `X-Docker-Container-Path-Stat` will be set to a
1274 base64-encoded JSON object containing some filesystem header information about
1275 the archived resource. The above example value would decode to the following
1276 JSON object (whitespace added for readability):
1283 "mtime": "2014-02-27T20:51:23Z",
1288 A `HEAD` request can also be made to this endpoint if only this information is
1293 - **200** - success, returns archive of copied resource
1294 - **400** - client error, bad parameter, details in JSON response body, one of:
1295 - must specify path parameter (**path** cannot be empty)
1296 - not a directory (**path** was asserted to be a directory but exists as a
1298 - **404** - client error, resource not found, one of:
1299 – no such container (container `id` does not exist)
1300 - no such file or directory (**path** does not exist)
1301 - **500** - server error
1303 #### Extract an archive of files or folders to a directory in a container
1305 `PUT /containers/(id or name)/archive`
1307 Upload a tar archive to be extracted to a path in the filesystem of container
1310 **Query parameters**:
1312 - **path** - path to a directory in the container
1313 to extract the archive's contents into. Required.
1315 If not an absolute path, it is relative to the container's root directory.
1316 The **path** resource must exist.
1317 - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error
1318 if unpacking the given content would cause an existing directory to be
1319 replaced with a non-directory and vice versa.
1321 **Example request**:
1323 PUT /v1.21/containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
1324 Content-Type: application/x-tar
1330 **Example response**:
1336 - **200** – the content was extracted successfully
1337 - **400** - client error, bad parameter, details in JSON response body, one of:
1338 - must specify path parameter (**path** cannot be empty)
1339 - not a directory (**path** should be a directory but exists as a file)
1340 - unable to overwrite existing directory with non-directory
1341 (if **noOverwriteDirNonDir**)
1342 - unable to overwrite existing non-directory with directory
1343 (if **noOverwriteDirNonDir**)
1344 - **403** - client error, permission denied, the volume
1345 or container rootfs is marked as read-only.
1346 - **404** - client error, resource not found, one of:
1347 – no such container (container `id` does not exist)
1348 - no such file or directory (**path** resource does not exist)
1349 - **500** – server error
1357 **Example request**:
1359 GET /v1.21/images/json?all=0 HTTP/1.1
1361 **Example response**:
1364 Content-Type: application/json
1373 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
1374 "Created": 1365714795,
1376 "VirtualSize": 131506275,
1384 "ParentId": "27cf784147099545",
1385 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
1386 "Created": 1364102658,
1388 "VirtualSize": 180116135,
1390 "com.example.version": "v1"
1395 **Example request, with digest information**:
1397 GET /v1.21/images/json?digests=1 HTTP/1.1
1399 **Example response, with digest information**:
1402 Content-Type: application/json
1406 "Created": 1420064636,
1407 "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
1408 "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
1410 "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
1413 "localhost:5000/test/busybox:latest",
1417 "VirtualSize": 2429728,
1422 The response shows a single image `Id` associated with two repositories
1423 (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use
1424 either of the `RepoTags` values `localhost:5000/test/busybox:latest` or
1425 `playdate:latest` to reference the image.
1427 You can also use `RepoDigests` values to reference an image. In this response,
1428 the array has only one reference and that is to the
1429 `localhost:5000/test/busybox` repository; the `playdate` repository has no
1430 digest. You can reference this digest using the value:
1431 `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
1433 See the `docker run` and `docker build` commands for examples of digest and tag
1434 references on the command line.
1436 **Query parameters**:
1438 - **all** – 1/True/true or 0/False/false, default false
1439 - **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
1441 - `label=key` or `label="key=value"` of an image label
1442 - **filter** - only return images with the specified name
1444 #### Build image from a Dockerfile
1448 Build an image from a Dockerfile
1450 **Example request**:
1452 POST /v1.21/build HTTP/1.1
1453 Content-Type: application/x-tar
1459 **Example response**:
1462 Content-Type: application/json
1464 {"stream": "Step 1/5..."}
1466 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
1468 The input stream must be a `tar` archive compressed with one of the
1469 following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`.
1471 The archive must include a build instructions file, typically called
1472 `Dockerfile` at the archive's root. The `dockerfile` parameter may be
1473 used to specify a different build instructions file. To do this, its value must be
1474 the path to the alternate build instructions file to use.
1476 The archive may include any number of other files,
1477 which are accessible in the build context (See the [*ADD build
1478 command*](../reference/builder.md#add)).
1480 The Docker daemon performs a preliminary validation of the `Dockerfile` before
1481 starting the build, and returns an error if the syntax is incorrect. After that,
1482 each instruction is run one-by-one until the ID of the new image is output.
1484 The build is canceled if the client drops the connection by quitting
1487 **Query parameters**:
1489 - **dockerfile** - Path within the build context to the `Dockerfile`. This is
1490 ignored if `remote` is specified and points to an external `Dockerfile`.
1491 - **t** – A name and optional tag to apply to the image in the `name:tag` format.
1492 If you omit the `tag` the default `latest` value is assumed.
1493 You can provide one or more `t` parameters.
1494 - **remote** – A Git repository URI or HTTP/HTTPS context URI. If the
1495 URI points to a single text file, the file's contents are placed into
1496 a file called `Dockerfile` and the image is built from that file. If
1497 the URI points to a tarball, the file is downloaded by the daemon and
1498 the contents therein used as the context for the build. If the URI
1499 points to a tarball and the `dockerfile` parameter is also specified,
1500 there must be a file with the corresponding path inside the tarball.
1501 - **q** – Suppress verbose build output.
1502 - **nocache** – Do not use the cache when building the image.
1503 - **pull** - Attempt to pull the image even if an older image exists locally.
1504 - **rm** - Remove intermediate containers after a successful build (default behavior).
1505 - **forcerm** - Always remove intermediate containers (includes `rm`).
1506 - **memory** - Set memory limit for build.
1507 - **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap.
1508 - **cpushares** - CPU shares (relative weight).
1509 - **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`).
1510 - **cpuperiod** - The length of a CPU period in microseconds.
1511 - **cpuquota** - Microseconds of CPU time that the container can get in a CPU period.
1512 - **buildargs** – JSON map of string pairs for build-time variables. Users pass
1513 these values at build-time. Docker uses the `buildargs` as the environment
1514 context for command(s) run via the Dockerfile's `RUN` instruction or for
1515 variable expansion in other Dockerfile instructions. This is not meant for
1516 passing secret values. [Read more about the buildargs instruction](../reference/builder.md#arg)
1518 **Request Headers**:
1520 - **Content-type** – Set to `"application/x-tar"`.
1521 - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
1522 object with the following structure:
1525 "docker.example.com": {
1526 "username": "janedoe",
1527 "password": "hunter2"
1529 "https://index.docker.io/v1/": {
1530 "username": "mobydock",
1531 "password": "conta1n3rize14"
1535 This object maps the hostname of a registry to an object containing the
1536 "username" and "password" for that registry. Multiple registries may
1537 be specified as the build may be based on an image requiring
1538 authentication to pull from any arbitrary registry. Only the registry
1539 domain name (and port if not the default "443") are required. However
1540 (for legacy reasons) the "official" Docker, Inc. hosted registry must
1541 be specified with both a "https://" prefix and a "/v1/" suffix even
1542 though Docker will prefer to use the v2 registry API.
1546 - **200** – no error
1547 - **500** – server error
1549 #### Create an image
1551 `POST /images/create`
1553 Create an image either by pulling it from the registry or by importing it
1555 **Example request**:
1557 POST /v1.21/images/create?fromImage=busybox&tag=latest HTTP/1.1
1559 **Example response**:
1562 Content-Type: application/json
1564 {"status": "Pulling..."}
1565 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
1566 {"error": "Invalid..."}
1569 When using this endpoint to pull an image from the registry, the
1570 `X-Registry-Auth` header can be used to include
1571 a base64-encoded AuthConfig object.
1573 **Query parameters**:
1575 - **fromImage** – Name of the image to pull. The name may include a tag or
1576 digest. This parameter may only be used when pulling an image.
1577 - **fromSrc** – Source to import. The value may be a URL from which the image
1578 can be retrieved or `-` to read the image from the request body.
1579 This parameter may only be used when importing an image.
1580 - **repo** – Repository name given to an image when it is imported.
1581 The repo may include a tag. This parameter may only be used when importing
1583 - **tag** – Tag or digest. If empty when pulling an image, this causes all tags
1584 for the given image to be pulled.
1586 **Request Headers**:
1588 - **X-Registry-Auth** – base64-encoded AuthConfig object
1592 - **200** – no error
1593 - **404** - repository does not exist or no read access
1594 - **500** – server error
1598 #### Inspect an image
1600 `GET /images/(name)/json`
1602 Return low-level information on the image `name`
1604 **Example request**:
1606 GET /v1.21/images/example/json HTTP/1.1
1608 **Example response**:
1611 Content-Type: application/json
1614 "Id" : "85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c",
1615 "Container" : "cb91e48a60d01f1e27028b4fc6819f4f290b3cf12496c8176ec714d0d390984a",
1618 "Architecture" : "amd64",
1619 "Parent" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
1620 "ContainerConfig" : {
1622 "Hostname" : "e611e15f9c9d",
1625 "AttachStdout" : false,
1626 "PublishService" : "",
1627 "AttachStdin" : false,
1628 "OpenStdin" : false,
1629 "StdinOnce" : false,
1630 "NetworkDisabled" : false,
1632 "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
1635 "Entrypoint" : null,
1637 "AttachStderr" : false,
1639 "com.example.license" : "GPL",
1640 "com.example.version" : "1.0",
1641 "com.example.vendor" : "Acme"
1644 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
1646 "ExposedPorts" : null,
1650 "#(nop) LABEL com.example.vendor=Acme com.example.license=GPL com.example.version=1.0"
1653 "DockerVersion" : "1.9.0-dev",
1654 "VirtualSize" : 188359297,
1657 "Created" : "2015-09-10T08:30:53.26995814Z",
1663 "localhost:5000/test/busybox/example@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
1671 "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
1672 "NetworkDisabled" : false,
1674 "StdinOnce" : false,
1675 "PublishService" : "",
1676 "AttachStdin" : false,
1677 "OpenStdin" : false,
1679 "AttachStdout" : false,
1681 "Hostname" : "e611e15f9c9d",
1686 "ExposedPorts" : null,
1688 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
1691 "com.example.vendor" : "Acme",
1692 "com.example.version" : "1.0",
1693 "com.example.license" : "GPL"
1695 "Entrypoint" : null,
1697 "AttachStderr" : false,
1705 - **200** – no error
1706 - **404** – no such image
1707 - **500** – server error
1709 #### Get the history of an image
1711 `GET /images/(name)/history`
1713 Return the history of the image `name`
1715 **Example request**:
1717 GET /v1.21/images/ubuntu/history HTTP/1.1
1719 **Example response**:
1722 Content-Type: application/json
1726 "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710",
1727 "Created": 1398108230,
1728 "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /",
1737 "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8",
1738 "Created": 1398108222,
1739 "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/",
1745 "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158",
1746 "Created": 1371157430,
1753 "Comment": "Imported from -"
1759 - **200** – no error
1760 - **404** – no such image
1761 - **500** – server error
1763 #### Push an image on the registry
1765 `POST /images/(name)/push`
1767 Push the image `name` on the registry
1769 **Example request**:
1771 POST /v1.21/images/test/push HTTP/1.1
1773 **Example response**:
1776 Content-Type: application/json
1778 {"status": "Pushing..."}
1779 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
1780 {"error": "Invalid..."}
1783 If you wish to push an image on to a private registry, that image must already have a tag
1784 into a repository which references that registry `hostname` and `port`. This repository name should
1785 then be used in the URL. This duplicates the command line's flow.
1787 **Example request**:
1789 POST /v1.21/images/registry.acme.com:5000/test/push HTTP/1.1
1792 **Query parameters**:
1794 - **tag** – The tag to associate with the image on the registry. This is optional.
1796 **Request Headers**:
1798 - **X-Registry-Auth** – base64-encoded AuthConfig object.
1802 - **200** – no error
1803 - **404** – no such image
1804 - **500** – server error
1806 #### Tag an image into a repository
1808 `POST /images/(name)/tag`
1810 Tag the image `name` into a repository
1812 **Example request**:
1814 POST /v1.21/images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
1816 **Example response**:
1818 HTTP/1.1 201 Created
1820 **Query parameters**:
1822 - **repo** – The repository to tag in
1823 - **force** – 1/True/true or 0/False/false, default false
1824 - **tag** - The new tag name
1828 - **201** – no error
1829 - **400** – bad parameter
1830 - **404** – no such image
1831 - **409** – conflict
1832 - **500** – server error
1834 #### Remove an image
1836 `DELETE /images/(name)`
1838 Remove the image `name` from the filesystem
1840 **Example request**:
1842 DELETE /v1.21/images/test HTTP/1.1
1844 **Example response**:
1847 Content-type: application/json
1850 {"Untagged": "3e2f21a89f"},
1851 {"Deleted": "3e2f21a89f"},
1852 {"Deleted": "53b4f83ac9"}
1855 **Query parameters**:
1857 - **force** – 1/True/true or 0/False/false, default false
1858 - **noprune** – 1/True/true or 0/False/false, default false
1862 - **200** – no error
1863 - **404** – no such image
1864 - **409** – conflict
1865 - **500** – server error
1869 `GET /images/search`
1871 Search for an image on [Docker Hub](https://hub.docker.com).
1874 > The response keys have changed from API v1.6 to reflect the JSON
1875 > sent by the registry server to the docker daemon's request.
1877 **Example request**:
1879 GET /v1.21/images/search?term=sshd HTTP/1.1
1881 **Example response**:
1884 Content-Type: application/json
1889 "is_official": false,
1890 "is_automated": false,
1891 "name": "wma55/u1210sshd",
1896 "is_official": false,
1897 "is_automated": false,
1898 "name": "jdswinbank/sshd",
1903 "is_official": false,
1904 "is_automated": false,
1905 "name": "vgauthier/sshd",
1911 **Query parameters**:
1913 - **term** – term to search
1917 - **200** – no error
1918 - **500** – server error
1922 #### Check auth configuration
1926 Get the default username and email
1928 **Example request**:
1930 POST /v1.21/auth HTTP/1.1
1931 Content-Type: application/json
1934 "username": "hannibal",
1936 "email": "hannibal@a-team.com",
1937 "serveraddress": "https://index.docker.io/v1/"
1940 **Example response**:
1946 - **200** – no error
1947 - **204** – no error
1948 - **500** – server error
1950 #### Display system-wide information
1954 Display system-wide information
1956 **Example request**:
1958 GET /v1.21/info HTTP/1.1
1960 **Example response**:
1963 Content-Type: application/json
1966 "ClusterStore": "etcd://localhost:2379",
1968 "CpuCfsPeriod": true,
1969 "CpuCfsQuota": true,
1971 "DockerRootDir": "/var/lib/docker",
1973 "DriverStatus": [[""]],
1974 "ExecutionDriver": "native-0.1",
1975 "ExperimentalBuild": false,
1976 "HttpProxy": "http://test:test@localhost:8080",
1977 "HttpsProxy": "https://test:test@localhost:8080",
1978 "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
1979 "IPv4Forwarding": true,
1981 "IndexServerAddress": "https://index.docker.io/v1/",
1982 "InitPath": "/usr/bin/docker",
1984 "KernelVersion": "3.12.0-1-amd64",
1988 "MemTotal": 2099236864,
1989 "MemoryLimit": true,
1991 "NEventsListener": 0,
1994 "Name": "prod-server-42",
1995 "NoProxy": "9.81.1.160",
1996 "OomKillDisable": true,
1997 "OperatingSystem": "Boot2Docker",
2002 "Name": "docker.io",
2007 "InsecureRegistryCIDRs": [
2011 "ServerVersion": "1.9.0",
2013 "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
2018 - **200** – no error
2019 - **500** – server error
2021 #### Show the docker version information
2025 Show the docker version information
2027 **Example request**:
2029 GET /v1.21/version HTTP/1.1
2031 **Example response**:
2034 Content-Type: application/json
2039 "KernelVersion": "3.18.5-tinycore64",
2040 "GoVersion": "go1.4.1",
2041 "GitCommit": "a8a31ef",
2043 "ApiVersion": "1.20",
2044 "Experimental": false
2049 - **200** – no error
2050 - **500** – server error
2052 #### Ping the docker server
2056 Ping the docker server
2058 **Example request**:
2060 GET /v1.21/_ping HTTP/1.1
2062 **Example response**:
2065 Content-Type: text/plain
2071 - **200** - no error
2072 - **500** - server error
2074 #### Create a new image from a container's changes
2078 Create a new image from a container's changes
2080 **Example request**:
2082 POST /v1.21/commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
2083 Content-Type: application/json
2089 "AttachStdin": false,
2090 "AttachStdout": true,
2091 "AttachStderr": true,
2102 "Destination": "/data",
2112 "NetworkDisabled": false,
2118 **Example response**:
2120 HTTP/1.1 201 Created
2121 Content-Type: application/json
2123 {"Id": "596069db4bf5"}
2125 **JSON parameters**:
2127 - **config** - the container's configuration
2129 **Query parameters**:
2131 - **container** – source container
2132 - **repo** – repository
2134 - **comment** – commit message
2135 - **author** – author (e.g., "John Hannibal Smith
2136 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
2137 - **pause** – 1/True/true or 0/False/false, whether to pause the container before committing
2138 - **changes** – Dockerfile instructions to apply while committing
2142 - **201** – no error
2143 - **404** – no such container
2144 - **500** – server error
2146 #### Monitor Docker's events
2150 Get container events from docker, in real time via streaming.
2152 Docker containers report the following events:
2154 attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause
2156 Docker images report the following events:
2158 delete, import, pull, push, tag, untag
2160 **Example request**:
2162 GET /v1.21/events?since=1374067924
2164 **Example response**:
2167 Content-Type: application/json
2169 {"status":"pull","id":"busybox:latest","time":1442421700,"timeNano":1442421700598988358}
2170 {"status":"create","id":"5745704abe9caa5","from":"busybox","time":1442421716,"timeNano":1442421716853979870}
2171 {"status":"attach","id":"5745704abe9caa5","from":"busybox","time":1442421716,"timeNano":1442421716894759198}
2172 {"status":"start","id":"5745704abe9caa5","from":"busybox","time":1442421716,"timeNano":1442421716983607193}
2174 **Query parameters**:
2176 - **since** – Timestamp. Show all events created since timestamp and then stream
2177 - **until** – Timestamp. Show events created until given timestamp and stop streaming
2178 - **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
2179 - `container=<string>`; -- container to filter
2180 - `event=<string>`; -- event to filter
2181 - `image=<string>`; -- image to filter
2182 - `label=<string>`; -- image and container label to filter
2186 - **200** – no error
2187 - **500** – server error
2189 #### Get a tarball containing all images in a repository
2191 `GET /images/(name)/get`
2193 Get a tarball containing all images and metadata for the repository specified
2196 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
2197 (and its parents) are returned. If `name` is an image ID, similarly only that
2198 image (and its parents) are returned, but with the exclusion of the
2199 'repositories' file in the tarball, as there were no image names referenced.
2201 See the [image tarball format](#image-tarball-format) for more details.
2205 GET /v1.21/images/ubuntu/get
2207 **Example response**:
2210 Content-Type: application/x-tar
2216 - **200** – no error
2217 - **500** – server error
2219 #### Get a tarball containing all images
2223 Get a tarball containing all images and metadata for one or more repositories.
2225 For each value of the `names` parameter: if it is a specific name and tag (e.g.
2226 `ubuntu:latest`), then only that image (and its parents) are returned; if it is
2227 an image ID, similarly only that image (and its parents) are returned and there
2228 would be no names referenced in the 'repositories' file for this image ID.
2230 See the [image tarball format](#image-tarball-format) for more details.
2234 GET /v1.21/images/get?names=myname%2Fmyapp%3Alatest&names=busybox
2236 **Example response**:
2239 Content-Type: application/x-tar
2245 - **200** – no error
2246 - **500** – server error
2248 #### Load a tarball with a set of images and tags into docker
2252 Load a set of images and tags into a Docker repository.
2253 See the [image tarball format](#image-tarball-format) for more details.
2257 POST /v1.21/images/load
2258 Content-Type: application/x-tar
2262 **Example response**:
2268 - **200** – no error
2269 - **500** – server error
2271 #### Image tarball format
2273 An image tarball contains one directory per image layer (named using its long ID),
2274 each containing these files:
2276 - `VERSION`: currently `1.0` - the file format version
2277 - `json`: detailed layer information, similar to `docker inspect layer_id`
2278 - `layer.tar`: A tarfile containing the filesystem changes in this layer
2280 The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories
2281 for storing attribute changes and deletions.
2283 If the tarball defines a repository, the tarball should also include a `repositories` file at
2284 the root that contains a list of repository and tag names mapped to layer IDs.
2288 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
2294 `POST /containers/(id or name)/exec`
2296 Sets up an exec instance in a running container `id`
2298 **Example request**:
2300 POST /v1.21/containers/e90e34656806/exec HTTP/1.1
2301 Content-Type: application/json
2304 "AttachStdin": true,
2305 "AttachStdout": true,
2306 "AttachStderr": true,
2313 **Example response**:
2315 HTTP/1.1 201 Created
2316 Content-Type: application/json
2319 "Id": "f90e34656806",
2323 **JSON parameters**:
2325 - **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command.
2326 - **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command.
2327 - **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command.
2328 - **Tty** - Boolean value to allocate a pseudo-TTY.
2329 - **Cmd** - Command to run specified as a string or an array of strings.
2330 - **Privileged** - Boolean value, runs the exec process with extended privileges.
2331 - **User** - A string value specifying the user, and optionally, group to run
2332 the exec process inside the container. Format is one of: `"user"`,
2333 `"user:group"`, `"uid"`, or `"uid:gid"`.
2337 - **201** – no error
2338 - **404** – no such container
2339 - **409** - container is paused
2340 - **500** - server error
2344 `POST /exec/(id)/start`
2346 Starts a previously set up `exec` instance `id`. If `detach` is true, this API
2347 returns after starting the `exec` command. Otherwise, this API sets up an
2348 interactive session with the `exec` command.
2350 **Example request**:
2352 POST /v1.21/exec/e90e34656806/start HTTP/1.1
2353 Content-Type: application/json
2360 **Example response**:
2363 Content-Type: application/vnd.docker.raw-stream
2369 **JSON parameters**:
2371 - **Detach** - Detach from the `exec` command.
2372 - **Tty** - Boolean value to allocate a pseudo-TTY.
2376 - **200** – no error
2377 - **404** – no such exec instance
2378 - **409** - container is paused
2382 Similar to the stream behavior of `POST /containers/(id or name)/attach` API
2386 `POST /exec/(id)/resize`
2388 Resizes the `tty` session used by the `exec` command `id`. The unit is number of characters.
2389 This API is valid only if `tty` was specified as part of creating and starting the `exec` command.
2391 **Example request**:
2393 POST /v1.21/exec/e90e34656806/resize?h=40&w=80 HTTP/1.1
2394 Content-Type: text/plain
2396 **Example response**:
2398 HTTP/1.1 201 Created
2399 Content-Type: text/plain
2401 **Query parameters**:
2403 - **h** – height of `tty` session
2408 - **201** – no error
2409 - **404** – no such exec instance
2413 `GET /exec/(id)/json`
2415 Return low-level information about the `exec` command `id`.
2417 **Example request**:
2419 GET /v1.21/exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
2421 **Example response**:
2424 Content-Type: plain/text
2427 "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
2431 "privileged" : false,
2434 "entrypoint" : "sh",
2440 "OpenStdin" : false,
2441 "OpenStderr" : false,
2442 "OpenStdout" : false,
2445 "Status" : "running",
2448 "Restarting" : false,
2449 "OOMKilled" : false,
2453 "StartedAt" : "2014-11-17T22:26:03.717657531Z",
2454 "FinishedAt" : "0001-01-01T00:00:00Z"
2456 "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
2457 "Created" : "2014-11-17T22:26:03.626304998Z",
2461 "Hostname" : "8f177a186b97",
2464 "AttachStdin" : false,
2465 "AttachStdout" : false,
2466 "AttachStderr" : false,
2467 "ExposedPorts" : null,
2469 "OpenStdin" : false,
2470 "StdinOnce" : false,
2471 "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
2478 "Entrypoint" : null,
2479 "NetworkDisabled" : false,
2482 "SecurityOpt" : null
2484 "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
2485 "NetworkSettings" : {
2488 "HairpinMode": false,
2489 "LinkLocalIPv6Address": "",
2490 "LinkLocalIPv6PrefixLen": 0,
2493 "SecondaryIPAddresses": null,
2494 "SecondaryIPv6Addresses": null,
2497 "GlobalIPv6Address": "",
2498 "GlobalIPv6PrefixLen": 0,
2510 "GlobalIPv6Address": "",
2511 "GlobalIPv6PrefixLen": 0,
2516 "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
2517 "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
2518 "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
2519 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
2522 "ExecDriver" : "native-0.2",
2524 "ProcessLabel" : "",
2525 "AppArmorProfile" : "",
2533 - **200** – no error
2534 - **404** – no such exec instance
2535 - **500** - server error
2543 **Example request**:
2545 GET /v1.21/volumes HTTP/1.1
2547 **Example response**:
2550 Content-Type: application/json
2557 "Mountpoint": "/var/lib/docker/volumes/tardis"
2562 **Query parameters**:
2564 - **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the volumes list. There is one available filter: `dangling=true`
2568 - **200** - no error
2569 - **500** - server error
2571 #### Create a volume
2573 `POST /volumes/create`
2577 **Example request**:
2579 POST /v1.21/volumes/create HTTP/1.1
2580 Content-Type: application/json
2586 **Example response**:
2588 HTTP/1.1 201 Created
2589 Content-Type: application/json
2594 "Mountpoint": "/var/lib/docker/volumes/tardis"
2599 - **201** - no error
2600 - **500** - server error
2602 **JSON parameters**:
2604 - **Name** - The new volume's name. If not specified, Docker generates a name.
2605 - **Driver** - Name of the volume driver to use. Defaults to `local` for the name.
2606 - **DriverOpts** - A mapping of driver options and values. These options are
2607 passed directly to the driver and are driver specific.
2609 #### Inspect a volume
2611 `GET /volumes/(name)`
2613 Return low-level information on the volume `name`
2615 **Example request**:
2619 **Example response**:
2622 Content-Type: application/json
2627 "Mountpoint": "/var/lib/docker/volumes/tardis"
2632 - **200** - no error
2633 - **404** - no such volume
2634 - **500** - server error
2636 #### Remove a volume
2638 `DELETE /volumes/(name)`
2640 Instruct the driver to remove the volume (`name`).
2642 **Example request**:
2644 DELETE /v1.21/volumes/tardis HTTP/1.1
2646 **Example response**:
2648 HTTP/1.1 204 No Content
2652 - **204** - no error
2653 - **404** - no such volume or volume driver
2654 - **409** - volume is in use and cannot be removed
2655 - **500** - server error
2663 **Example request**:
2665 GET /v1.21/networks HTTP/1.1
2667 **Example response**:
2671 Content-Type: application/json
2676 "Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566",
2680 "Driver": "default",
2683 "Subnet": "172.17.0.0/16"
2688 "39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": {
2689 "EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda",
2690 "MacAddress": "02:42:ac:11:00:02",
2691 "IPv4Address": "172.17.0.2/16",
2696 "com.docker.network.bridge.default_bridge": "true",
2697 "com.docker.network.bridge.enable_icc": "true",
2698 "com.docker.network.bridge.enable_ip_masquerade": "true",
2699 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
2700 "com.docker.network.bridge.name": "docker0",
2701 "com.docker.network.driver.mtu": "1500"
2706 "Id": "e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794",
2710 "Driver": "default",
2718 "Id": "13e871235c677f196c4e1ecebb9dc733b9b2d2ab589e30c539efeda84a24215e",
2722 "Driver": "default",
2731 **Query parameters**:
2733 - **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the networks list. Available filters: `name=[network-names]` , `id=[network-ids]`
2737 - **200** - no error
2738 - **500** - server error
2740 #### Inspect network
2742 `GET /networks/(id or name)`
2744 Return low-level information on the network `id`
2746 **Example request**:
2748 GET /v1.21/networks/f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566 HTTP/1.1
2750 **Example response**:
2754 Content-Type: application/json
2758 "Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566",
2762 "Driver": "default",
2765 "Subnet": "172.17.0.0/16"
2770 "39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": {
2771 "EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda",
2772 "MacAddress": "02:42:ac:11:00:02",
2773 "IPv4Address": "172.17.0.2/16",
2778 "com.docker.network.bridge.default_bridge": "true",
2779 "com.docker.network.bridge.enable_icc": "true",
2780 "com.docker.network.bridge.enable_ip_masquerade": "true",
2781 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
2782 "com.docker.network.bridge.name": "docker0",
2783 "com.docker.network.driver.mtu": "1500"
2790 - **200** - no error
2791 - **404** - network not found
2792 - **500** - server error
2794 #### Create a network
2796 `POST /networks/create`
2800 **Example request**:
2803 POST /v1.21/networks/create HTTP/1.1
2804 Content-Type: application/json
2807 "Name":"isolated_nw",
2808 "CheckDuplicate":true,
2811 "Driver": "default",
2814 "Subnet":"172.20.0.0/16",
2815 "IPRange":"172.20.10.0/24",
2816 "Gateway":"172.20.10.11"
2823 **Example response**:
2826 HTTP/1.1 201 Created
2827 Content-Type: application/json
2830 "Id": "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30",
2837 - **201** - no error
2838 - **404** - plugin not found
2839 - **500** - server error
2841 **JSON parameters**:
2843 - **Name** - The new network's name. this is a mandatory field
2844 - **CheckDuplicate** - Requests daemon to check for networks with same name. Defaults to `false`.
2845 Since Network is primarily keyed based on a random ID and not on the name,
2846 and network name is strictly a user-friendly alias to the network which is uniquely identified using ID,
2847 there is no guaranteed way to check for duplicates across a cluster of docker hosts.
2848 This parameter CheckDuplicate is there to provide a best effort checking of any networks
2849 which has the same name but it is not guaranteed to catch all name collisions.
2850 - **Driver** - Name of the network driver plugin to use. Defaults to `bridge` driver
2851 - **IPAM** - Optional custom IP scheme for the network
2852 - **Driver** - Name of the IPAM driver to use. Defaults to `default` driver
2853 - **Config** - List of IPAM configuration options, specified as a map:
2854 `{"Subnet": <CIDR>, "IPRange": <CIDR>, "Gateway": <IP address>, "AuxAddress": <device_name:IP address>}`
2855 - **Options** - Network specific options to be used by the drivers
2857 #### Connect a container to a network
2859 `POST /networks/(id or name)/connect`
2861 Connect a container to a network
2863 **Example request**:
2866 POST /v1.21/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/connect HTTP/1.1
2867 Content-Type: application/json
2870 "Container":"3613f73ba0e4"
2874 **Example response**:
2880 - **200** - no error
2881 - **404** - network or container is not found
2882 - **500** - Internal Server Error
2884 **JSON parameters**:
2886 - **container** - container-id/name to be connected to the network
2888 #### Disconnect a container from a network
2890 `POST /networks/(id or name)/disconnect`
2892 Disconnect a container from a network
2894 **Example request**:
2897 POST /v1.21/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/disconnect HTTP/1.1
2898 Content-Type: application/json
2901 "Container":"3613f73ba0e4"
2905 **Example response**:
2911 - **200** - no error
2912 - **404** - network or container not found
2913 - **500** - Internal Server Error
2915 **JSON parameters**:
2917 - **Container** - container-id/name to be disconnected from a network
2919 #### Remove a network
2921 `DELETE /networks/(id or name)`
2923 Instruct the driver to remove the network (`id`).
2925 **Example request**:
2927 DELETE /v1.21/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30 HTTP/1.1
2929 **Example response**:
2935 - **200** - no error
2936 - **403** - operation not supported for pre-defined networks
2937 - **404** - no such network
2938 - **500** - server error
2942 ### 3.1 Inside `docker run`
2944 As an example, the `docker run` command line makes the following API calls:
2946 - Create the container
2948 - If the status code is 404, it means the image doesn't exist:
2950 - Then, retry to create the container.
2952 - Start the container.
2954 - If you are not in detached mode:
2955 - Attach to the container, using `logs=1` (to have `stdout` and
2956 `stderr` from the container's start) and `stream=1`
2958 - If in detached mode or only `stdin` is attached, display the container's id.
2962 In this version of the API, `/attach`, uses hijacking to transport `stdin`,
2963 `stdout`, and `stderr` on the same socket.
2965 To hint potential proxies about connection hijacking, Docker client sends
2966 connection upgrade headers similarly to websocket.
2971 When Docker daemon detects the `Upgrade` header, it switches its status code
2972 from **200 OK** to **101 UPGRADED** and resends the same headers.
2975 ### 3.3 CORS Requests
2977 To set cross origin requests to the Engine API please give values to
2978 `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all,
2979 default or blank means CORS disabled
2981 $ dockerd -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"