github.com/jiasir/docker@v1.3.3-0.20170609024000-252e610103e7/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 Content-Type: application/x-tar 1668 1669 {% raw %} 1670 {{ TAR STREAM }} 1671 {% endraw %} 1672 1673 **Example response**: 1674 1675 HTTP/1.1 200 OK 1676 Content-Type: application/json 1677 1678 {"stream": "Step 1/5..."} 1679 {"stream": "..."} 1680 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 1681 1682 The input stream must be a `tar` archive compressed with one of the 1683 following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`. 1684 1685 The archive must include a build instructions file, typically called 1686 `Dockerfile` at the archive's root. The `dockerfile` parameter may be 1687 used to specify a different build instructions file. To do this, its value must be 1688 the path to the alternate build instructions file to use. 1689 1690 The archive may include any number of other files, 1691 which are accessible in the build context (See the [*ADD build 1692 command*](../reference/builder.md#add)). 1693 1694 The Docker daemon performs a preliminary validation of the `Dockerfile` before 1695 starting the build, and returns an error if the syntax is incorrect. After that, 1696 each instruction is run one-by-one until the ID of the new image is output. 1697 1698 The build is canceled if the client drops the connection by quitting 1699 or being killed. 1700 1701 **Query parameters**: 1702 1703 - **dockerfile** - Path within the build context to the `Dockerfile`. This is 1704 ignored if `remote` is specified and points to an external `Dockerfile`. 1705 - **t** – A name and optional tag to apply to the image in the `name:tag` format. 1706 If you omit the `tag` the default `latest` value is assumed. 1707 You can provide one or more `t` parameters. 1708 - **remote** – A Git repository URI or HTTP/HTTPS context URI. If the 1709 URI points to a single text file, the file's contents are placed into 1710 a file called `Dockerfile` and the image is built from that file. If 1711 the URI points to a tarball, the file is downloaded by the daemon and 1712 the contents therein used as the context for the build. If the URI 1713 points to a tarball and the `dockerfile` parameter is also specified, 1714 there must be a file with the corresponding path inside the tarball. 1715 - **q** – Suppress verbose build output. 1716 - **nocache** – Do not use the cache when building the image. 1717 - **pull** - Attempt to pull the image even if an older image exists locally. 1718 - **rm** - Remove intermediate containers after a successful build (default behavior). 1719 - **forcerm** - Always remove intermediate containers (includes `rm`). 1720 - **memory** - Set memory limit for build. 1721 - **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap. 1722 - **cpushares** - CPU shares (relative weight). 1723 - **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`). 1724 - **cpuperiod** - The length of a CPU period in microseconds. 1725 - **cpuquota** - Microseconds of CPU time that the container can get in a CPU period. 1726 - **buildargs** – JSON map of string pairs for build-time variables. Users pass 1727 these values at build-time. Docker uses the `buildargs` as the environment 1728 context for command(s) run via the Dockerfile's `RUN` instruction or for 1729 variable expansion in other Dockerfile instructions. This is not meant for 1730 passing secret values. [Read more about the buildargs instruction](../reference/builder.md#arg) 1731 - **shmsize** - Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB. 1732 - **labels** – JSON map of string pairs for labels to set on the image. 1733 1734 **Request Headers**: 1735 1736 - **Content-type** – Set to `"application/x-tar"`. 1737 - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON 1738 object with the following structure: 1739 1740 { 1741 "docker.example.com": { 1742 "username": "janedoe", 1743 "password": "hunter2" 1744 }, 1745 "https://index.docker.io/v1/": { 1746 "username": "mobydock", 1747 "password": "conta1n3rize14" 1748 } 1749 } 1750 1751 This object maps the hostname of a registry to an object containing the 1752 "username" and "password" for that registry. Multiple registries may 1753 be specified as the build may be based on an image requiring 1754 authentication to pull from any arbitrary registry. Only the registry 1755 domain name (and port if not the default "443") are required. However 1756 (for legacy reasons) the "official" Docker, Inc. hosted registry must 1757 be specified with both a "https://" prefix and a "/v1/" suffix even 1758 though Docker will prefer to use the v2 registry API. 1759 1760 **Status codes**: 1761 1762 - **200** – no error 1763 - **500** – server error 1764 1765 #### Create an image 1766 1767 `POST /images/create` 1768 1769 Create an image either by pulling it from the registry or by importing it 1770 1771 **Example request**: 1772 1773 POST /v1.23/images/create?fromImage=busybox&tag=latest HTTP/1.1 1774 1775 **Example response**: 1776 1777 HTTP/1.1 200 OK 1778 Content-Type: application/json 1779 1780 {"status": "Pulling..."} 1781 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 1782 {"error": "Invalid..."} 1783 ... 1784 1785 When using this endpoint to pull an image from the registry, the 1786 `X-Registry-Auth` header can be used to include 1787 a base64-encoded AuthConfig object. 1788 1789 **Query parameters**: 1790 1791 - **fromImage** – Name of the image to pull. The name may include a tag or 1792 digest. This parameter may only be used when pulling an image. 1793 The pull is cancelled if the HTTP connection is closed. 1794 - **fromSrc** – Source to import. The value may be a URL from which the image 1795 can be retrieved or `-` to read the image from the request body. 1796 This parameter may only be used when importing an image. 1797 - **repo** – Repository name given to an image when it is imported. 1798 The repo may include a tag. This parameter may only be used when importing 1799 an image. 1800 - **tag** – Tag or digest. If empty when pulling an image, this causes all tags 1801 for the given image to be pulled. 1802 1803 **Request Headers**: 1804 1805 - **X-Registry-Auth** – base64-encoded AuthConfig object, containing either login information, or a token 1806 - Credential based login: 1807 1808 ``` 1809 { 1810 "username": "jdoe", 1811 "password": "secret", 1812 "email": "jdoe@acme.com" 1813 } 1814 ``` 1815 1816 - Token based login: 1817 1818 ``` 1819 { 1820 "identitytoken": "9cbaf023786cd7..." 1821 } 1822 ``` 1823 1824 **Status codes**: 1825 1826 - **200** – no error 1827 - **404** - repository does not exist or no read access 1828 - **500** – server error 1829 1830 1831 1832 #### Inspect an image 1833 1834 `GET /images/(name)/json` 1835 1836 Return low-level information on the image `name` 1837 1838 **Example request**: 1839 1840 GET /v1.23/images/example/json HTTP/1.1 1841 1842 **Example response**: 1843 1844 HTTP/1.1 200 OK 1845 Content-Type: application/json 1846 1847 { 1848 "Id" : "sha256:85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c", 1849 "Container" : "cb91e48a60d01f1e27028b4fc6819f4f290b3cf12496c8176ec714d0d390984a", 1850 "Comment" : "", 1851 "Os" : "linux", 1852 "Architecture" : "amd64", 1853 "Parent" : "sha256:91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c", 1854 "ContainerConfig" : { 1855 "Tty" : false, 1856 "Hostname" : "e611e15f9c9d", 1857 "Volumes" : null, 1858 "Domainname" : "", 1859 "AttachStdout" : false, 1860 "PublishService" : "", 1861 "AttachStdin" : false, 1862 "OpenStdin" : false, 1863 "StdinOnce" : false, 1864 "NetworkDisabled" : false, 1865 "OnBuild" : [], 1866 "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c", 1867 "User" : "", 1868 "WorkingDir" : "", 1869 "Entrypoint" : null, 1870 "MacAddress" : "", 1871 "AttachStderr" : false, 1872 "Labels" : { 1873 "com.example.license" : "GPL", 1874 "com.example.version" : "1.0", 1875 "com.example.vendor" : "Acme" 1876 }, 1877 "Env" : [ 1878 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 1879 ], 1880 "ExposedPorts" : null, 1881 "Cmd" : [ 1882 "/bin/sh", 1883 "-c", 1884 "#(nop) LABEL com.example.vendor=Acme com.example.license=GPL com.example.version=1.0" 1885 ] 1886 }, 1887 "DockerVersion" : "1.9.0-dev", 1888 "VirtualSize" : 188359297, 1889 "Size" : 0, 1890 "Author" : "", 1891 "Created" : "2015-09-10T08:30:53.26995814Z", 1892 "GraphDriver" : { 1893 "Name" : "aufs", 1894 "Data" : null 1895 }, 1896 "RepoDigests" : [ 1897 "localhost:5000/test/busybox/example@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" 1898 ], 1899 "RepoTags" : [ 1900 "example:1.0", 1901 "example:latest", 1902 "example:stable" 1903 ], 1904 "Config" : { 1905 "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c", 1906 "NetworkDisabled" : false, 1907 "OnBuild" : [], 1908 "StdinOnce" : false, 1909 "PublishService" : "", 1910 "AttachStdin" : false, 1911 "OpenStdin" : false, 1912 "Domainname" : "", 1913 "AttachStdout" : false, 1914 "Tty" : false, 1915 "Hostname" : "e611e15f9c9d", 1916 "Volumes" : null, 1917 "Cmd" : [ 1918 "/bin/bash" 1919 ], 1920 "ExposedPorts" : null, 1921 "Env" : [ 1922 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 1923 ], 1924 "Labels" : { 1925 "com.example.vendor" : "Acme", 1926 "com.example.version" : "1.0", 1927 "com.example.license" : "GPL" 1928 }, 1929 "Entrypoint" : null, 1930 "MacAddress" : "", 1931 "AttachStderr" : false, 1932 "WorkingDir" : "", 1933 "User" : "" 1934 }, 1935 "RootFS": { 1936 "Type": "layers", 1937 "Layers": [ 1938 "sha256:1834950e52ce4d5a88a1bbd131c537f4d0e56d10ff0dd69e66be3b7dfa9df7e6", 1939 "sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef" 1940 ] 1941 } 1942 } 1943 1944 **Status codes**: 1945 1946 - **200** – no error 1947 - **404** – no such image 1948 - **500** – server error 1949 1950 #### Get the history of an image 1951 1952 `GET /images/(name)/history` 1953 1954 Return the history of the image `name` 1955 1956 **Example request**: 1957 1958 GET /v1.23/images/ubuntu/history HTTP/1.1 1959 1960 **Example response**: 1961 1962 HTTP/1.1 200 OK 1963 Content-Type: application/json 1964 1965 [ 1966 { 1967 "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710", 1968 "Created": 1398108230, 1969 "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /", 1970 "Tags": [ 1971 "ubuntu:lucid", 1972 "ubuntu:10.04" 1973 ], 1974 "Size": 182964289, 1975 "Comment": "" 1976 }, 1977 { 1978 "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8", 1979 "Created": 1398108222, 1980 "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/", 1981 "Tags": null, 1982 "Size": 0, 1983 "Comment": "" 1984 }, 1985 { 1986 "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158", 1987 "Created": 1371157430, 1988 "CreatedBy": "", 1989 "Tags": [ 1990 "scratch12:latest", 1991 "scratch:latest" 1992 ], 1993 "Size": 0, 1994 "Comment": "Imported from -" 1995 } 1996 ] 1997 1998 **Status codes**: 1999 2000 - **200** – no error 2001 - **404** – no such image 2002 - **500** – server error 2003 2004 #### Push an image on the registry 2005 2006 `POST /images/(name)/push` 2007 2008 Push the image `name` on the registry 2009 2010 **Example request**: 2011 2012 POST /v1.23/images/test/push HTTP/1.1 2013 2014 **Example response**: 2015 2016 HTTP/1.1 200 OK 2017 Content-Type: application/json 2018 2019 {"status": "Pushing..."} 2020 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 2021 {"error": "Invalid..."} 2022 ... 2023 2024 If you wish to push an image on to a private registry, that image must already have a tag 2025 into a repository which references that registry `hostname` and `port`. This repository name should 2026 then be used in the URL. This duplicates the command line's flow. 2027 2028 The push is cancelled if the HTTP connection is closed. 2029 2030 **Example request**: 2031 2032 POST /v1.23/images/registry.acme.com:5000/test/push HTTP/1.1 2033 2034 2035 **Query parameters**: 2036 2037 - **tag** – The tag to associate with the image on the registry. This is optional. 2038 2039 **Request Headers**: 2040 2041 - **X-Registry-Auth** – base64-encoded AuthConfig object, containing either login information, or a token 2042 - Credential based login: 2043 2044 ``` 2045 { 2046 "username": "jdoe", 2047 "password": "secret", 2048 "email": "jdoe@acme.com", 2049 } 2050 ``` 2051 2052 - Identity token based login: 2053 2054 ``` 2055 { 2056 "identitytoken": "9cbaf023786cd7..." 2057 } 2058 ``` 2059 2060 **Status codes**: 2061 2062 - **200** – no error 2063 - **404** – no such image 2064 - **500** – server error 2065 2066 #### Tag an image into a repository 2067 2068 `POST /images/(name)/tag` 2069 2070 Tag the image `name` into a repository 2071 2072 **Example request**: 2073 2074 POST /v1.23/images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1 2075 2076 **Example response**: 2077 2078 HTTP/1.1 201 Created 2079 2080 **Query parameters**: 2081 2082 - **repo** – The repository to tag in 2083 - **force** – 1/True/true or 0/False/false, default false 2084 - **tag** - The new tag name 2085 2086 **Status codes**: 2087 2088 - **201** – no error 2089 - **400** – bad parameter 2090 - **404** – no such image 2091 - **409** – conflict 2092 - **500** – server error 2093 2094 #### Remove an image 2095 2096 `DELETE /images/(name)` 2097 2098 Remove the image `name` from the filesystem 2099 2100 **Example request**: 2101 2102 DELETE /v1.23/images/test HTTP/1.1 2103 2104 **Example response**: 2105 2106 HTTP/1.1 200 OK 2107 Content-type: application/json 2108 2109 [ 2110 {"Untagged": "3e2f21a89f"}, 2111 {"Deleted": "3e2f21a89f"}, 2112 {"Deleted": "53b4f83ac9"} 2113 ] 2114 2115 **Query parameters**: 2116 2117 - **force** – 1/True/true or 0/False/false, default false 2118 - **noprune** – 1/True/true or 0/False/false, default false 2119 2120 **Status codes**: 2121 2122 - **200** – no error 2123 - **404** – no such image 2124 - **409** – conflict 2125 - **500** – server error 2126 2127 #### Search images 2128 2129 `GET /images/search` 2130 2131 Search for an image on [Docker Hub](https://hub.docker.com). 2132 2133 > **Note**: 2134 > The response keys have changed from API v1.6 to reflect the JSON 2135 > sent by the registry server to the docker daemon's request. 2136 2137 **Example request**: 2138 2139 GET /v1.23/images/search?term=sshd HTTP/1.1 2140 2141 **Example response**: 2142 2143 HTTP/1.1 200 OK 2144 Content-Type: application/json 2145 2146 [ 2147 { 2148 "description": "", 2149 "is_official": false, 2150 "is_automated": false, 2151 "name": "wma55/u1210sshd", 2152 "star_count": 0 2153 }, 2154 { 2155 "description": "", 2156 "is_official": false, 2157 "is_automated": false, 2158 "name": "jdswinbank/sshd", 2159 "star_count": 0 2160 }, 2161 { 2162 "description": "", 2163 "is_official": false, 2164 "is_automated": false, 2165 "name": "vgauthier/sshd", 2166 "star_count": 0 2167 } 2168 ... 2169 ] 2170 2171 **Query parameters**: 2172 2173 - **term** – term to search 2174 2175 **Status codes**: 2176 2177 - **200** – no error 2178 - **500** – server error 2179 2180 ### 2.3 Misc 2181 2182 #### Check auth configuration 2183 2184 `POST /auth` 2185 2186 Validate credentials for a registry and get identity token, 2187 if available, for accessing the registry without password. 2188 2189 **Example request**: 2190 2191 POST /v1.23/auth HTTP/1.1 2192 Content-Type: application/json 2193 2194 { 2195 "username": "hannibal", 2196 "password": "xxxx", 2197 "serveraddress": "https://index.docker.io/v1/" 2198 } 2199 2200 **Example response**: 2201 2202 HTTP/1.1 200 OK 2203 2204 { 2205 "Status": "Login Succeeded", 2206 "IdentityToken": "9cbaf023786cd7..." 2207 } 2208 2209 **Status codes**: 2210 2211 - **200** – no error 2212 - **204** – no error 2213 - **500** – server error 2214 2215 #### Display system-wide information 2216 2217 `GET /info` 2218 2219 Display system-wide information 2220 2221 **Example request**: 2222 2223 GET /v1.23/info HTTP/1.1 2224 2225 **Example response**: 2226 2227 HTTP/1.1 200 OK 2228 Content-Type: application/json 2229 2230 { 2231 "Architecture": "x86_64", 2232 "ClusterStore": "etcd://localhost:2379", 2233 "CgroupDriver": "cgroupfs", 2234 "Containers": 11, 2235 "ContainersRunning": 7, 2236 "ContainersStopped": 3, 2237 "ContainersPaused": 1, 2238 "CpuCfsPeriod": true, 2239 "CpuCfsQuota": true, 2240 "Debug": false, 2241 "DockerRootDir": "/var/lib/docker", 2242 "Driver": "btrfs", 2243 "DriverStatus": [[""]], 2244 "ExecutionDriver": "native-0.1", 2245 "ExperimentalBuild": false, 2246 "HttpProxy": "http://test:test@localhost:8080", 2247 "HttpsProxy": "https://test:test@localhost:8080", 2248 "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS", 2249 "IPv4Forwarding": true, 2250 "Images": 16, 2251 "IndexServerAddress": "https://index.docker.io/v1/", 2252 "InitPath": "/usr/bin/docker", 2253 "InitSha1": "", 2254 "KernelMemory": true, 2255 "KernelVersion": "3.12.0-1-amd64", 2256 "Labels": [ 2257 "storage=ssd" 2258 ], 2259 "MemTotal": 2099236864, 2260 "MemoryLimit": true, 2261 "NCPU": 1, 2262 "NEventsListener": 0, 2263 "NFd": 11, 2264 "NGoroutines": 21, 2265 "Name": "prod-server-42", 2266 "NoProxy": "9.81.1.160", 2267 "OomKillDisable": true, 2268 "OSType": "linux", 2269 "OperatingSystem": "Boot2Docker", 2270 "Plugins": { 2271 "Volume": [ 2272 "local" 2273 ], 2274 "Network": [ 2275 "null", 2276 "host", 2277 "bridge" 2278 ] 2279 }, 2280 "RegistryConfig": { 2281 "IndexConfigs": { 2282 "docker.io": { 2283 "Mirrors": null, 2284 "Name": "docker.io", 2285 "Official": true, 2286 "Secure": true 2287 } 2288 }, 2289 "InsecureRegistryCIDRs": [ 2290 "127.0.0.0/8" 2291 ] 2292 }, 2293 "ServerVersion": "1.9.0", 2294 "SwapLimit": false, 2295 "SystemStatus": [["State", "Healthy"]], 2296 "SystemTime": "2015-03-10T11:11:23.730591467-07:00" 2297 } 2298 2299 **Status codes**: 2300 2301 - **200** – no error 2302 - **500** – server error 2303 2304 #### Show the docker version information 2305 2306 `GET /version` 2307 2308 Show the docker version information 2309 2310 **Example request**: 2311 2312 GET /v1.23/version HTTP/1.1 2313 2314 **Example response**: 2315 2316 HTTP/1.1 200 OK 2317 Content-Type: application/json 2318 2319 { 2320 "Version": "1.11.0", 2321 "Os": "linux", 2322 "KernelVersion": "3.19.0-23-generic", 2323 "GoVersion": "go1.4.2", 2324 "GitCommit": "e75da4b", 2325 "Arch": "amd64", 2326 "ApiVersion": "1.23", 2327 "BuildTime": "2015-12-01T07:09:13.444803460+00:00", 2328 "Experimental": true 2329 } 2330 2331 **Status codes**: 2332 2333 - **200** – no error 2334 - **500** – server error 2335 2336 #### Ping the docker server 2337 2338 `GET /_ping` 2339 2340 Ping the docker server 2341 2342 **Example request**: 2343 2344 GET /v1.23/_ping HTTP/1.1 2345 2346 **Example response**: 2347 2348 HTTP/1.1 200 OK 2349 Content-Type: text/plain 2350 2351 OK 2352 2353 **Status codes**: 2354 2355 - **200** - no error 2356 - **500** - server error 2357 2358 #### Create a new image from a container's changes 2359 2360 `POST /commit` 2361 2362 Create a new image from a container's changes 2363 2364 **Example request**: 2365 2366 POST /v1.23/commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1 2367 Content-Type: application/json 2368 2369 { 2370 "Hostname": "", 2371 "Domainname": "", 2372 "User": "", 2373 "AttachStdin": false, 2374 "AttachStdout": true, 2375 "AttachStderr": true, 2376 "Tty": false, 2377 "OpenStdin": false, 2378 "StdinOnce": false, 2379 "Env": null, 2380 "Cmd": [ 2381 "date" 2382 ], 2383 "Mounts": [ 2384 { 2385 "Source": "/data", 2386 "Destination": "/data", 2387 "Mode": "ro,Z", 2388 "RW": false 2389 } 2390 ], 2391 "Labels": { 2392 "key1": "value1", 2393 "key2": "value2" 2394 }, 2395 "WorkingDir": "", 2396 "NetworkDisabled": false, 2397 "ExposedPorts": { 2398 "22/tcp": {} 2399 } 2400 } 2401 2402 **Example response**: 2403 2404 HTTP/1.1 201 Created 2405 Content-Type: application/json 2406 2407 {"Id": "596069db4bf5"} 2408 2409 **JSON parameters**: 2410 2411 - **config** - the container's configuration 2412 2413 **Query parameters**: 2414 2415 - **container** – source container 2416 - **repo** – repository 2417 - **tag** – tag 2418 - **comment** – commit message 2419 - **author** – author (e.g., "John Hannibal Smith 2420 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 2421 - **pause** – 1/True/true or 0/False/false, whether to pause the container before committing 2422 - **changes** – Dockerfile instructions to apply while committing 2423 2424 **Status codes**: 2425 2426 - **201** – no error 2427 - **404** – no such container 2428 - **500** – server error 2429 2430 #### Monitor Docker's events 2431 2432 `GET /events` 2433 2434 Get container events from docker, in real time via streaming. 2435 2436 Docker containers report the following events: 2437 2438 attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update 2439 2440 Docker images report the following events: 2441 2442 delete, import, pull, push, tag, untag 2443 2444 Docker volumes report the following events: 2445 2446 create, mount, unmount, destroy 2447 2448 Docker networks report the following events: 2449 2450 create, connect, disconnect, destroy 2451 2452 **Example request**: 2453 2454 GET /v1.23/events?since=1374067924 2455 2456 **Example response**: 2457 2458 HTTP/1.1 200 OK 2459 Content-Type: application/json 2460 Server: Docker/1.11.0 (linux) 2461 Date: Fri, 29 Apr 2016 15:18:06 GMT 2462 Transfer-Encoding: chunked 2463 2464 { 2465 "status": "pull", 2466 "id": "alpine:latest", 2467 "Type": "image", 2468 "Action": "pull", 2469 "Actor": { 2470 "ID": "alpine:latest", 2471 "Attributes": { 2472 "name": "alpine" 2473 } 2474 }, 2475 "time": 1461943101, 2476 "timeNano": 1461943101301854122 2477 } 2478 { 2479 "status": "create", 2480 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2481 "from": "alpine", 2482 "Type": "container", 2483 "Action": "create", 2484 "Actor": { 2485 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2486 "Attributes": { 2487 "com.example.some-label": "some-label-value", 2488 "image": "alpine", 2489 "name": "my-container" 2490 } 2491 }, 2492 "time": 1461943101, 2493 "timeNano": 1461943101381709551 2494 } 2495 { 2496 "status": "attach", 2497 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2498 "from": "alpine", 2499 "Type": "container", 2500 "Action": "attach", 2501 "Actor": { 2502 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2503 "Attributes": { 2504 "com.example.some-label": "some-label-value", 2505 "image": "alpine", 2506 "name": "my-container" 2507 } 2508 }, 2509 "time": 1461943101, 2510 "timeNano": 1461943101383858412 2511 } 2512 { 2513 "Type": "network", 2514 "Action": "connect", 2515 "Actor": { 2516 "ID": "7dc8ac97d5d29ef6c31b6052f3938c1e8f2749abbd17d1bd1febf2608db1b474", 2517 "Attributes": { 2518 "container": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2519 "name": "bridge", 2520 "type": "bridge" 2521 } 2522 }, 2523 "time": 1461943101, 2524 "timeNano": 1461943101394865557 2525 } 2526 { 2527 "status": "start", 2528 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2529 "from": "alpine", 2530 "Type": "container", 2531 "Action": "start", 2532 "Actor": { 2533 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2534 "Attributes": { 2535 "com.example.some-label": "some-label-value", 2536 "image": "alpine", 2537 "name": "my-container" 2538 } 2539 }, 2540 "time": 1461943101, 2541 "timeNano": 1461943101607533796 2542 } 2543 { 2544 "status": "resize", 2545 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2546 "from": "alpine", 2547 "Type": "container", 2548 "Action": "resize", 2549 "Actor": { 2550 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2551 "Attributes": { 2552 "com.example.some-label": "some-label-value", 2553 "height": "46", 2554 "image": "alpine", 2555 "name": "my-container", 2556 "width": "204" 2557 } 2558 }, 2559 "time": 1461943101, 2560 "timeNano": 1461943101610269268 2561 } 2562 { 2563 "status": "die", 2564 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2565 "from": "alpine", 2566 "Type": "container", 2567 "Action": "die", 2568 "Actor": { 2569 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2570 "Attributes": { 2571 "com.example.some-label": "some-label-value", 2572 "exitCode": "0", 2573 "image": "alpine", 2574 "name": "my-container" 2575 } 2576 }, 2577 "time": 1461943105, 2578 "timeNano": 1461943105079144137 2579 } 2580 { 2581 "Type": "network", 2582 "Action": "disconnect", 2583 "Actor": { 2584 "ID": "7dc8ac97d5d29ef6c31b6052f3938c1e8f2749abbd17d1bd1febf2608db1b474", 2585 "Attributes": { 2586 "container": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2587 "name": "bridge", 2588 "type": "bridge" 2589 } 2590 }, 2591 "time": 1461943105, 2592 "timeNano": 1461943105230860245 2593 } 2594 { 2595 "status": "destroy", 2596 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2597 "from": "alpine", 2598 "Type": "container", 2599 "Action": "destroy", 2600 "Actor": { 2601 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2602 "Attributes": { 2603 "com.example.some-label": "some-label-value", 2604 "image": "alpine", 2605 "name": "my-container" 2606 } 2607 }, 2608 "time": 1461943105, 2609 "timeNano": 1461943105338056026 2610 } 2611 2612 **Query parameters**: 2613 2614 - **since** – Timestamp. Show all events created since timestamp and then stream 2615 - **until** – Timestamp. Show events created until given timestamp and stop streaming 2616 - **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters: 2617 - `container=<string>`; -- container to filter 2618 - `event=<string>`; -- event to filter 2619 - `image=<string>`; -- image to filter 2620 - `label=<string>`; -- image and container label to filter 2621 - `type=<string>`; -- either `container` or `image` or `volume` or `network` 2622 - `volume=<string>`; -- volume to filter 2623 - `network=<string>`; -- network to filter 2624 2625 **Status codes**: 2626 2627 - **200** – no error 2628 - **500** – server error 2629 2630 #### Get a tarball containing all images in a repository 2631 2632 `GET /images/(name)/get` 2633 2634 Get a tarball containing all images and metadata for the repository specified 2635 by `name`. 2636 2637 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image 2638 (and its parents) are returned. If `name` is an image ID, similarly only that 2639 image (and its parents) are returned, but with the exclusion of the 2640 'repositories' file in the tarball, as there were no image names referenced. 2641 2642 See the [image tarball format](#image-tarball-format) for more details. 2643 2644 **Example request** 2645 2646 GET /v1.23/images/ubuntu/get 2647 2648 **Example response**: 2649 2650 HTTP/1.1 200 OK 2651 Content-Type: application/x-tar 2652 2653 Binary data stream 2654 2655 **Status codes**: 2656 2657 - **200** – no error 2658 - **500** – server error 2659 2660 #### Get a tarball containing all images 2661 2662 `GET /images/get` 2663 2664 Get a tarball containing all images and metadata for one or more repositories. 2665 2666 For each value of the `names` parameter: if it is a specific name and tag (e.g. 2667 `ubuntu:latest`), then only that image (and its parents) are returned; if it is 2668 an image ID, similarly only that image (and its parents) are returned and there 2669 would be no names referenced in the 'repositories' file for this image ID. 2670 2671 See the [image tarball format](#image-tarball-format) for more details. 2672 2673 **Example request** 2674 2675 GET /v1.23/images/get?names=myname%2Fmyapp%3Alatest&names=busybox 2676 2677 **Example response**: 2678 2679 HTTP/1.1 200 OK 2680 Content-Type: application/x-tar 2681 2682 Binary data stream 2683 2684 **Status codes**: 2685 2686 - **200** – no error 2687 - **500** – server error 2688 2689 #### Load a tarball with a set of images and tags into docker 2690 2691 `POST /images/load` 2692 2693 Load a set of images and tags into a Docker repository. 2694 See the [image tarball format](#image-tarball-format) for more details. 2695 2696 **Example request** 2697 2698 POST /v1.23/images/load 2699 Content-Type: application/x-tar 2700 2701 Tarball in body 2702 2703 **Example response**: 2704 2705 HTTP/1.1 200 OK 2706 Content-Type: application/json 2707 Transfer-Encoding: chunked 2708 2709 {"status":"Loading layer","progressDetail":{"current":32768,"total":1292800},"progress":"[= ] 32.77 kB/1.293 MB","id":"8ac8bfaff55a"} 2710 {"status":"Loading layer","progressDetail":{"current":65536,"total":1292800},"progress":"[== ] 65.54 kB/1.293 MB","id":"8ac8bfaff55a"} 2711 {"status":"Loading layer","progressDetail":{"current":98304,"total":1292800},"progress":"[=== ] 98.3 kB/1.293 MB","id":"8ac8bfaff55a"} 2712 {"status":"Loading layer","progressDetail":{"current":131072,"total":1292800},"progress":"[===== ] 131.1 kB/1.293 MB","id":"8ac8bfaff55a"} 2713 ... 2714 {"stream":"Loaded image: busybox:latest\n"} 2715 2716 **Example response**: 2717 2718 If the "quiet" query parameter is set to `true` / `1` (`?quiet=1`), progress 2719 details are suppressed, and only a confirmation message is returned once the 2720 action completes. 2721 2722 HTTP/1.1 200 OK 2723 Content-Type: application/json 2724 Transfer-Encoding: chunked 2725 2726 {"stream":"Loaded image: busybox:latest\n"} 2727 2728 **Query parameters**: 2729 2730 - **quiet** – Boolean value, suppress progress details during load. Defaults 2731 to `0` / `false` if omitted. 2732 2733 **Status codes**: 2734 2735 - **200** – no error 2736 - **500** – server error 2737 2738 #### Image tarball format 2739 2740 An image tarball contains one directory per image layer (named using its long ID), 2741 each containing these files: 2742 2743 - `VERSION`: currently `1.0` - the file format version 2744 - `json`: detailed layer information, similar to `docker inspect layer_id` 2745 - `layer.tar`: A tarfile containing the filesystem changes in this layer 2746 2747 The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories 2748 for storing attribute changes and deletions. 2749 2750 If the tarball defines a repository, the tarball should also include a `repositories` file at 2751 the root that contains a list of repository and tag names mapped to layer IDs. 2752 2753 ``` 2754 {"hello-world": 2755 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 2756 } 2757 ``` 2758 2759 #### Exec Create 2760 2761 `POST /containers/(id or name)/exec` 2762 2763 Sets up an exec instance in a running container `id` 2764 2765 **Example request**: 2766 2767 POST /v1.23/containers/e90e34656806/exec HTTP/1.1 2768 Content-Type: application/json 2769 2770 { 2771 "AttachStdin": true, 2772 "AttachStdout": true, 2773 "AttachStderr": true, 2774 "Cmd": ["sh"], 2775 "DetachKeys": "ctrl-p,ctrl-q", 2776 "Privileged": true, 2777 "Tty": true, 2778 "User": "123:456" 2779 } 2780 2781 **Example response**: 2782 2783 HTTP/1.1 201 Created 2784 Content-Type: application/json 2785 2786 { 2787 "Id": "f90e34656806", 2788 "Warnings":[] 2789 } 2790 2791 **JSON parameters**: 2792 2793 - **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command. 2794 - **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command. 2795 - **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command. 2796 - **DetachKeys** – Override the key sequence for detaching a 2797 container. Format is a single character `[a-Z]` or `ctrl-<value>` 2798 where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 2799 - **Tty** - Boolean value to allocate a pseudo-TTY. 2800 - **Cmd** - Command to run specified as a string or an array of strings. 2801 - **Privileged** - Boolean value, runs the exec process with extended privileges. 2802 - **User** - A string value specifying the user, and optionally, group to run 2803 the exec process inside the container. Format is one of: `"user"`, 2804 `"user:group"`, `"uid"`, or `"uid:gid"`. 2805 2806 **Status codes**: 2807 2808 - **201** – no error 2809 - **404** – no such container 2810 - **409** - container is paused 2811 - **500** - server error 2812 2813 #### Exec Start 2814 2815 `POST /exec/(id)/start` 2816 2817 Starts a previously set up `exec` instance `id`. If `detach` is true, this API 2818 returns after starting the `exec` command. Otherwise, this API sets up an 2819 interactive session with the `exec` command. 2820 2821 **Example request**: 2822 2823 POST /v1.23/exec/e90e34656806/start HTTP/1.1 2824 Content-Type: application/json 2825 2826 { 2827 "Detach": false, 2828 "Tty": false 2829 } 2830 2831 **Example response**: 2832 2833 HTTP/1.1 200 OK 2834 Content-Type: application/vnd.docker.raw-stream 2835 2836 {% raw %} 2837 {{ STREAM }} 2838 {% endraw %} 2839 2840 **JSON parameters**: 2841 2842 - **Detach** - Detach from the `exec` command. 2843 - **Tty** - Boolean value to allocate a pseudo-TTY. 2844 2845 **Status codes**: 2846 2847 - **200** – no error 2848 - **404** – no such exec instance 2849 - **409** - container is paused 2850 2851 **Stream details**: 2852 2853 Similar to the stream behavior of `POST /containers/(id or name)/attach` API 2854 2855 #### Exec Resize 2856 2857 `POST /exec/(id)/resize` 2858 2859 Resizes the `tty` session used by the `exec` command `id`. The unit is number of characters. 2860 This API is valid only if `tty` was specified as part of creating and starting the `exec` command. 2861 2862 **Example request**: 2863 2864 POST /v1.23/exec/e90e34656806/resize?h=40&w=80 HTTP/1.1 2865 Content-Type: text/plain 2866 2867 **Example response**: 2868 2869 HTTP/1.1 201 Created 2870 Content-Type: text/plain 2871 2872 **Query parameters**: 2873 2874 - **h** – height of `tty` session 2875 - **w** – width 2876 2877 **Status codes**: 2878 2879 - **201** – no error 2880 - **404** – no such exec instance 2881 2882 #### Exec Inspect 2883 2884 `GET /exec/(id)/json` 2885 2886 Return low-level information about the `exec` command `id`. 2887 2888 **Example request**: 2889 2890 GET /v1.23/exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1 2891 2892 **Example response**: 2893 2894 HTTP/1.1 200 OK 2895 Content-Type: application/json 2896 2897 { 2898 "CanRemove": false, 2899 "ContainerID": "b53ee82b53a40c7dca428523e34f741f3abc51d9f297a14ff874bf761b995126", 2900 "DetachKeys": "", 2901 "ExitCode": 2, 2902 "ID": "f33bbfb39f5b142420f4759b2348913bd4a8d1a6d7fd56499cb41a1bb91d7b3b", 2903 "OpenStderr": true, 2904 "OpenStdin": true, 2905 "OpenStdout": true, 2906 "ProcessConfig": { 2907 "arguments": [ 2908 "-c", 2909 "exit 2" 2910 ], 2911 "entrypoint": "sh", 2912 "privileged": false, 2913 "tty": true, 2914 "user": "1000" 2915 }, 2916 "Running": false 2917 } 2918 2919 **Status codes**: 2920 2921 - **200** – no error 2922 - **404** – no such exec instance 2923 - **500** - server error 2924 2925 ### 2.4 Volumes 2926 2927 #### List volumes 2928 2929 `GET /volumes` 2930 2931 **Example request**: 2932 2933 GET /v1.23/volumes HTTP/1.1 2934 2935 **Example response**: 2936 2937 HTTP/1.1 200 OK 2938 Content-Type: application/json 2939 2940 { 2941 "Volumes": [ 2942 { 2943 "Name": "tardis", 2944 "Driver": "local", 2945 "Mountpoint": "/var/lib/docker/volumes/tardis" 2946 } 2947 ], 2948 "Warnings": [] 2949 } 2950 2951 **Query parameters**: 2952 2953 - **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the volumes list. There is one available filter: `dangling=true` 2954 2955 **Status codes**: 2956 2957 - **200** - no error 2958 - **500** - server error 2959 2960 #### Create a volume 2961 2962 `POST /volumes/create` 2963 2964 Create a volume 2965 2966 **Example request**: 2967 2968 POST /v1.23/volumes/create HTTP/1.1 2969 Content-Type: application/json 2970 2971 { 2972 "Name": "tardis", 2973 "Labels": { 2974 "com.example.some-label": "some-value", 2975 "com.example.some-other-label": "some-other-value" 2976 } 2977 } 2978 2979 **Example response**: 2980 2981 HTTP/1.1 201 Created 2982 Content-Type: application/json 2983 2984 { 2985 "Name": "tardis", 2986 "Driver": "local", 2987 "Mountpoint": "/var/lib/docker/volumes/tardis", 2988 "Labels": { 2989 "com.example.some-label": "some-value", 2990 "com.example.some-other-label": "some-other-value" 2991 } 2992 } 2993 2994 **Status codes**: 2995 2996 - **201** - no error 2997 - **500** - server error 2998 2999 **JSON parameters**: 3000 3001 - **Name** - The new volume's name. If not specified, Docker generates a name. 3002 - **Driver** - Name of the volume driver to use. Defaults to `local` for the name. 3003 - **DriverOpts** - A mapping of driver options and values. These options are 3004 passed directly to the driver and are driver specific. 3005 - **Labels** - Labels to set on the volume, specified as a map: `{"key":"value","key2":"value2"}` 3006 3007 #### Inspect a volume 3008 3009 `GET /volumes/(name)` 3010 3011 Return low-level information on the volume `name` 3012 3013 **Example request**: 3014 3015 GET /v1.23/volumes/tardis 3016 3017 **Example response**: 3018 3019 HTTP/1.1 200 OK 3020 Content-Type: application/json 3021 3022 { 3023 "Name": "tardis", 3024 "Driver": "local", 3025 "Mountpoint": "/var/lib/docker/volumes/tardis/_data", 3026 "Labels": { 3027 "com.example.some-label": "some-value", 3028 "com.example.some-other-label": "some-other-value" 3029 } 3030 } 3031 3032 **Status codes**: 3033 3034 - **200** - no error 3035 - **404** - no such volume 3036 - **500** - server error 3037 3038 #### Remove a volume 3039 3040 `DELETE /volumes/(name)` 3041 3042 Instruct the driver to remove the volume (`name`). 3043 3044 **Example request**: 3045 3046 DELETE /v1.23/volumes/tardis HTTP/1.1 3047 3048 **Example response**: 3049 3050 HTTP/1.1 204 No Content 3051 3052 **Status codes**: 3053 3054 - **204** - no error 3055 - **404** - no such volume or volume driver 3056 - **409** - volume is in use and cannot be removed 3057 - **500** - server error 3058 3059 ### 3.5 Networks 3060 3061 #### List networks 3062 3063 `GET /networks` 3064 3065 **Example request**: 3066 3067 GET /v1.23/networks?filters={"type":{"custom":true}} HTTP/1.1 3068 3069 **Example response**: 3070 3071 ``` 3072 HTTP/1.1 200 OK 3073 Content-Type: application/json 3074 3075 [ 3076 { 3077 "Name": "bridge", 3078 "Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566", 3079 "Scope": "local", 3080 "Driver": "bridge", 3081 "EnableIPv6": false, 3082 "Internal": false, 3083 "IPAM": { 3084 "Driver": "default", 3085 "Config": [ 3086 { 3087 "Subnet": "172.17.0.0/16" 3088 } 3089 ] 3090 }, 3091 "Containers": { 3092 "39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": { 3093 "EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda", 3094 "MacAddress": "02:42:ac:11:00:02", 3095 "IPv4Address": "172.17.0.2/16", 3096 "IPv6Address": "" 3097 } 3098 }, 3099 "Options": { 3100 "com.docker.network.bridge.default_bridge": "true", 3101 "com.docker.network.bridge.enable_icc": "true", 3102 "com.docker.network.bridge.enable_ip_masquerade": "true", 3103 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 3104 "com.docker.network.bridge.name": "docker0", 3105 "com.docker.network.driver.mtu": "1500" 3106 } 3107 }, 3108 { 3109 "Name": "none", 3110 "Id": "e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794", 3111 "Scope": "local", 3112 "Driver": "null", 3113 "EnableIPv6": false, 3114 "Internal": false, 3115 "IPAM": { 3116 "Driver": "default", 3117 "Config": [] 3118 }, 3119 "Containers": {}, 3120 "Options": {} 3121 }, 3122 { 3123 "Name": "host", 3124 "Id": "13e871235c677f196c4e1ecebb9dc733b9b2d2ab589e30c539efeda84a24215e", 3125 "Scope": "local", 3126 "Driver": "host", 3127 "EnableIPv6": false, 3128 "Internal": false, 3129 "IPAM": { 3130 "Driver": "default", 3131 "Config": [] 3132 }, 3133 "Containers": {}, 3134 "Options": {} 3135 } 3136 ] 3137 ``` 3138 3139 **Query parameters**: 3140 3141 - **filters** - JSON encoded network list filter. The filter value is one of: 3142 - `id=<network-id>` Matches all or part of a network id. 3143 - `name=<network-name>` Matches all or part of a network name. 3144 - `type=["custom"|"builtin"]` Filters networks by type. The `custom` keyword returns all user-defined networks. 3145 3146 **Status codes**: 3147 3148 - **200** - no error 3149 - **500** - server error 3150 3151 #### Inspect network 3152 3153 `GET /networks/(id or name)` 3154 3155 Return low-level information on the network `id` 3156 3157 **Example request**: 3158 3159 GET /v1.23/networks/7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99 HTTP/1.1 3160 3161 **Example response**: 3162 3163 ``` 3164 HTTP/1.1 200 OK 3165 Content-Type: application/json 3166 3167 { 3168 "Name": "net01", 3169 "Id": "7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99", 3170 "Scope": "local", 3171 "Driver": "bridge", 3172 "EnableIPv6": false, 3173 "IPAM": { 3174 "Driver": "default", 3175 "Config": [ 3176 { 3177 "Subnet": "172.19.0.0/16", 3178 "Gateway": "172.19.0.1/16" 3179 } 3180 ], 3181 "Options": { 3182 "foo": "bar" 3183 } 3184 }, 3185 "Internal": false, 3186 "Containers": { 3187 "19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c": { 3188 "Name": "test", 3189 "EndpointID": "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a", 3190 "MacAddress": "02:42:ac:13:00:02", 3191 "IPv4Address": "172.19.0.2/16", 3192 "IPv6Address": "" 3193 } 3194 }, 3195 "Options": { 3196 "com.docker.network.bridge.default_bridge": "true", 3197 "com.docker.network.bridge.enable_icc": "true", 3198 "com.docker.network.bridge.enable_ip_masquerade": "true", 3199 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 3200 "com.docker.network.bridge.name": "docker0", 3201 "com.docker.network.driver.mtu": "1500" 3202 }, 3203 "Labels": { 3204 "com.example.some-label": "some-value", 3205 "com.example.some-other-label": "some-other-value" 3206 } 3207 } 3208 ``` 3209 3210 **Status codes**: 3211 3212 - **200** - no error 3213 - **404** - network not found 3214 - **500** - server error 3215 3216 #### Create a network 3217 3218 `POST /networks/create` 3219 3220 Create a network 3221 3222 **Example request**: 3223 3224 ``` 3225 POST /v1.23/networks/create HTTP/1.1 3226 Content-Type: application/json 3227 3228 { 3229 "Name":"isolated_nw", 3230 "CheckDuplicate":true, 3231 "Driver":"bridge", 3232 "EnableIPv6": true, 3233 "IPAM":{ 3234 "Driver": "default", 3235 "Config":[ 3236 { 3237 "Subnet":"172.20.0.0/16", 3238 "IPRange":"172.20.10.0/24", 3239 "Gateway":"172.20.10.11" 3240 }, 3241 { 3242 "Subnet":"2001:db8:abcd::/64", 3243 "Gateway":"2001:db8:abcd::1011" 3244 } 3245 ], 3246 "Options": { 3247 "foo": "bar" 3248 } 3249 }, 3250 "Internal":true, 3251 "Options": { 3252 "com.docker.network.bridge.default_bridge": "true", 3253 "com.docker.network.bridge.enable_icc": "true", 3254 "com.docker.network.bridge.enable_ip_masquerade": "true", 3255 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 3256 "com.docker.network.bridge.name": "docker0", 3257 "com.docker.network.driver.mtu": "1500" 3258 }, 3259 "Labels": { 3260 "com.example.some-label": "some-value", 3261 "com.example.some-other-label": "some-other-value" 3262 } 3263 } 3264 ``` 3265 3266 **Example response**: 3267 3268 ``` 3269 HTTP/1.1 201 Created 3270 Content-Type: application/json 3271 3272 { 3273 "Id": "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30", 3274 "Warning": "" 3275 } 3276 ``` 3277 3278 **Status codes**: 3279 3280 - **201** - no error 3281 - **404** - plugin not found 3282 - **500** - server error 3283 3284 **JSON parameters**: 3285 3286 - **Name** - The new network's name. this is a mandatory field 3287 - **CheckDuplicate** - Requests daemon to check for networks with same name. Defaults to `false`. 3288 Since Network is primarily keyed based on a random ID and not on the name, 3289 and network name is strictly a user-friendly alias to the network 3290 which is uniquely identified using ID, there is no guaranteed way to check for duplicates. 3291 This parameter CheckDuplicate is there to provide a best effort checking of any networks 3292 which has the same name but it is not guaranteed to catch all name collisions. 3293 - **Driver** - Name of the network driver plugin to use. Defaults to `bridge` driver 3294 - **Internal** - Restrict external access to the network 3295 - **IPAM** - Optional custom IP scheme for the network 3296 - **Driver** - Name of the IPAM driver to use. Defaults to `default` driver 3297 - **Config** - List of IPAM configuration options, specified as a map: 3298 `{"Subnet": <CIDR>, "IPRange": <CIDR>, "Gateway": <IP address>, "AuxAddress": <device_name:IP address>}` 3299 - **Options** - Driver-specific options, specified as a map: `{"option":"value" [,"option2":"value2"]}` 3300 - **EnableIPv6** - Enable IPv6 on the network 3301 - **Options** - Network specific options to be used by the drivers 3302 - **Labels** - Labels to set on the network, specified as a map: `{"key":"value" [,"key2":"value2"]}` 3303 3304 #### Connect a container to a network 3305 3306 `POST /networks/(id or name)/connect` 3307 3308 Connect a container to a network 3309 3310 **Example request**: 3311 3312 ``` 3313 POST /v1.23/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/connect HTTP/1.1 3314 Content-Type: application/json 3315 3316 { 3317 "Container":"3613f73ba0e4", 3318 "EndpointConfig": { 3319 "IPAMConfig": { 3320 "IPv4Address":"172.24.56.89", 3321 "IPv6Address":"2001:db8::5689" 3322 } 3323 } 3324 } 3325 ``` 3326 3327 **Example response**: 3328 3329 HTTP/1.1 200 OK 3330 3331 **Status codes**: 3332 3333 - **200** - no error 3334 - **404** - network or container is not found 3335 - **500** - Internal Server Error 3336 3337 **JSON parameters**: 3338 3339 - **container** - container-id/name to be connected to the network 3340 3341 #### Disconnect a container from a network 3342 3343 `POST /networks/(id or name)/disconnect` 3344 3345 Disconnect a container from a network 3346 3347 **Example request**: 3348 3349 ``` 3350 POST /v1.23/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/disconnect HTTP/1.1 3351 Content-Type: application/json 3352 3353 { 3354 "Container":"3613f73ba0e4", 3355 "Force":false 3356 } 3357 ``` 3358 3359 **Example response**: 3360 3361 HTTP/1.1 200 OK 3362 3363 **Status codes**: 3364 3365 - **200** - no error 3366 - **404** - network or container not found 3367 - **500** - Internal Server Error 3368 3369 **JSON parameters**: 3370 3371 - **Container** - container-id/name to be disconnected from a network 3372 - **Force** - Force the container to disconnect from a network 3373 3374 #### Remove a network 3375 3376 `DELETE /networks/(id or name)` 3377 3378 Instruct the driver to remove the network (`id`). 3379 3380 **Example request**: 3381 3382 DELETE /v1.23/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30 HTTP/1.1 3383 3384 **Example response**: 3385 3386 HTTP/1.1 204 No Content 3387 3388 **Status codes**: 3389 3390 - **204** - no error 3391 - **403** - operation not supported for pre-defined networks 3392 - **404** - no such network 3393 - **500** - server error 3394 3395 ## 3. Going further 3396 3397 ### 3.1 Inside `docker run` 3398 3399 As an example, the `docker run` command line makes the following API calls: 3400 3401 - Create the container 3402 3403 - If the status code is 404, it means the image doesn't exist: 3404 - Try to pull it. 3405 - Then, retry to create the container. 3406 3407 - Start the container. 3408 3409 - If you are not in detached mode: 3410 - Attach to the container, using `logs=1` (to have `stdout` and 3411 `stderr` from the container's start) and `stream=1` 3412 3413 - If in detached mode or only `stdin` is attached, display the container's id. 3414 3415 ### 3.2 Hijacking 3416 3417 In this version of the API, `/attach`, uses hijacking to transport `stdin`, 3418 `stdout`, and `stderr` on the same socket. 3419 3420 To hint potential proxies about connection hijacking, Docker client sends 3421 connection upgrade headers similarly to websocket. 3422 3423 Upgrade: tcp 3424 Connection: Upgrade 3425 3426 When Docker daemon detects the `Upgrade` header, it switches its status code 3427 from **200 OK** to **101 UPGRADED** and resends the same headers. 3428 3429 3430 ### 3.3 CORS Requests 3431 3432 To set cross origin requests to the Engine API please give values to 3433 `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, 3434 default or blank means CORS disabled 3435 3436 $ dockerd -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"