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