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