github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/docs/api/v1.24.md (about) 1 --- 2 title: "Engine API v1.24" 3 description: "API Documentation for Docker" 4 keywords: "API, Docker, rcli, REST, documentation" 5 redirect_from: 6 - /engine/reference/api/docker_remote_api_v1.24/ 7 - /reference/api/docker_remote_api_v1.24/ 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 27 ## 2. Errors 28 29 The Engine API uses standard HTTP status codes to indicate the success or failure of the API call. The body of the response will be JSON in the following format: 30 31 { 32 "message": "page not found" 33 } 34 35 The status codes that are returned for each endpoint are specified in the endpoint documentation below. 36 37 ## 3. Endpoints 38 39 ### 3.1 Containers 40 41 #### List containers 42 43 `GET /containers/json` 44 45 List containers 46 47 **Example request**: 48 49 GET /v1.24/containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1 50 51 **Example response**: 52 53 HTTP/1.1 200 OK 54 Content-Type: application/json 55 56 [ 57 { 58 "Id": "8dfafdbc3a40", 59 "Names":["/boring_feynman"], 60 "Image": "ubuntu:latest", 61 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", 62 "Command": "echo 1", 63 "Created": 1367854155, 64 "State": "exited", 65 "Status": "Exit 0", 66 "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}], 67 "Labels": { 68 "com.example.vendor": "Acme", 69 "com.example.license": "GPL", 70 "com.example.version": "1.0" 71 }, 72 "SizeRw": 12288, 73 "SizeRootFs": 0, 74 "HostConfig": { 75 "NetworkMode": "default" 76 }, 77 "NetworkSettings": { 78 "Networks": { 79 "bridge": { 80 "IPAMConfig": null, 81 "Links": null, 82 "Aliases": null, 83 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 84 "EndpointID": "2cdc4edb1ded3631c81f57966563e5c8525b81121bb3706a9a9a3ae102711f3f", 85 "Gateway": "172.17.0.1", 86 "IPAddress": "172.17.0.2", 87 "IPPrefixLen": 16, 88 "IPv6Gateway": "", 89 "GlobalIPv6Address": "", 90 "GlobalIPv6PrefixLen": 0, 91 "MacAddress": "02:42:ac:11:00:02" 92 } 93 } 94 }, 95 "Mounts": [ 96 { 97 "Name": "fac362...80535", 98 "Source": "/data", 99 "Destination": "/data", 100 "Driver": "local", 101 "Mode": "ro,Z", 102 "RW": false, 103 "Propagation": "" 104 } 105 ] 106 }, 107 { 108 "Id": "9cd87474be90", 109 "Names":["/coolName"], 110 "Image": "ubuntu:latest", 111 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", 112 "Command": "echo 222222", 113 "Created": 1367854155, 114 "State": "exited", 115 "Status": "Exit 0", 116 "Ports": [], 117 "Labels": {}, 118 "SizeRw": 12288, 119 "SizeRootFs": 0, 120 "HostConfig": { 121 "NetworkMode": "default" 122 }, 123 "NetworkSettings": { 124 "Networks": { 125 "bridge": { 126 "IPAMConfig": null, 127 "Links": null, 128 "Aliases": null, 129 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 130 "EndpointID": "88eaed7b37b38c2a3f0c4bc796494fdf51b270c2d22656412a2ca5d559a64d7a", 131 "Gateway": "172.17.0.1", 132 "IPAddress": "172.17.0.8", 133 "IPPrefixLen": 16, 134 "IPv6Gateway": "", 135 "GlobalIPv6Address": "", 136 "GlobalIPv6PrefixLen": 0, 137 "MacAddress": "02:42:ac:11:00:08" 138 } 139 } 140 }, 141 "Mounts": [] 142 }, 143 { 144 "Id": "3176a2479c92", 145 "Names":["/sleepy_dog"], 146 "Image": "ubuntu:latest", 147 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", 148 "Command": "echo 3333333333333333", 149 "Created": 1367854154, 150 "State": "exited", 151 "Status": "Exit 0", 152 "Ports":[], 153 "Labels": {}, 154 "SizeRw":12288, 155 "SizeRootFs":0, 156 "HostConfig": { 157 "NetworkMode": "default" 158 }, 159 "NetworkSettings": { 160 "Networks": { 161 "bridge": { 162 "IPAMConfig": null, 163 "Links": null, 164 "Aliases": null, 165 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 166 "EndpointID": "8b27c041c30326d59cd6e6f510d4f8d1d570a228466f956edf7815508f78e30d", 167 "Gateway": "172.17.0.1", 168 "IPAddress": "172.17.0.6", 169 "IPPrefixLen": 16, 170 "IPv6Gateway": "", 171 "GlobalIPv6Address": "", 172 "GlobalIPv6PrefixLen": 0, 173 "MacAddress": "02:42:ac:11:00:06" 174 } 175 } 176 }, 177 "Mounts": [] 178 }, 179 { 180 "Id": "4cb07b47f9fb", 181 "Names":["/running_cat"], 182 "Image": "ubuntu:latest", 183 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", 184 "Command": "echo 444444444444444444444444444444444", 185 "Created": 1367854152, 186 "State": "exited", 187 "Status": "Exit 0", 188 "Ports": [], 189 "Labels": {}, 190 "SizeRw": 12288, 191 "SizeRootFs": 0, 192 "HostConfig": { 193 "NetworkMode": "default" 194 }, 195 "NetworkSettings": { 196 "Networks": { 197 "bridge": { 198 "IPAMConfig": null, 199 "Links": null, 200 "Aliases": null, 201 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 202 "EndpointID": "d91c7b2f0644403d7ef3095985ea0e2370325cd2332ff3a3225c4247328e66e9", 203 "Gateway": "172.17.0.1", 204 "IPAddress": "172.17.0.5", 205 "IPPrefixLen": 16, 206 "IPv6Gateway": "", 207 "GlobalIPv6Address": "", 208 "GlobalIPv6PrefixLen": 0, 209 "MacAddress": "02:42:ac:11:00:05" 210 } 211 } 212 }, 213 "Mounts": [] 214 } 215 ] 216 217 **Query parameters**: 218 219 - **all** – 1/True/true or 0/False/false, Show all containers. 220 Only running containers are shown by default (i.e., this defaults to false) 221 - **limit** – Show `limit` last created 222 containers, include non-running ones. 223 - **since** – Show only containers created since Id, include 224 non-running ones. 225 - **before** – Show only containers created before Id, include 226 non-running ones. 227 - **size** – 1/True/true or 0/False/false, Show the containers 228 sizes 229 - **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters: 230 - `exited=<int>`; -- containers with exit code of `<int>` ; 231 - `status=`(`created`|`restarting`|`running`|`paused`|`exited`|`dead`) 232 - `label=key` or `label="key=value"` of a container label 233 - `isolation=`(`default`|`process`|`hyperv`) (Windows daemon only) 234 - `ancestor`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) 235 - `before`=(`<container id>` or `<container name>`) 236 - `since`=(`<container id>` or `<container name>`) 237 - `volume`=(`<volume name>` or `<mount point destination>`) 238 - `network`=(`<network id>` or `<network name>`) 239 240 **Status codes**: 241 242 - **200** – no error 243 - **400** – bad parameter 244 - **500** – server error 245 246 #### Create a container 247 248 `POST /containers/create` 249 250 Create a container 251 252 **Example request**: 253 254 POST /v1.24/containers/create HTTP/1.1 255 Content-Type: application/json 256 257 { 258 "Hostname": "", 259 "Domainname": "", 260 "User": "", 261 "AttachStdin": false, 262 "AttachStdout": true, 263 "AttachStderr": true, 264 "Tty": false, 265 "OpenStdin": false, 266 "StdinOnce": false, 267 "Env": [ 268 "FOO=bar", 269 "BAZ=quux" 270 ], 271 "Cmd": [ 272 "date" 273 ], 274 "Entrypoint": "", 275 "Image": "ubuntu", 276 "Labels": { 277 "com.example.vendor": "Acme", 278 "com.example.license": "GPL", 279 "com.example.version": "1.0" 280 }, 281 "Volumes": { 282 "/volumes/data": {} 283 }, 284 "Healthcheck":{ 285 "Test": ["CMD-SHELL", "curl localhost:3000"], 286 "Interval": 1000000000, 287 "Timeout": 10000000000, 288 "Retries": 10 289 }, 290 "WorkingDir": "", 291 "NetworkDisabled": false, 292 "MacAddress": "12:34:56:78:9a:bc", 293 "ExposedPorts": { 294 "22/tcp": {} 295 }, 296 "StopSignal": "SIGTERM", 297 "HostConfig": { 298 "Binds": ["/tmp:/tmp"], 299 "Tmpfs": { "/run": "rw,noexec,nosuid,size=65536k" }, 300 "Links": ["redis3:redis"], 301 "Memory": 0, 302 "MemorySwap": 0, 303 "MemoryReservation": 0, 304 "KernelMemory": 0, 305 "CpuPercent": 80, 306 "CpuShares": 512, 307 "CpuPeriod": 100000, 308 "CpuQuota": 50000, 309 "CpusetCpus": "0,1", 310 "CpusetMems": "0,1", 311 "IOMaximumBandwidth": 0, 312 "IOMaximumIOps": 0, 313 "BlkioWeight": 300, 314 "BlkioWeightDevice": [{}], 315 "BlkioDeviceReadBps": [{}], 316 "BlkioDeviceReadIOps": [{}], 317 "BlkioDeviceWriteBps": [{}], 318 "BlkioDeviceWriteIOps": [{}], 319 "MemorySwappiness": 60, 320 "OomKillDisable": false, 321 "OomScoreAdj": 500, 322 "PidMode": "", 323 "PidsLimit": -1, 324 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] }, 325 "PublishAllPorts": false, 326 "Privileged": false, 327 "ReadonlyRootfs": false, 328 "Dns": ["8.8.8.8"], 329 "DnsOptions": [""], 330 "DnsSearch": [""], 331 "ExtraHosts": null, 332 "VolumesFrom": ["parent", "other:ro"], 333 "CapAdd": ["NET_ADMIN"], 334 "CapDrop": ["MKNOD"], 335 "GroupAdd": ["newgroup"], 336 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 }, 337 "NetworkMode": "bridge", 338 "Devices": [], 339 "Sysctls": { "net.ipv4.ip_forward": "1" }, 340 "Ulimits": [{}], 341 "LogConfig": { "Type": "json-file", "Config": {} }, 342 "SecurityOpt": [], 343 "StorageOpt": {}, 344 "CgroupParent": "", 345 "VolumeDriver": "", 346 "ShmSize": 67108864 347 }, 348 "NetworkingConfig": { 349 "EndpointsConfig": { 350 "isolated_nw" : { 351 "IPAMConfig": { 352 "IPv4Address":"172.20.30.33", 353 "IPv6Address":"2001:db8:abcd::3033", 354 "LinkLocalIPs":["169.254.34.68", "fe80::3468"] 355 }, 356 "Links":["container_1", "container_2"], 357 "Aliases":["server_x", "server_y"] 358 } 359 } 360 } 361 } 362 363 **Example response**: 364 365 HTTP/1.1 201 Created 366 Content-Type: application/json 367 368 { 369 "Id":"e90e34656806", 370 "Warnings":[] 371 } 372 373 **JSON parameters**: 374 375 - **Hostname** - A string value containing the hostname to use for the 376 container. This must be a valid RFC 1123 hostname. 377 - **Domainname** - A string value containing the domain name to use 378 for the container. 379 - **User** - A string value specifying the user inside the container. 380 - **AttachStdin** - Boolean value, attaches to `stdin`. 381 - **AttachStdout** - Boolean value, attaches to `stdout`. 382 - **AttachStderr** - Boolean value, attaches to `stderr`. 383 - **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed. 384 - **OpenStdin** - Boolean value, opens `stdin`, 385 - **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects. 386 - **Env** - A list of environment variables in the form of `["VAR=value", ...]` 387 - **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value", ... }` 388 - **Cmd** - Command to run specified as a string or an array of strings. 389 - **Entrypoint** - Set the entry point for the container as a string or an array 390 of strings. 391 - **Image** - A string specifying the image name to use for the container. 392 - **Volumes** - An object mapping mount point paths (strings) inside the 393 container to empty objects. 394 - **Healthcheck** - A test to perform to check that the container is healthy. 395 - **Test** - The test to perform. Possible values are: 396 + `{}` inherit healthcheck from image or parent image 397 + `{"NONE"}` disable healthcheck 398 + `{"CMD", args...}` exec arguments directly 399 + `{"CMD-SHELL", command}` run command with system's default shell 400 - **Interval** - The time to wait between checks in nanoseconds. It should be 0 or not less than 1000000000(1s). 0 means inherit. 401 - **Timeout** - The time to wait before considering the check to have hung. It should be 0 or not less than 1000000000(1s). 0 means inherit. 402 - **Retries** - The number of consecutive failures needed to consider a container as unhealthy. 0 means inherit. 403 - **WorkingDir** - A string specifying the working directory for commands to 404 run in. 405 - **NetworkDisabled** - Boolean value, when true disables networking for the 406 container 407 - **ExposedPorts** - An object mapping ports to an empty object in the form of: 408 `"ExposedPorts": { "<port>/<tcp|udp>: {}" }` 409 - **StopSignal** - Signal to stop a container as a string or unsigned integer. `SIGTERM` by default. 410 - **HostConfig** 411 - **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms: 412 + `host-src:container-dest` to bind-mount a host path into the 413 container. Both `host-src`, and `container-dest` must be an 414 _absolute_ path. 415 + `host-src:container-dest:ro` to make the bind-mount read-only 416 inside the container. Both `host-src`, and `container-dest` must be 417 an _absolute_ path. 418 + `volume-name:container-dest` to bind-mount a volume managed by a 419 volume driver into the container. `container-dest` must be an 420 _absolute_ path. 421 + `volume-name:container-dest:ro` to mount the volume read-only 422 inside the container. `container-dest` must be an _absolute_ path. 423 - **Tmpfs** – A map of container directories which should be replaced by tmpfs mounts, and their corresponding 424 mount options. A JSON object in the form `{ "/run": "rw,noexec,nosuid,size=65536k" }`. 425 - **Links** - A list of links for the container. Each link entry should be 426 in the form of `container_name:alias`. 427 - **Memory** - Memory limit in bytes. 428 - **MemorySwap** - Total memory limit (memory + swap); set `-1` to enable unlimited swap. 429 You must use this with `memory` and make the swap value larger than `memory`. 430 - **MemoryReservation** - Memory soft limit in bytes. 431 - **KernelMemory** - Kernel memory limit in bytes. 432 - **CpuPercent** - An integer value containing the usable percentage of the available CPUs. (Windows daemon only) 433 - **CpuShares** - An integer value containing the container's CPU Shares 434 (ie. the relative weight vs other containers). 435 - **CpuPeriod** - The length of a CPU period in microseconds. 436 - **CpuQuota** - Microseconds of CPU time that the container can get in a CPU period. 437 - **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use. 438 - **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. 439 - **IOMaximumBandwidth** - Maximum IO absolute rate in terms of IOps. 440 - **IOMaximumIOps** - Maximum IO absolute rate in terms of bytes per second. 441 - **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000. 442 - **BlkioWeightDevice** - Block IO weight (relative device weight) in the form of: `"BlkioWeightDevice": [{"Path": "device_path", "Weight": weight}]` 443 - **BlkioDeviceReadBps** - Limit read rate (bytes per second) from a device in the form of: `"BlkioDeviceReadBps": [{"Path": "device_path", "Rate": rate}]`, for example: 444 `"BlkioDeviceReadBps": [{"Path": "/dev/sda", "Rate": "1024"}]"` 445 - **BlkioDeviceWriteBps** - Limit write rate (bytes per second) to a device in the form of: `"BlkioDeviceWriteBps": [{"Path": "device_path", "Rate": rate}]`, for example: 446 `"BlkioDeviceWriteBps": [{"Path": "/dev/sda", "Rate": "1024"}]"` 447 - **BlkioDeviceReadIOps** - Limit read rate (IO per second) from a device in the form of: `"BlkioDeviceReadIOps": [{"Path": "device_path", "Rate": rate}]`, for example: 448 `"BlkioDeviceReadIOps": [{"Path": "/dev/sda", "Rate": "1000"}]` 449 - **BlkioDeviceWriteIOps** - Limit write rate (IO per second) to a device in the form of: `"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]`, for example: 450 `"BlkioDeviceWriteIOps": [{"Path": "/dev/sda", "Rate": "1000"}]` 451 - **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100. 452 - **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not. 453 - **OomScoreAdj** - An integer value containing the score given to the container in order to tune OOM killer preferences. 454 - **PidMode** - Set the PID (Process) Namespace mode for the container; 455 `"container:<name|id>"`: joins another container's PID namespace 456 `"host"`: use the host's PID namespace inside the container 457 - **PidsLimit** - Tune a container's pids limit. Set -1 for unlimited. 458 - **PortBindings** - A map of exposed container ports and the host port they 459 should map to. A JSON object in the form 460 `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }` 461 Take note that `port` is specified as a string and not an integer value. 462 - **PublishAllPorts** - Allocates a random host port for all of a container's 463 exposed ports. Specified as a boolean value. 464 - **Privileged** - Gives the container full access to the host. Specified as 465 a boolean value. 466 - **ReadonlyRootfs** - Mount the container's root filesystem as read only. 467 Specified as a boolean value. 468 - **Dns** - A list of DNS servers for the container to use. 469 - **DnsOptions** - A list of DNS options 470 - **DnsSearch** - A list of DNS search domains 471 - **ExtraHosts** - A list of hostnames/IP mappings to add to the 472 container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`. 473 - **VolumesFrom** - A list of volumes to inherit from another container. 474 Specified in the form `<container name>[:<ro|rw>]` 475 - **CapAdd** - A list of kernel capabilities to add to the container. 476 - **Capdrop** - A list of kernel capabilities to drop from the container. 477 - **GroupAdd** - A list of additional groups that the container process will run as 478 - **RestartPolicy** – The behavior to apply when the container exits. The 479 value is an object with a `Name` property of either `"always"` to 480 always restart, `"unless-stopped"` to restart always except when 481 user has manually stopped the container or `"on-failure"` to restart only when the container 482 exit code is non-zero. If `on-failure` is used, `MaximumRetryCount` 483 controls the number of times to retry before giving up. 484 The default is not to restart. (optional) 485 An ever increasing delay (double the previous delay, starting at 100mS) 486 is added before each restart to prevent flooding the server. 487 - **UsernsMode** - Sets the usernamespace mode for the container when usernamespace remapping option is enabled. 488 supported values are: `host`. 489 - **NetworkMode** - Sets the networking mode for the container. Supported 490 standard values are: `bridge`, `host`, `none`, and `container:<name|id>`. Any other value is taken 491 as a custom network's name to which this container should connect to. 492 - **Devices** - A list of devices to add to the container specified as a JSON object in the 493 form 494 `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}` 495 - **Ulimits** - A list of ulimits to set in the container, specified as 496 `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example: 497 `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }` 498 - **Sysctls** - A list of kernel parameters (sysctls) to set in the container, specified as 499 `{ <name>: <Value> }`, for example: 500 `{ "net.ipv4.ip_forward": "1" }` 501 - **SecurityOpt**: A list of string values to customize labels for MLS 502 systems, such as SELinux. 503 - **StorageOpt**: Storage driver options per container. Options can be passed in the form 504 `{"size":"120G"}` 505 - **LogConfig** - Log configuration for the container, specified as a JSON object in the form 506 `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`. 507 Available types: `json-file`, `syslog`, `journald`, `gelf`, `fluentd`, `awslogs`, `splunk`, `etwlogs`, `none`. 508 `json-file` logging driver. 509 - **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. 510 - **VolumeDriver** - Driver that this container users to mount volumes. 511 - **ShmSize** - Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB. 512 513 **Query parameters**: 514 515 - **name** – Assign the specified name to the container. Must 516 match `/?[a-zA-Z0-9_-]+`. 517 518 **Status codes**: 519 520 - **201** – no error 521 - **400** – bad parameter 522 - **404** – no such container 523 - **406** – impossible to attach (container not running) 524 - **409** – conflict 525 - **500** – server error 526 527 #### Inspect a container 528 529 `GET /containers/(id or name)/json` 530 531 Return low-level information on the container `id` 532 533 **Example request**: 534 535 GET /v1.24/containers/4fa6e0f0c678/json HTTP/1.1 536 537 **Example response**: 538 539 HTTP/1.1 200 OK 540 Content-Type: application/json 541 542 { 543 "AppArmorProfile": "", 544 "Args": [ 545 "-c", 546 "exit 9" 547 ], 548 "Config": { 549 "AttachStderr": true, 550 "AttachStdin": false, 551 "AttachStdout": true, 552 "Cmd": [ 553 "/bin/sh", 554 "-c", 555 "exit 9" 556 ], 557 "Domainname": "", 558 "Entrypoint": null, 559 "Env": [ 560 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 561 ], 562 "ExposedPorts": null, 563 "Hostname": "ba033ac44011", 564 "Image": "ubuntu", 565 "Labels": { 566 "com.example.vendor": "Acme", 567 "com.example.license": "GPL", 568 "com.example.version": "1.0" 569 }, 570 "MacAddress": "", 571 "NetworkDisabled": false, 572 "OnBuild": null, 573 "OpenStdin": false, 574 "StdinOnce": false, 575 "Tty": false, 576 "User": "", 577 "Volumes": { 578 "/volumes/data": {} 579 }, 580 "WorkingDir": "", 581 "StopSignal": "SIGTERM" 582 }, 583 "Created": "2015-01-06T15:47:31.485331387Z", 584 "Driver": "devicemapper", 585 "ExecIDs": null, 586 "HostConfig": { 587 "Binds": null, 588 "IOMaximumBandwidth": 0, 589 "IOMaximumIOps": 0, 590 "BlkioWeight": 0, 591 "BlkioWeightDevice": [{}], 592 "BlkioDeviceReadBps": [{}], 593 "BlkioDeviceWriteBps": [{}], 594 "BlkioDeviceReadIOps": [{}], 595 "BlkioDeviceWriteIOps": [{}], 596 "CapAdd": null, 597 "CapDrop": null, 598 "ContainerIDFile": "", 599 "CpusetCpus": "", 600 "CpusetMems": "", 601 "CpuPercent": 80, 602 "CpuShares": 0, 603 "CpuPeriod": 100000, 604 "Devices": [], 605 "Dns": null, 606 "DnsOptions": null, 607 "DnsSearch": null, 608 "ExtraHosts": null, 609 "IpcMode": "", 610 "Links": null, 611 "LxcConf": [], 612 "Memory": 0, 613 "MemorySwap": 0, 614 "MemoryReservation": 0, 615 "KernelMemory": 0, 616 "OomKillDisable": false, 617 "OomScoreAdj": 500, 618 "NetworkMode": "bridge", 619 "PidMode": "", 620 "PortBindings": {}, 621 "Privileged": false, 622 "ReadonlyRootfs": false, 623 "PublishAllPorts": false, 624 "RestartPolicy": { 625 "MaximumRetryCount": 2, 626 "Name": "on-failure" 627 }, 628 "LogConfig": { 629 "Config": null, 630 "Type": "json-file" 631 }, 632 "SecurityOpt": null, 633 "Sysctls": { 634 "net.ipv4.ip_forward": "1" 635 }, 636 "StorageOpt": null, 637 "VolumesFrom": null, 638 "Ulimits": [{}], 639 "VolumeDriver": "", 640 "ShmSize": 67108864 641 }, 642 "HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname", 643 "HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts", 644 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log", 645 "Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39", 646 "Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2", 647 "MountLabel": "", 648 "Name": "/boring_euclid", 649 "NetworkSettings": { 650 "Bridge": "", 651 "SandboxID": "", 652 "HairpinMode": false, 653 "LinkLocalIPv6Address": "", 654 "LinkLocalIPv6PrefixLen": 0, 655 "Ports": null, 656 "SandboxKey": "", 657 "SecondaryIPAddresses": null, 658 "SecondaryIPv6Addresses": null, 659 "EndpointID": "", 660 "Gateway": "", 661 "GlobalIPv6Address": "", 662 "GlobalIPv6PrefixLen": 0, 663 "IPAddress": "", 664 "IPPrefixLen": 0, 665 "IPv6Gateway": "", 666 "MacAddress": "", 667 "Networks": { 668 "bridge": { 669 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 670 "EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d", 671 "Gateway": "172.17.0.1", 672 "IPAddress": "172.17.0.2", 673 "IPPrefixLen": 16, 674 "IPv6Gateway": "", 675 "GlobalIPv6Address": "", 676 "GlobalIPv6PrefixLen": 0, 677 "MacAddress": "02:42:ac:12:00:02" 678 } 679 } 680 }, 681 "Path": "/bin/sh", 682 "ProcessLabel": "", 683 "ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf", 684 "RestartCount": 1, 685 "State": { 686 "Error": "", 687 "ExitCode": 9, 688 "FinishedAt": "2015-01-06T15:47:32.080254511Z", 689 "OOMKilled": false, 690 "Dead": false, 691 "Paused": false, 692 "Pid": 0, 693 "Restarting": false, 694 "Running": true, 695 "StartedAt": "2015-01-06T15:47:32.072697474Z", 696 "Status": "running" 697 }, 698 "Mounts": [ 699 { 700 "Name": "fac362...80535", 701 "Source": "/data", 702 "Destination": "/data", 703 "Driver": "local", 704 "Mode": "ro,Z", 705 "RW": false, 706 "Propagation": "" 707 } 708 ] 709 } 710 711 **Example request, with size information**: 712 713 GET /v1.24/containers/4fa6e0f0c678/json?size=1 HTTP/1.1 714 715 **Example response, with size information**: 716 717 HTTP/1.1 200 OK 718 Content-Type: application/json 719 720 { 721 .... 722 "SizeRw": 0, 723 "SizeRootFs": 972, 724 .... 725 } 726 727 **Query parameters**: 728 729 - **size** – 1/True/true or 0/False/false, return container size information. Default is `false`. 730 731 **Status codes**: 732 733 - **200** – no error 734 - **404** – no such container 735 - **500** – server error 736 737 #### List processes running inside a container 738 739 `GET /containers/(id or name)/top` 740 741 List processes running inside the container `id`. On Unix systems this 742 is done by running the `ps` command. This endpoint is not 743 supported on Windows. 744 745 **Example request**: 746 747 GET /v1.24/containers/4fa6e0f0c678/top HTTP/1.1 748 749 **Example response**: 750 751 HTTP/1.1 200 OK 752 Content-Type: application/json 753 754 { 755 "Titles" : [ 756 "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD" 757 ], 758 "Processes" : [ 759 [ 760 "root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash" 761 ], 762 [ 763 "root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10" 764 ] 765 ] 766 } 767 768 **Example request**: 769 770 GET /v1.24/containers/4fa6e0f0c678/top?ps_args=aux HTTP/1.1 771 772 **Example response**: 773 774 HTTP/1.1 200 OK 775 Content-Type: application/json 776 777 { 778 "Titles" : [ 779 "USER","PID","%CPU","%MEM","VSZ","RSS","TTY","STAT","START","TIME","COMMAND" 780 ] 781 "Processes" : [ 782 [ 783 "root","13642","0.0","0.1","18172","3184","pts/0","Ss","17:03","0:00","/bin/bash" 784 ], 785 [ 786 "root","13895","0.0","0.0","4348","692","pts/0","S+","17:15","0:00","sleep 10" 787 ] 788 ], 789 } 790 791 **Query parameters**: 792 793 - **ps_args** – `ps` arguments to use (e.g., `aux`), defaults to `-ef` 794 795 **Status codes**: 796 797 - **200** – no error 798 - **404** – no such container 799 - **500** – server error 800 801 #### Get container logs 802 803 `GET /containers/(id or name)/logs` 804 805 Get `stdout` and `stderr` logs from the container ``id`` 806 807 > **Note**: 808 > This endpoint works only for containers with the `json-file` or `journald` logging drivers. 809 810 **Example request**: 811 812 GET /v1.24/containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1 813 814 **Example response**: 815 816 HTTP/1.1 101 UPGRADED 817 Content-Type: application/vnd.docker.raw-stream 818 Connection: Upgrade 819 Upgrade: tcp 820 821 {% raw %} 822 {{ STREAM }} 823 {% endraw %} 824 825 **Query parameters**: 826 827 - **details** - 1/True/true or 0/False/flase, Show extra details provided to logs. Default `false`. 828 - **follow** – 1/True/true or 0/False/false, return stream. Default `false`. 829 - **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`. 830 - **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`. 831 - **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp 832 will only output log-entries since that timestamp. Default: 0 (unfiltered) 833 - **timestamps** – 1/True/true or 0/False/false, print timestamps for 834 every log line. Default `false`. 835 - **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all. 836 837 **Status codes**: 838 839 - **101** – no error, hints proxy about hijacking 840 - **200** – no error, no upgrade header found 841 - **404** – no such container 842 - **500** – server error 843 844 #### Inspect changes on a container's filesystem 845 846 `GET /containers/(id or name)/changes` 847 848 Inspect changes on container `id`'s filesystem 849 850 **Example request**: 851 852 GET /v1.24/containers/4fa6e0f0c678/changes HTTP/1.1 853 854 **Example response**: 855 856 HTTP/1.1 200 OK 857 Content-Type: application/json 858 859 [ 860 { 861 "Path": "/dev", 862 "Kind": 0 863 }, 864 { 865 "Path": "/dev/kmsg", 866 "Kind": 1 867 }, 868 { 869 "Path": "/test", 870 "Kind": 1 871 } 872 ] 873 874 Values for `Kind`: 875 876 - `0`: Modify 877 - `1`: Add 878 - `2`: Delete 879 880 **Status codes**: 881 882 - **200** – no error 883 - **404** – no such container 884 - **500** – server error 885 886 #### Export a container 887 888 `GET /containers/(id or name)/export` 889 890 Export the contents of container `id` 891 892 **Example request**: 893 894 GET /v1.24/containers/4fa6e0f0c678/export HTTP/1.1 895 896 **Example response**: 897 898 HTTP/1.1 200 OK 899 Content-Type: application/octet-stream 900 901 {% raw %} 902 {{ TAR STREAM }} 903 {% endraw %} 904 905 **Status codes**: 906 907 - **200** – no error 908 - **404** – no such container 909 - **500** – server error 910 911 #### Get container stats based on resource usage 912 913 `GET /containers/(id or name)/stats` 914 915 This endpoint returns a live stream of a container's resource usage statistics. 916 917 **Example request**: 918 919 GET /v1.24/containers/redis1/stats HTTP/1.1 920 921 **Example response**: 922 923 HTTP/1.1 200 OK 924 Content-Type: application/json 925 926 { 927 "read" : "2015-01-08T22:57:31.547920715Z", 928 "pids_stats": { 929 "current": 3 930 }, 931 "networks": { 932 "eth0": { 933 "rx_bytes": 5338, 934 "rx_dropped": 0, 935 "rx_errors": 0, 936 "rx_packets": 36, 937 "tx_bytes": 648, 938 "tx_dropped": 0, 939 "tx_errors": 0, 940 "tx_packets": 8 941 }, 942 "eth5": { 943 "rx_bytes": 4641, 944 "rx_dropped": 0, 945 "rx_errors": 0, 946 "rx_packets": 26, 947 "tx_bytes": 690, 948 "tx_dropped": 0, 949 "tx_errors": 0, 950 "tx_packets": 9 951 } 952 }, 953 "memory_stats" : { 954 "stats" : { 955 "total_pgmajfault" : 0, 956 "cache" : 0, 957 "mapped_file" : 0, 958 "total_inactive_file" : 0, 959 "pgpgout" : 414, 960 "rss" : 6537216, 961 "total_mapped_file" : 0, 962 "writeback" : 0, 963 "unevictable" : 0, 964 "pgpgin" : 477, 965 "total_unevictable" : 0, 966 "pgmajfault" : 0, 967 "total_rss" : 6537216, 968 "total_rss_huge" : 6291456, 969 "total_writeback" : 0, 970 "total_inactive_anon" : 0, 971 "rss_huge" : 6291456, 972 "hierarchical_memory_limit" : 67108864, 973 "total_pgfault" : 964, 974 "total_active_file" : 0, 975 "active_anon" : 6537216, 976 "total_active_anon" : 6537216, 977 "total_pgpgout" : 414, 978 "total_cache" : 0, 979 "inactive_anon" : 0, 980 "active_file" : 0, 981 "pgfault" : 964, 982 "inactive_file" : 0, 983 "total_pgpgin" : 477 984 }, 985 "max_usage" : 6651904, 986 "usage" : 6537216, 987 "failcnt" : 0, 988 "limit" : 67108864 989 }, 990 "blkio_stats" : {}, 991 "cpu_stats" : { 992 "cpu_usage" : { 993 "percpu_usage" : [ 994 8646879, 995 24472255, 996 36438778, 997 30657443 998 ], 999 "usage_in_usermode" : 50000000, 1000 "total_usage" : 100215355, 1001 "usage_in_kernelmode" : 30000000 1002 }, 1003 "system_cpu_usage" : 739306590000000, 1004 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0} 1005 }, 1006 "precpu_stats" : { 1007 "cpu_usage" : { 1008 "percpu_usage" : [ 1009 8646879, 1010 24350896, 1011 36438778, 1012 30657443 1013 ], 1014 "usage_in_usermode" : 50000000, 1015 "total_usage" : 100093996, 1016 "usage_in_kernelmode" : 30000000 1017 }, 1018 "system_cpu_usage" : 9492140000000, 1019 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0} 1020 } 1021 } 1022 1023 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. 1024 1025 **Query parameters**: 1026 1027 - **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`. 1028 1029 **Status codes**: 1030 1031 - **200** – no error 1032 - **404** – no such container 1033 - **500** – server error 1034 1035 #### Resize a container TTY 1036 1037 `POST /containers/(id or name)/resize` 1038 1039 Resize the TTY for container with `id`. The unit is number of characters. You must restart the container for the resize to take effect. 1040 1041 **Example request**: 1042 1043 POST /v1.24/containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1 1044 1045 **Example response**: 1046 1047 HTTP/1.1 200 OK 1048 Content-Length: 0 1049 Content-Type: text/plain; charset=utf-8 1050 1051 **Query parameters**: 1052 1053 - **h** – height of `tty` session 1054 - **w** – width 1055 1056 **Status codes**: 1057 1058 - **200** – no error 1059 - **404** – No such container 1060 - **500** – Cannot resize container 1061 1062 #### Start a container 1063 1064 `POST /containers/(id or name)/start` 1065 1066 Start the container `id` 1067 1068 **Example request**: 1069 1070 POST /v1.24/containers/e90e34656806/start HTTP/1.1 1071 1072 **Example response**: 1073 1074 HTTP/1.1 204 No Content 1075 1076 **Query parameters**: 1077 1078 - **detachKeys** – Override the key sequence for detaching a 1079 container. Format is a single character `[a-Z]` or `ctrl-<value>` 1080 where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 1081 1082 **Status codes**: 1083 1084 - **204** – no error 1085 - **304** – container already started 1086 - **404** – no such container 1087 - **500** – server error 1088 1089 #### Stop a container 1090 1091 `POST /containers/(id or name)/stop` 1092 1093 Stop the container `id` 1094 1095 **Example request**: 1096 1097 POST /v1.24/containers/e90e34656806/stop?t=5 HTTP/1.1 1098 1099 **Example response**: 1100 1101 HTTP/1.1 204 No Content 1102 1103 **Query parameters**: 1104 1105 - **t** – number of seconds to wait before killing the container 1106 1107 **Status codes**: 1108 1109 - **204** – no error 1110 - **304** – container already stopped 1111 - **404** – no such container 1112 - **500** – server error 1113 1114 #### Restart a container 1115 1116 `POST /containers/(id or name)/restart` 1117 1118 Restart the container `id` 1119 1120 **Example request**: 1121 1122 POST /v1.24/containers/e90e34656806/restart?t=5 HTTP/1.1 1123 1124 **Example response**: 1125 1126 HTTP/1.1 204 No Content 1127 1128 **Query parameters**: 1129 1130 - **t** – number of seconds to wait before killing the container 1131 1132 **Status codes**: 1133 1134 - **204** – no error 1135 - **404** – no such container 1136 - **500** – server error 1137 1138 #### Kill a container 1139 1140 `POST /containers/(id or name)/kill` 1141 1142 Kill the container `id` 1143 1144 **Example request**: 1145 1146 POST /v1.24/containers/e90e34656806/kill HTTP/1.1 1147 1148 **Example response**: 1149 1150 HTTP/1.1 204 No Content 1151 1152 **Query parameters**: 1153 1154 - **signal** - Signal to send to the container: integer or string like `SIGINT`. 1155 When not set, `SIGKILL` is assumed and the call waits for the container to exit. 1156 1157 **Status codes**: 1158 1159 - **204** – no error 1160 - **404** – no such container 1161 - **500** – server error 1162 1163 #### Update a container 1164 1165 `POST /containers/(id or name)/update` 1166 1167 Update configuration of one or more containers. 1168 1169 **Example request**: 1170 1171 POST /v1.24/containers/e90e34656806/update HTTP/1.1 1172 Content-Type: application/json 1173 1174 { 1175 "BlkioWeight": 300, 1176 "CpuShares": 512, 1177 "CpuPeriod": 100000, 1178 "CpuQuota": 50000, 1179 "CpusetCpus": "0,1", 1180 "CpusetMems": "0", 1181 "Memory": 314572800, 1182 "MemorySwap": 514288000, 1183 "MemoryReservation": 209715200, 1184 "KernelMemory": 52428800, 1185 "RestartPolicy": { 1186 "MaximumRetryCount": 4, 1187 "Name": "on-failure" 1188 } 1189 } 1190 1191 **Example response**: 1192 1193 HTTP/1.1 200 OK 1194 Content-Type: application/json 1195 1196 { 1197 "Warnings": [] 1198 } 1199 1200 **Status codes**: 1201 1202 - **200** – no error 1203 - **400** – bad parameter 1204 - **404** – no such container 1205 - **500** – server error 1206 1207 #### Rename a container 1208 1209 `POST /containers/(id or name)/rename` 1210 1211 Rename the container `id` to a `new_name` 1212 1213 **Example request**: 1214 1215 POST /v1.24/containers/e90e34656806/rename?name=new_name HTTP/1.1 1216 1217 **Example response**: 1218 1219 HTTP/1.1 204 No Content 1220 1221 **Query parameters**: 1222 1223 - **name** – new name for the container 1224 1225 **Status codes**: 1226 1227 - **204** – no error 1228 - **404** – no such container 1229 - **409** - conflict name already assigned 1230 - **500** – server error 1231 1232 #### Pause a container 1233 1234 `POST /containers/(id or name)/pause` 1235 1236 Pause the container `id` 1237 1238 **Example request**: 1239 1240 POST /v1.24/containers/e90e34656806/pause HTTP/1.1 1241 1242 **Example response**: 1243 1244 HTTP/1.1 204 No Content 1245 1246 **Status codes**: 1247 1248 - **204** – no error 1249 - **404** – no such container 1250 - **500** – server error 1251 1252 #### Unpause a container 1253 1254 `POST /containers/(id or name)/unpause` 1255 1256 Unpause the container `id` 1257 1258 **Example request**: 1259 1260 POST /v1.24/containers/e90e34656806/unpause HTTP/1.1 1261 1262 **Example response**: 1263 1264 HTTP/1.1 204 No Content 1265 1266 **Status codes**: 1267 1268 - **204** – no error 1269 - **404** – no such container 1270 - **500** – server error 1271 1272 #### Attach to a container 1273 1274 `POST /containers/(id or name)/attach` 1275 1276 Attach to the container `id` 1277 1278 **Example request**: 1279 1280 POST /v1.24/containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1 1281 1282 **Example response**: 1283 1284 HTTP/1.1 101 UPGRADED 1285 Content-Type: application/vnd.docker.raw-stream 1286 Connection: Upgrade 1287 Upgrade: tcp 1288 1289 {% raw %} 1290 {{ STREAM }} 1291 {% endraw %} 1292 1293 **Query parameters**: 1294 1295 - **detachKeys** – Override the key sequence for detaching a 1296 container. Format is a single character `[a-Z]` or `ctrl-<value>` 1297 where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 1298 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`. 1299 - **stream** – 1/True/true or 0/False/false, return stream. 1300 Default `false`. 1301 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach 1302 to `stdin`. Default `false`. 1303 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return 1304 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`. 1305 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return 1306 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`. 1307 1308 **Status codes**: 1309 1310 - **101** – no error, hints proxy about hijacking 1311 - **200** – no error, no upgrade header found 1312 - **400** – bad parameter 1313 - **404** – no such container 1314 - **409** - container is paused 1315 - **500** – server error 1316 1317 **Stream details**: 1318 1319 When using the TTY setting is enabled in 1320 [`POST /containers/create` 1321 ](#create-a-container), 1322 the stream is the raw data from the process PTY and client's `stdin`. 1323 When the TTY is disabled, then the stream is multiplexed to separate 1324 `stdout` and `stderr`. 1325 1326 The format is a **Header** and a **Payload** (frame). 1327 1328 **HEADER** 1329 1330 The header contains the information which the stream writes (`stdout` or 1331 `stderr`). It also contains the size of the associated frame encoded in the 1332 last four bytes (`uint32`). 1333 1334 It is encoded on the first eight bytes like this: 1335 1336 header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} 1337 1338 `STREAM_TYPE` can be: 1339 1340 - 0: `stdin` (is written on `stdout`) 1341 - 1: `stdout` 1342 - 2: `stderr` 1343 1344 `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of 1345 the `uint32` size encoded as big endian. 1346 1347 **PAYLOAD** 1348 1349 The payload is the raw stream. 1350 1351 **IMPLEMENTATION** 1352 1353 The simplest way to implement the Attach protocol is the following: 1354 1355 1. Read eight bytes. 1356 2. Choose `stdout` or `stderr` depending on the first byte. 1357 3. Extract the frame size from the last four bytes. 1358 4. Read the extracted size and output it on the correct output. 1359 5. Goto 1. 1360 1361 #### Attach to a container (websocket) 1362 1363 `GET /containers/(id or name)/attach/ws` 1364 1365 Attach to the container `id` via websocket 1366 1367 Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455) 1368 1369 **Example request** 1370 1371 GET /v1.24/containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1 1372 1373 **Example response** 1374 1375 {% raw %} 1376 {{ STREAM }} 1377 {% endraw %} 1378 1379 **Query parameters**: 1380 1381 - **detachKeys** – Override the key sequence for detaching a 1382 container. Format is a single character `[a-Z]` or `ctrl-<value>` 1383 where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 1384 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`. 1385 - **stream** – 1/True/true or 0/False/false, return stream. 1386 Default `false`. 1387 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach 1388 to `stdin`. Default `false`. 1389 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return 1390 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`. 1391 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return 1392 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`. 1393 1394 **Status codes**: 1395 1396 - **200** – no error 1397 - **400** – bad parameter 1398 - **404** – no such container 1399 - **500** – server error 1400 1401 #### Wait a container 1402 1403 `POST /containers/(id or name)/wait` 1404 1405 Block until container `id` stops, then returns the exit code 1406 1407 **Example request**: 1408 1409 POST /v1.24/containers/16253994b7c4/wait HTTP/1.1 1410 1411 **Example response**: 1412 1413 HTTP/1.1 200 OK 1414 Content-Type: application/json 1415 1416 {"StatusCode": 0} 1417 1418 **Status codes**: 1419 1420 - **200** – no error 1421 - **404** – no such container 1422 - **500** – server error 1423 1424 #### Remove a container 1425 1426 `DELETE /containers/(id or name)` 1427 1428 Remove the container `id` from the filesystem 1429 1430 **Example request**: 1431 1432 DELETE /v1.24/containers/16253994b7c4?v=1 HTTP/1.1 1433 1434 **Example response**: 1435 1436 HTTP/1.1 204 No Content 1437 1438 **Query parameters**: 1439 1440 - **v** – 1/True/true or 0/False/false, Remove the volumes 1441 associated to the container. Default `false`. 1442 - **force** - 1/True/true or 0/False/false, Kill then remove the container. 1443 Default `false`. 1444 - **link** - 1/True/true or 0/False/false, Remove the specified 1445 link associated to the container. Default `false`. 1446 1447 **Status codes**: 1448 1449 - **204** – no error 1450 - **400** – bad parameter 1451 - **404** – no such container 1452 - **409** – conflict 1453 - **500** – server error 1454 1455 #### Retrieving information about files and folders in a container 1456 1457 `HEAD /containers/(id or name)/archive` 1458 1459 See the description of the `X-Docker-Container-Path-Stat` header in the 1460 following section. 1461 1462 #### Get an archive of a filesystem resource in a container 1463 1464 `GET /containers/(id or name)/archive` 1465 1466 Get a tar archive of a resource in the filesystem of container `id`. 1467 1468 **Query parameters**: 1469 1470 - **path** - resource in the container's filesystem to archive. Required. 1471 1472 If not an absolute path, it is relative to the container's root directory. 1473 The resource specified by **path** must exist. To assert that the resource 1474 is expected to be a directory, **path** should end in `/` or `/.` 1475 (assuming a path separator of `/`). If **path** ends in `/.` then this 1476 indicates that only the contents of the **path** directory should be 1477 copied. A symlink is always resolved to its target. 1478 1479 > **Note**: It is not possible to copy certain system files such as resources 1480 > under `/proc`, `/sys`, `/dev`, and mounts created by the user in the 1481 > container. 1482 1483 **Example request**: 1484 1485 GET /v1.24/containers/8cce319429b2/archive?path=/root HTTP/1.1 1486 1487 **Example response**: 1488 1489 HTTP/1.1 200 OK 1490 Content-Type: application/x-tar 1491 X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= 1492 1493 {% raw %} 1494 {{ TAR STREAM }} 1495 {% endraw %} 1496 1497 On success, a response header `X-Docker-Container-Path-Stat` will be set to a 1498 base64-encoded JSON object containing some filesystem header information about 1499 the archived resource. The above example value would decode to the following 1500 JSON object (whitespace added for readability): 1501 1502 ```json 1503 { 1504 "name": "root", 1505 "size": 4096, 1506 "mode": 2147484096, 1507 "mtime": "2014-02-27T20:51:23Z", 1508 "linkTarget": "" 1509 } 1510 ``` 1511 1512 A `HEAD` request can also be made to this endpoint if only this information is 1513 desired. 1514 1515 **Status codes**: 1516 1517 - **200** - success, returns archive of copied resource 1518 - **400** - client error, bad parameter, details in JSON response body, one of: 1519 - must specify path parameter (**path** cannot be empty) 1520 - not a directory (**path** was asserted to be a directory but exists as a 1521 file) 1522 - **404** - client error, resource not found, one of: 1523 – no such container (container `id` does not exist) 1524 - no such file or directory (**path** does not exist) 1525 - **500** - server error 1526 1527 #### Extract an archive of files or folders to a directory in a container 1528 1529 `PUT /containers/(id or name)/archive` 1530 1531 Upload a tar archive to be extracted to a path in the filesystem of container 1532 `id`. 1533 1534 **Query parameters**: 1535 1536 - **path** - path to a directory in the container 1537 to extract the archive's contents into. Required. 1538 1539 If not an absolute path, it is relative to the container's root directory. 1540 The **path** resource must exist. 1541 - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error 1542 if unpacking the given content would cause an existing directory to be 1543 replaced with a non-directory and vice versa. 1544 1545 **Example request**: 1546 1547 PUT /v1.24/containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 1548 Content-Type: application/x-tar 1549 1550 {% raw %} 1551 {{ TAR STREAM }} 1552 {% endraw %} 1553 1554 **Example response**: 1555 1556 HTTP/1.1 200 OK 1557 1558 **Status codes**: 1559 1560 - **200** – the content was extracted successfully 1561 - **400** - client error, bad parameter, details in JSON response body, one of: 1562 - must specify path parameter (**path** cannot be empty) 1563 - not a directory (**path** should be a directory but exists as a file) 1564 - unable to overwrite existing directory with non-directory 1565 (if **noOverwriteDirNonDir**) 1566 - unable to overwrite existing non-directory with directory 1567 (if **noOverwriteDirNonDir**) 1568 - **403** - client error, permission denied, the volume 1569 or container rootfs is marked as read-only. 1570 - **404** - client error, resource not found, one of: 1571 – no such container (container `id` does not exist) 1572 - no such file or directory (**path** resource does not exist) 1573 - **500** – server error 1574 1575 ### 3.2 Images 1576 1577 #### List Images 1578 1579 `GET /images/json` 1580 1581 **Example request**: 1582 1583 GET /v1.24/images/json?all=0 HTTP/1.1 1584 1585 **Example response**: 1586 1587 HTTP/1.1 200 OK 1588 Content-Type: application/json 1589 1590 [ 1591 { 1592 "RepoTags": [ 1593 "ubuntu:12.04", 1594 "ubuntu:precise", 1595 "ubuntu:latest" 1596 ], 1597 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 1598 "Created": 1365714795, 1599 "Size": 131506275, 1600 "VirtualSize": 131506275, 1601 "Labels": {} 1602 }, 1603 { 1604 "RepoTags": [ 1605 "ubuntu:12.10", 1606 "ubuntu:quantal" 1607 ], 1608 "ParentId": "27cf784147099545", 1609 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1610 "Created": 1364102658, 1611 "Size": 24653, 1612 "VirtualSize": 180116135, 1613 "Labels": { 1614 "com.example.version": "v1" 1615 } 1616 } 1617 ] 1618 1619 **Example request, with digest information**: 1620 1621 GET /v1.24/images/json?digests=1 HTTP/1.1 1622 1623 **Example response, with digest information**: 1624 1625 HTTP/1.1 200 OK 1626 Content-Type: application/json 1627 1628 [ 1629 { 1630 "Created": 1420064636, 1631 "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125", 1632 "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2", 1633 "RepoDigests": [ 1634 "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" 1635 ], 1636 "RepoTags": [ 1637 "localhost:5000/test/busybox:latest", 1638 "playdate:latest" 1639 ], 1640 "Size": 0, 1641 "VirtualSize": 2429728, 1642 "Labels": {} 1643 } 1644 ] 1645 1646 The response shows a single image `Id` associated with two repositories 1647 (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use 1648 either of the `RepoTags` values `localhost:5000/test/busybox:latest` or 1649 `playdate:latest` to reference the image. 1650 1651 You can also use `RepoDigests` values to reference an image. In this response, 1652 the array has only one reference and that is to the 1653 `localhost:5000/test/busybox` repository; the `playdate` repository has no 1654 digest. You can reference this digest using the value: 1655 `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...` 1656 1657 See the `docker run` and `docker build` commands for examples of digest and tag 1658 references on the command line. 1659 1660 **Query parameters**: 1661 1662 - **all** – 1/True/true or 0/False/false, default false 1663 - **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters: 1664 - `dangling=true` 1665 - `label=key` or `label="key=value"` of an image label 1666 - `before`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) 1667 - `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) 1668 - **filter** - only return images with the specified name 1669 1670 #### Build image from a Dockerfile 1671 1672 `POST /build` 1673 1674 Build an image from a Dockerfile 1675 1676 **Example request**: 1677 1678 POST /v1.24/build HTTP/1.1 1679 Content-Type: application/x-tar 1680 1681 {% raw %} 1682 {{ TAR STREAM }} 1683 {% endraw %} 1684 1685 **Example response**: 1686 1687 HTTP/1.1 200 OK 1688 Content-Type: application/json 1689 1690 {"stream": "Step 1/5..."} 1691 {"stream": "..."} 1692 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 1693 1694 The input stream must be a `tar` archive compressed with one of the 1695 following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`. 1696 1697 The archive must include a build instructions file, typically called 1698 `Dockerfile` at the archive's root. The `dockerfile` parameter may be 1699 used to specify a different build instructions file. To do this, its value must be 1700 the path to the alternate build instructions file to use. 1701 1702 The archive may include any number of other files, 1703 which are accessible in the build context (See the [*ADD build 1704 command*](../reference/builder.md#add)). 1705 1706 The Docker daemon performs a preliminary validation of the `Dockerfile` before 1707 starting the build, and returns an error if the syntax is incorrect. After that, 1708 each instruction is run one-by-one until the ID of the new image is output. 1709 1710 The build is canceled if the client drops the connection by quitting 1711 or being killed. 1712 1713 **Query parameters**: 1714 1715 - **dockerfile** - Path within the build context to the `Dockerfile`. This is 1716 ignored if `remote` is specified and points to an external `Dockerfile`. 1717 - **t** – A name and optional tag to apply to the image in the `name:tag` format. 1718 If you omit the `tag` the default `latest` value is assumed. 1719 You can provide one or more `t` parameters. 1720 - **remote** – A Git repository URI or HTTP/HTTPS context URI. If the 1721 URI points to a single text file, the file's contents are placed into 1722 a file called `Dockerfile` and the image is built from that file. If 1723 the URI points to a tarball, the file is downloaded by the daemon and 1724 the contents therein used as the context for the build. If the URI 1725 points to a tarball and the `dockerfile` parameter is also specified, 1726 there must be a file with the corresponding path inside the tarball. 1727 - **q** – Suppress verbose build output. 1728 - **nocache** – Do not use the cache when building the image. 1729 - **pull** - Attempt to pull the image even if an older image exists locally. 1730 - **rm** - Remove intermediate containers after a successful build (default behavior). 1731 - **forcerm** - Always remove intermediate containers (includes `rm`). 1732 - **memory** - Set memory limit for build. 1733 - **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap. 1734 - **cpushares** - CPU shares (relative weight). 1735 - **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`). 1736 - **cpuperiod** - The length of a CPU period in microseconds. 1737 - **cpuquota** - Microseconds of CPU time that the container can get in a CPU period. 1738 - **buildargs** – JSON map of string pairs for build-time variables. Users pass 1739 these values at build-time. Docker uses the `buildargs` as the environment 1740 context for command(s) run via the Dockerfile's `RUN` instruction or for 1741 variable expansion in other Dockerfile instructions. This is not meant for 1742 passing secret values. [Read more about the buildargs instruction](../reference/builder.md#arg) 1743 - **shmsize** - Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB. 1744 - **labels** – JSON map of string pairs for labels to set on the image. 1745 1746 **Request Headers**: 1747 1748 - **Content-type** – Set to `"application/x-tar"`. 1749 - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON 1750 object with the following structure: 1751 1752 { 1753 "docker.example.com": { 1754 "username": "janedoe", 1755 "password": "hunter2" 1756 }, 1757 "https://index.docker.io/v1/": { 1758 "username": "mobydock", 1759 "password": "conta1n3rize14" 1760 } 1761 } 1762 1763 This object maps the hostname of a registry to an object containing the 1764 "username" and "password" for that registry. Multiple registries may 1765 be specified as the build may be based on an image requiring 1766 authentication to pull from any arbitrary registry. Only the registry 1767 domain name (and port if not the default "443") are required. However 1768 (for legacy reasons) the "official" Docker, Inc. hosted registry must 1769 be specified with both a "https://" prefix and a "/v1/" suffix even 1770 though Docker will prefer to use the v2 registry API. 1771 1772 **Status codes**: 1773 1774 - **200** – no error 1775 - **500** – server error 1776 1777 #### Create an image 1778 1779 `POST /images/create` 1780 1781 Create an image either by pulling it from the registry or by importing it 1782 1783 **Example request**: 1784 1785 POST /v1.24/images/create?fromImage=busybox&tag=latest HTTP/1.1 1786 1787 **Example response**: 1788 1789 HTTP/1.1 200 OK 1790 Content-Type: application/json 1791 1792 {"status": "Pulling..."} 1793 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 1794 {"error": "Invalid..."} 1795 ... 1796 1797 When using this endpoint to pull an image from the registry, the 1798 `X-Registry-Auth` header can be used to include 1799 a base64-encoded AuthConfig object. 1800 1801 **Query parameters**: 1802 1803 - **fromImage** – Name of the image to pull. The name may include a tag or 1804 digest. This parameter may only be used when pulling an image. 1805 The pull is cancelled if the HTTP connection is closed. 1806 - **fromSrc** – Source to import. The value may be a URL from which the image 1807 can be retrieved or `-` to read the image from the request body. 1808 This parameter may only be used when importing an image. 1809 - **repo** – Repository name given to an image when it is imported. 1810 The repo may include a tag. This parameter may only be used when importing 1811 an image. 1812 - **tag** – Tag or digest. If empty when pulling an image, this causes all tags 1813 for the given image to be pulled. 1814 1815 **Request Headers**: 1816 1817 - **X-Registry-Auth** – base64-encoded AuthConfig object, containing either login information, or a token 1818 - Credential based login: 1819 1820 ``` 1821 { 1822 "username": "jdoe", 1823 "password": "secret", 1824 "email": "jdoe@acme.com" 1825 } 1826 ``` 1827 1828 - Token based login: 1829 1830 ``` 1831 { 1832 "identitytoken": "9cbaf023786cd7..." 1833 } 1834 ``` 1835 1836 **Status codes**: 1837 1838 - **200** – no error 1839 - **404** - repository does not exist or no read access 1840 - **500** – server error 1841 1842 1843 1844 #### Inspect an image 1845 1846 `GET /images/(name)/json` 1847 1848 Return low-level information on the image `name` 1849 1850 **Example request**: 1851 1852 GET /v1.24/images/example/json HTTP/1.1 1853 1854 **Example response**: 1855 1856 HTTP/1.1 200 OK 1857 Content-Type: application/json 1858 1859 { 1860 "Id" : "sha256:85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c", 1861 "Container" : "cb91e48a60d01f1e27028b4fc6819f4f290b3cf12496c8176ec714d0d390984a", 1862 "Comment" : "", 1863 "Os" : "linux", 1864 "Architecture" : "amd64", 1865 "Parent" : "sha256:91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c", 1866 "ContainerConfig" : { 1867 "Tty" : false, 1868 "Hostname" : "e611e15f9c9d", 1869 "Volumes" : null, 1870 "Domainname" : "", 1871 "AttachStdout" : false, 1872 "PublishService" : "", 1873 "AttachStdin" : false, 1874 "OpenStdin" : false, 1875 "StdinOnce" : false, 1876 "NetworkDisabled" : false, 1877 "OnBuild" : [], 1878 "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c", 1879 "User" : "", 1880 "WorkingDir" : "", 1881 "Entrypoint" : null, 1882 "MacAddress" : "", 1883 "AttachStderr" : false, 1884 "Labels" : { 1885 "com.example.license" : "GPL", 1886 "com.example.version" : "1.0", 1887 "com.example.vendor" : "Acme" 1888 }, 1889 "Env" : [ 1890 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 1891 ], 1892 "ExposedPorts" : null, 1893 "Cmd" : [ 1894 "/bin/sh", 1895 "-c", 1896 "#(nop) LABEL com.example.vendor=Acme com.example.license=GPL com.example.version=1.0" 1897 ] 1898 }, 1899 "DockerVersion" : "1.9.0-dev", 1900 "VirtualSize" : 188359297, 1901 "Size" : 0, 1902 "Author" : "", 1903 "Created" : "2015-09-10T08:30:53.26995814Z", 1904 "GraphDriver" : { 1905 "Name" : "aufs", 1906 "Data" : null 1907 }, 1908 "RepoDigests" : [ 1909 "localhost:5000/test/busybox/example@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" 1910 ], 1911 "RepoTags" : [ 1912 "example:1.0", 1913 "example:latest", 1914 "example:stable" 1915 ], 1916 "Config" : { 1917 "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c", 1918 "NetworkDisabled" : false, 1919 "OnBuild" : [], 1920 "StdinOnce" : false, 1921 "PublishService" : "", 1922 "AttachStdin" : false, 1923 "OpenStdin" : false, 1924 "Domainname" : "", 1925 "AttachStdout" : false, 1926 "Tty" : false, 1927 "Hostname" : "e611e15f9c9d", 1928 "Volumes" : null, 1929 "Cmd" : [ 1930 "/bin/bash" 1931 ], 1932 "ExposedPorts" : null, 1933 "Env" : [ 1934 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 1935 ], 1936 "Labels" : { 1937 "com.example.vendor" : "Acme", 1938 "com.example.version" : "1.0", 1939 "com.example.license" : "GPL" 1940 }, 1941 "Entrypoint" : null, 1942 "MacAddress" : "", 1943 "AttachStderr" : false, 1944 "WorkingDir" : "", 1945 "User" : "" 1946 }, 1947 "RootFS": { 1948 "Type": "layers", 1949 "Layers": [ 1950 "sha256:1834950e52ce4d5a88a1bbd131c537f4d0e56d10ff0dd69e66be3b7dfa9df7e6", 1951 "sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef" 1952 ] 1953 } 1954 } 1955 1956 **Status codes**: 1957 1958 - **200** – no error 1959 - **404** – no such image 1960 - **500** – server error 1961 1962 #### Get the history of an image 1963 1964 `GET /images/(name)/history` 1965 1966 Return the history of the image `name` 1967 1968 **Example request**: 1969 1970 GET /v1.24/images/ubuntu/history HTTP/1.1 1971 1972 **Example response**: 1973 1974 HTTP/1.1 200 OK 1975 Content-Type: application/json 1976 1977 [ 1978 { 1979 "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710", 1980 "Created": 1398108230, 1981 "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /", 1982 "Tags": [ 1983 "ubuntu:lucid", 1984 "ubuntu:10.04" 1985 ], 1986 "Size": 182964289, 1987 "Comment": "" 1988 }, 1989 { 1990 "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8", 1991 "Created": 1398108222, 1992 "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/", 1993 "Tags": null, 1994 "Size": 0, 1995 "Comment": "" 1996 }, 1997 { 1998 "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158", 1999 "Created": 1371157430, 2000 "CreatedBy": "", 2001 "Tags": [ 2002 "scratch12:latest", 2003 "scratch:latest" 2004 ], 2005 "Size": 0, 2006 "Comment": "Imported from -" 2007 } 2008 ] 2009 2010 **Status codes**: 2011 2012 - **200** – no error 2013 - **404** – no such image 2014 - **500** – server error 2015 2016 #### Push an image on the registry 2017 2018 `POST /images/(name)/push` 2019 2020 Push the image `name` on the registry 2021 2022 **Example request**: 2023 2024 POST /v1.24/images/test/push HTTP/1.1 2025 2026 **Example response**: 2027 2028 HTTP/1.1 200 OK 2029 Content-Type: application/json 2030 2031 {"status": "Pushing..."} 2032 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 2033 {"error": "Invalid..."} 2034 ... 2035 2036 If you wish to push an image on to a private registry, that image must already have a tag 2037 into a repository which references that registry `hostname` and `port`. This repository name should 2038 then be used in the URL. This duplicates the command line's flow. 2039 2040 The push is cancelled if the HTTP connection is closed. 2041 2042 **Example request**: 2043 2044 POST /v1.24/images/registry.acme.com:5000/test/push HTTP/1.1 2045 2046 2047 **Query parameters**: 2048 2049 - **tag** – The tag to associate with the image on the registry. This is optional. 2050 2051 **Request Headers**: 2052 2053 - **X-Registry-Auth** – base64-encoded AuthConfig object, containing either login information, or a token 2054 - Credential based login: 2055 2056 ``` 2057 { 2058 "username": "jdoe", 2059 "password": "secret", 2060 "email": "jdoe@acme.com", 2061 } 2062 ``` 2063 2064 - Identity token based login: 2065 2066 ``` 2067 { 2068 "identitytoken": "9cbaf023786cd7..." 2069 } 2070 ``` 2071 2072 **Status codes**: 2073 2074 - **200** – no error 2075 - **404** – no such image 2076 - **500** – server error 2077 2078 #### Tag an image into a repository 2079 2080 `POST /images/(name)/tag` 2081 2082 Tag the image `name` into a repository 2083 2084 **Example request**: 2085 2086 POST /v1.24/images/test/tag?repo=myrepo&tag=v42 HTTP/1.1 2087 2088 **Example response**: 2089 2090 HTTP/1.1 201 Created 2091 2092 **Query parameters**: 2093 2094 - **repo** – The repository to tag in 2095 - **tag** - The new tag name 2096 2097 **Status codes**: 2098 2099 - **201** – no error 2100 - **400** – bad parameter 2101 - **404** – no such image 2102 - **409** – conflict 2103 - **500** – server error 2104 2105 #### Remove an image 2106 2107 `DELETE /images/(name)` 2108 2109 Remove the image `name` from the filesystem 2110 2111 **Example request**: 2112 2113 DELETE /v1.24/images/test HTTP/1.1 2114 2115 **Example response**: 2116 2117 HTTP/1.1 200 OK 2118 Content-type: application/json 2119 2120 [ 2121 {"Untagged": "3e2f21a89f"}, 2122 {"Deleted": "3e2f21a89f"}, 2123 {"Deleted": "53b4f83ac9"} 2124 ] 2125 2126 **Query parameters**: 2127 2128 - **force** – 1/True/true or 0/False/false, default false 2129 - **noprune** – 1/True/true or 0/False/false, default false 2130 2131 **Status codes**: 2132 2133 - **200** – no error 2134 - **404** – no such image 2135 - **409** – conflict 2136 - **500** – server error 2137 2138 #### Search images 2139 2140 `GET /images/search` 2141 2142 Search for an image on [Docker Hub](https://hub.docker.com). 2143 2144 > **Note**: 2145 > The response keys have changed from API v1.6 to reflect the JSON 2146 > sent by the registry server to the docker daemon's request. 2147 2148 **Example request**: 2149 2150 GET /v1.24/images/search?term=sshd HTTP/1.1 2151 2152 **Example response**: 2153 2154 HTTP/1.1 200 OK 2155 Content-Type: application/json 2156 2157 [ 2158 { 2159 "description": "", 2160 "is_official": false, 2161 "is_automated": false, 2162 "name": "wma55/u1210sshd", 2163 "star_count": 0 2164 }, 2165 { 2166 "description": "", 2167 "is_official": false, 2168 "is_automated": false, 2169 "name": "jdswinbank/sshd", 2170 "star_count": 0 2171 }, 2172 { 2173 "description": "", 2174 "is_official": false, 2175 "is_automated": false, 2176 "name": "vgauthier/sshd", 2177 "star_count": 0 2178 } 2179 ... 2180 ] 2181 2182 **Query parameters**: 2183 2184 - **term** – term to search 2185 - **limit** – maximum returned search results 2186 - **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters: 2187 - `stars=<number>` 2188 - `is-automated=(true|false)` 2189 - `is-official=(true|false)` 2190 2191 **Status codes**: 2192 2193 - **200** – no error 2194 - **500** – server error 2195 2196 ### 3.3 Misc 2197 2198 #### Check auth configuration 2199 2200 `POST /auth` 2201 2202 Validate credentials for a registry and get identity token, 2203 if available, for accessing the registry without password. 2204 2205 **Example request**: 2206 2207 POST /v1.24/auth HTTP/1.1 2208 Content-Type: application/json 2209 2210 { 2211 "username": "hannibal", 2212 "password": "xxxx", 2213 "serveraddress": "https://index.docker.io/v1/" 2214 } 2215 2216 **Example response**: 2217 2218 HTTP/1.1 200 OK 2219 2220 { 2221 "Status": "Login Succeeded", 2222 "IdentityToken": "9cbaf023786cd7..." 2223 } 2224 2225 **Status codes**: 2226 2227 - **200** – no error 2228 - **204** – no error 2229 - **500** – server error 2230 2231 #### Display system-wide information 2232 2233 `GET /info` 2234 2235 Display system-wide information 2236 2237 **Example request**: 2238 2239 GET /v1.24/info HTTP/1.1 2240 2241 **Example response**: 2242 2243 HTTP/1.1 200 OK 2244 Content-Type: application/json 2245 2246 { 2247 "Architecture": "x86_64", 2248 "ClusterStore": "etcd://localhost:2379", 2249 "CgroupDriver": "cgroupfs", 2250 "Containers": 11, 2251 "ContainersRunning": 7, 2252 "ContainersStopped": 3, 2253 "ContainersPaused": 1, 2254 "CpuCfsPeriod": true, 2255 "CpuCfsQuota": true, 2256 "Debug": false, 2257 "DockerRootDir": "/var/lib/docker", 2258 "Driver": "btrfs", 2259 "DriverStatus": [[""]], 2260 "ExperimentalBuild": false, 2261 "HttpProxy": "http://test:test@localhost:8080", 2262 "HttpsProxy": "https://test:test@localhost:8080", 2263 "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS", 2264 "IPv4Forwarding": true, 2265 "Images": 16, 2266 "IndexServerAddress": "https://index.docker.io/v1/", 2267 "InitPath": "/usr/bin/docker", 2268 "InitSha1": "", 2269 "KernelMemory": true, 2270 "KernelVersion": "3.12.0-1-amd64", 2271 "Labels": [ 2272 "storage=ssd" 2273 ], 2274 "MemTotal": 2099236864, 2275 "MemoryLimit": true, 2276 "NCPU": 1, 2277 "NEventsListener": 0, 2278 "NFd": 11, 2279 "NGoroutines": 21, 2280 "Name": "prod-server-42", 2281 "NoProxy": "9.81.1.160", 2282 "OomKillDisable": true, 2283 "OSType": "linux", 2284 "OperatingSystem": "Boot2Docker", 2285 "Plugins": { 2286 "Volume": [ 2287 "local" 2288 ], 2289 "Network": [ 2290 "null", 2291 "host", 2292 "bridge" 2293 ] 2294 }, 2295 "RegistryConfig": { 2296 "IndexConfigs": { 2297 "docker.io": { 2298 "Mirrors": null, 2299 "Name": "docker.io", 2300 "Official": true, 2301 "Secure": true 2302 } 2303 }, 2304 "InsecureRegistryCIDRs": [ 2305 "127.0.0.0/8" 2306 ] 2307 }, 2308 "SecurityOptions": [ 2309 "apparmor", 2310 "seccomp", 2311 "selinux" 2312 ], 2313 "ServerVersion": "1.9.0", 2314 "SwapLimit": false, 2315 "SystemStatus": [["State", "Healthy"]], 2316 "SystemTime": "2015-03-10T11:11:23.730591467-07:00" 2317 } 2318 2319 **Status codes**: 2320 2321 - **200** – no error 2322 - **500** – server error 2323 2324 #### Show the docker version information 2325 2326 `GET /version` 2327 2328 Show the docker version information 2329 2330 **Example request**: 2331 2332 GET /v1.24/version HTTP/1.1 2333 2334 **Example response**: 2335 2336 HTTP/1.1 200 OK 2337 Content-Type: application/json 2338 2339 { 2340 "Version": "1.12.0", 2341 "Os": "linux", 2342 "KernelVersion": "3.19.0-23-generic", 2343 "GoVersion": "go1.6.3", 2344 "GitCommit": "deadbee", 2345 "Arch": "amd64", 2346 "ApiVersion": "1.24", 2347 "BuildTime": "2016-06-14T07:09:13.444803460+00:00", 2348 "Experimental": true 2349 } 2350 2351 **Status codes**: 2352 2353 - **200** – no error 2354 - **500** – server error 2355 2356 #### Ping the docker server 2357 2358 `GET /_ping` 2359 2360 Ping the docker server 2361 2362 **Example request**: 2363 2364 GET /v1.24/_ping HTTP/1.1 2365 2366 **Example response**: 2367 2368 HTTP/1.1 200 OK 2369 Content-Type: text/plain 2370 2371 OK 2372 2373 **Status codes**: 2374 2375 - **200** - no error 2376 - **500** - server error 2377 2378 #### Create a new image from a container's changes 2379 2380 `POST /commit` 2381 2382 Create a new image from a container's changes 2383 2384 **Example request**: 2385 2386 POST /v1.24/commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1 2387 Content-Type: application/json 2388 2389 { 2390 "Hostname": "", 2391 "Domainname": "", 2392 "User": "", 2393 "AttachStdin": false, 2394 "AttachStdout": true, 2395 "AttachStderr": true, 2396 "Tty": false, 2397 "OpenStdin": false, 2398 "StdinOnce": false, 2399 "Env": null, 2400 "Cmd": [ 2401 "date" 2402 ], 2403 "Mounts": [ 2404 { 2405 "Source": "/data", 2406 "Destination": "/data", 2407 "Mode": "ro,Z", 2408 "RW": false 2409 } 2410 ], 2411 "Labels": { 2412 "key1": "value1", 2413 "key2": "value2" 2414 }, 2415 "WorkingDir": "", 2416 "NetworkDisabled": false, 2417 "ExposedPorts": { 2418 "22/tcp": {} 2419 } 2420 } 2421 2422 **Example response**: 2423 2424 HTTP/1.1 201 Created 2425 Content-Type: application/json 2426 2427 {"Id": "596069db4bf5"} 2428 2429 **JSON parameters**: 2430 2431 - **config** - the container's configuration 2432 2433 **Query parameters**: 2434 2435 - **container** – source container 2436 - **repo** – repository 2437 - **tag** – tag 2438 - **comment** – commit message 2439 - **author** – author (e.g., "John Hannibal Smith 2440 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 2441 - **pause** – 1/True/true or 0/False/false, whether to pause the container before committing 2442 - **changes** – Dockerfile instructions to apply while committing 2443 2444 **Status codes**: 2445 2446 - **201** – no error 2447 - **404** – no such container 2448 - **500** – server error 2449 2450 #### Monitor Docker's events 2451 2452 `GET /events` 2453 2454 Get container events from docker, in real time via streaming. 2455 2456 Docker containers report the following events: 2457 2458 attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, health_status, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update 2459 2460 Docker images report the following events: 2461 2462 delete, import, load, pull, push, save, tag, untag 2463 2464 Docker volumes report the following events: 2465 2466 create, mount, unmount, destroy 2467 2468 Docker networks report the following events: 2469 2470 create, connect, disconnect, destroy 2471 2472 Docker daemon report the following event: 2473 2474 reload 2475 2476 **Example request**: 2477 2478 GET /v1.24/events?since=1374067924 2479 2480 **Example response**: 2481 2482 HTTP/1.1 200 OK 2483 Content-Type: application/json 2484 Server: Docker/1.12.0 (linux) 2485 Date: Fri, 29 Apr 2016 15:18:06 GMT 2486 Transfer-Encoding: chunked 2487 2488 { 2489 "status": "pull", 2490 "id": "alpine:latest", 2491 "Type": "image", 2492 "Action": "pull", 2493 "Actor": { 2494 "ID": "alpine:latest", 2495 "Attributes": { 2496 "name": "alpine" 2497 } 2498 }, 2499 "time": 1461943101, 2500 "timeNano": 1461943101301854122 2501 } 2502 { 2503 "status": "create", 2504 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2505 "from": "alpine", 2506 "Type": "container", 2507 "Action": "create", 2508 "Actor": { 2509 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2510 "Attributes": { 2511 "com.example.some-label": "some-label-value", 2512 "image": "alpine", 2513 "name": "my-container" 2514 } 2515 }, 2516 "time": 1461943101, 2517 "timeNano": 1461943101381709551 2518 } 2519 { 2520 "status": "attach", 2521 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2522 "from": "alpine", 2523 "Type": "container", 2524 "Action": "attach", 2525 "Actor": { 2526 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2527 "Attributes": { 2528 "com.example.some-label": "some-label-value", 2529 "image": "alpine", 2530 "name": "my-container" 2531 } 2532 }, 2533 "time": 1461943101, 2534 "timeNano": 1461943101383858412 2535 } 2536 { 2537 "Type": "network", 2538 "Action": "connect", 2539 "Actor": { 2540 "ID": "7dc8ac97d5d29ef6c31b6052f3938c1e8f2749abbd17d1bd1febf2608db1b474", 2541 "Attributes": { 2542 "container": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2543 "name": "bridge", 2544 "type": "bridge" 2545 } 2546 }, 2547 "time": 1461943101, 2548 "timeNano": 1461943101394865557 2549 } 2550 { 2551 "status": "start", 2552 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2553 "from": "alpine", 2554 "Type": "container", 2555 "Action": "start", 2556 "Actor": { 2557 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2558 "Attributes": { 2559 "com.example.some-label": "some-label-value", 2560 "image": "alpine", 2561 "name": "my-container" 2562 } 2563 }, 2564 "time": 1461943101, 2565 "timeNano": 1461943101607533796 2566 } 2567 { 2568 "status": "resize", 2569 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2570 "from": "alpine", 2571 "Type": "container", 2572 "Action": "resize", 2573 "Actor": { 2574 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2575 "Attributes": { 2576 "com.example.some-label": "some-label-value", 2577 "height": "46", 2578 "image": "alpine", 2579 "name": "my-container", 2580 "width": "204" 2581 } 2582 }, 2583 "time": 1461943101, 2584 "timeNano": 1461943101610269268 2585 } 2586 { 2587 "status": "die", 2588 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2589 "from": "alpine", 2590 "Type": "container", 2591 "Action": "die", 2592 "Actor": { 2593 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2594 "Attributes": { 2595 "com.example.some-label": "some-label-value", 2596 "exitCode": "0", 2597 "image": "alpine", 2598 "name": "my-container" 2599 } 2600 }, 2601 "time": 1461943105, 2602 "timeNano": 1461943105079144137 2603 } 2604 { 2605 "Type": "network", 2606 "Action": "disconnect", 2607 "Actor": { 2608 "ID": "7dc8ac97d5d29ef6c31b6052f3938c1e8f2749abbd17d1bd1febf2608db1b474", 2609 "Attributes": { 2610 "container": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2611 "name": "bridge", 2612 "type": "bridge" 2613 } 2614 }, 2615 "time": 1461943105, 2616 "timeNano": 1461943105230860245 2617 } 2618 { 2619 "status": "destroy", 2620 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2621 "from": "alpine", 2622 "Type": "container", 2623 "Action": "destroy", 2624 "Actor": { 2625 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2626 "Attributes": { 2627 "com.example.some-label": "some-label-value", 2628 "image": "alpine", 2629 "name": "my-container" 2630 } 2631 }, 2632 "time": 1461943105, 2633 "timeNano": 1461943105338056026 2634 } 2635 2636 **Query parameters**: 2637 2638 - **since** – Timestamp. Show all events created since timestamp and then stream 2639 - **until** – Timestamp. Show events created until given timestamp and stop streaming 2640 - **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters: 2641 - `container=<string>`; -- container to filter 2642 - `event=<string>`; -- event to filter 2643 - `image=<string>`; -- image to filter 2644 - `label=<string>`; -- image and container label to filter 2645 - `type=<string>`; -- either `container` or `image` or `volume` or `network` or `daemon` 2646 - `volume=<string>`; -- volume to filter 2647 - `network=<string>`; -- network to filter 2648 - `daemon=<string>`; -- daemon name or id to filter 2649 2650 **Status codes**: 2651 2652 - **200** – no error 2653 - **400** - bad parameter 2654 - **500** – server error 2655 2656 #### Get a tarball containing all images in a repository 2657 2658 `GET /images/(name)/get` 2659 2660 Get a tarball containing all images and metadata for the repository specified 2661 by `name`. 2662 2663 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image 2664 (and its parents) are returned. If `name` is an image ID, similarly only that 2665 image (and its parents) are returned, but with the exclusion of the 2666 'repositories' file in the tarball, as there were no image names referenced. 2667 2668 See the [image tarball format](#image-tarball-format) for more details. 2669 2670 **Example request** 2671 2672 GET /v1.24/images/ubuntu/get 2673 2674 **Example response**: 2675 2676 HTTP/1.1 200 OK 2677 Content-Type: application/x-tar 2678 2679 Binary data stream 2680 2681 **Status codes**: 2682 2683 - **200** – no error 2684 - **500** – server error 2685 2686 #### Get a tarball containing all images 2687 2688 `GET /images/get` 2689 2690 Get a tarball containing all images and metadata for one or more repositories. 2691 2692 For each value of the `names` parameter: if it is a specific name and tag (e.g. 2693 `ubuntu:latest`), then only that image (and its parents) are returned; if it is 2694 an image ID, similarly only that image (and its parents) are returned and there 2695 would be no names referenced in the 'repositories' file for this image ID. 2696 2697 See the [image tarball format](#image-tarball-format) for more details. 2698 2699 **Example request** 2700 2701 GET /v1.24/images/get?names=myname%2Fmyapp%3Alatest&names=busybox 2702 2703 **Example response**: 2704 2705 HTTP/1.1 200 OK 2706 Content-Type: application/x-tar 2707 2708 Binary data stream 2709 2710 **Status codes**: 2711 2712 - **200** – no error 2713 - **500** – server error 2714 2715 #### Load a tarball with a set of images and tags into docker 2716 2717 `POST /images/load` 2718 2719 Load a set of images and tags into a Docker repository. 2720 See the [image tarball format](#image-tarball-format) for more details. 2721 2722 **Example request** 2723 2724 POST /v1.24/images/load 2725 Content-Type: application/x-tar 2726 2727 Tarball in body 2728 2729 **Example response**: 2730 2731 HTTP/1.1 200 OK 2732 Content-Type: application/json 2733 Transfer-Encoding: chunked 2734 2735 {"status":"Loading layer","progressDetail":{"current":32768,"total":1292800},"progress":"[= ] 32.77 kB/1.293 MB","id":"8ac8bfaff55a"} 2736 {"status":"Loading layer","progressDetail":{"current":65536,"total":1292800},"progress":"[== ] 65.54 kB/1.293 MB","id":"8ac8bfaff55a"} 2737 {"status":"Loading layer","progressDetail":{"current":98304,"total":1292800},"progress":"[=== ] 98.3 kB/1.293 MB","id":"8ac8bfaff55a"} 2738 {"status":"Loading layer","progressDetail":{"current":131072,"total":1292800},"progress":"[===== ] 131.1 kB/1.293 MB","id":"8ac8bfaff55a"} 2739 ... 2740 {"stream":"Loaded image: busybox:latest\n"} 2741 2742 **Example response**: 2743 2744 If the "quiet" query parameter is set to `true` / `1` (`?quiet=1`), progress 2745 details are suppressed, and only a confirmation message is returned once the 2746 action completes. 2747 2748 HTTP/1.1 200 OK 2749 Content-Type: application/json 2750 Transfer-Encoding: chunked 2751 2752 {"stream":"Loaded image: busybox:latest\n"} 2753 2754 **Query parameters**: 2755 2756 - **quiet** – Boolean value, suppress progress details during load. Defaults 2757 to `0` / `false` if omitted. 2758 2759 **Status codes**: 2760 2761 - **200** – no error 2762 - **500** – server error 2763 2764 #### Image tarball format 2765 2766 An image tarball contains one directory per image layer (named using its long ID), 2767 each containing these files: 2768 2769 - `VERSION`: currently `1.0` - the file format version 2770 - `json`: detailed layer information, similar to `docker inspect layer_id` 2771 - `layer.tar`: A tarfile containing the filesystem changes in this layer 2772 2773 The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories 2774 for storing attribute changes and deletions. 2775 2776 If the tarball defines a repository, the tarball should also include a `repositories` file at 2777 the root that contains a list of repository and tag names mapped to layer IDs. 2778 2779 ``` 2780 {"hello-world": 2781 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 2782 } 2783 ``` 2784 2785 #### Exec Create 2786 2787 `POST /containers/(id or name)/exec` 2788 2789 Sets up an exec instance in a running container `id` 2790 2791 **Example request**: 2792 2793 POST /v1.24/containers/e90e34656806/exec HTTP/1.1 2794 Content-Type: application/json 2795 2796 { 2797 "AttachStdin": true, 2798 "AttachStdout": true, 2799 "AttachStderr": true, 2800 "Cmd": ["sh"], 2801 "DetachKeys": "ctrl-p,ctrl-q", 2802 "Privileged": true, 2803 "Tty": true, 2804 "User": "123:456" 2805 } 2806 2807 **Example response**: 2808 2809 HTTP/1.1 201 Created 2810 Content-Type: application/json 2811 2812 { 2813 "Id": "f90e34656806", 2814 "Warnings":[] 2815 } 2816 2817 **JSON parameters**: 2818 2819 - **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command. 2820 - **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command. 2821 - **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command. 2822 - **DetachKeys** – Override the key sequence for detaching a 2823 container. Format is a single character `[a-Z]` or `ctrl-<value>` 2824 where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 2825 - **Tty** - Boolean value to allocate a pseudo-TTY. 2826 - **Cmd** - Command to run specified as a string or an array of strings. 2827 - **Privileged** - Boolean value, runs the exec process with extended privileges. 2828 - **User** - A string value specifying the user, and optionally, group to run 2829 the exec process inside the container. Format is one of: `"user"`, 2830 `"user:group"`, `"uid"`, or `"uid:gid"`. 2831 2832 **Status codes**: 2833 2834 - **201** – no error 2835 - **404** – no such container 2836 - **409** - container is paused 2837 - **500** - server error 2838 2839 #### Exec Start 2840 2841 `POST /exec/(id)/start` 2842 2843 Starts a previously set up `exec` instance `id`. If `detach` is true, this API 2844 returns after starting the `exec` command. Otherwise, this API sets up an 2845 interactive session with the `exec` command. 2846 2847 **Example request**: 2848 2849 POST /v1.24/exec/e90e34656806/start HTTP/1.1 2850 Content-Type: application/json 2851 2852 { 2853 "Detach": false, 2854 "Tty": false 2855 } 2856 2857 **Example response**: 2858 2859 HTTP/1.1 200 OK 2860 Content-Type: application/vnd.docker.raw-stream 2861 2862 {% raw %} 2863 {{ STREAM }} 2864 {% endraw %} 2865 2866 **JSON parameters**: 2867 2868 - **Detach** - Detach from the `exec` command. 2869 - **Tty** - Boolean value to allocate a pseudo-TTY. 2870 2871 **Status codes**: 2872 2873 - **200** – no error 2874 - **404** – no such exec instance 2875 - **409** - container is paused 2876 2877 **Stream details**: 2878 2879 Similar to the stream behavior of `POST /containers/(id or name)/attach` API 2880 2881 #### Exec Resize 2882 2883 `POST /exec/(id)/resize` 2884 2885 Resizes the `tty` session used by the `exec` command `id`. The unit is number of characters. 2886 This API is valid only if `tty` was specified as part of creating and starting the `exec` command. 2887 2888 **Example request**: 2889 2890 POST /v1.24/exec/e90e34656806/resize?h=40&w=80 HTTP/1.1 2891 Content-Type: text/plain 2892 2893 **Example response**: 2894 2895 HTTP/1.1 201 Created 2896 Content-Type: text/plain 2897 2898 **Query parameters**: 2899 2900 - **h** – height of `tty` session 2901 - **w** – width 2902 2903 **Status codes**: 2904 2905 - **201** – no error 2906 - **404** – no such exec instance 2907 2908 #### Exec Inspect 2909 2910 `GET /exec/(id)/json` 2911 2912 Return low-level information about the `exec` command `id`. 2913 2914 **Example request**: 2915 2916 GET /v1.24/exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1 2917 2918 **Example response**: 2919 2920 HTTP/1.1 200 OK 2921 Content-Type: application/json 2922 2923 { 2924 "CanRemove": false, 2925 "ContainerID": "b53ee82b53a40c7dca428523e34f741f3abc51d9f297a14ff874bf761b995126", 2926 "DetachKeys": "", 2927 "ExitCode": 2, 2928 "ID": "f33bbfb39f5b142420f4759b2348913bd4a8d1a6d7fd56499cb41a1bb91d7b3b", 2929 "OpenStderr": true, 2930 "OpenStdin": true, 2931 "OpenStdout": true, 2932 "ProcessConfig": { 2933 "arguments": [ 2934 "-c", 2935 "exit 2" 2936 ], 2937 "entrypoint": "sh", 2938 "privileged": false, 2939 "tty": true, 2940 "user": "1000" 2941 }, 2942 "Running": false 2943 } 2944 2945 **Status codes**: 2946 2947 - **200** – no error 2948 - **404** – no such exec instance 2949 - **500** - server error 2950 2951 ### 3.4 Volumes 2952 2953 #### List volumes 2954 2955 `GET /volumes` 2956 2957 **Example request**: 2958 2959 GET /v1.24/volumes HTTP/1.1 2960 2961 **Example response**: 2962 2963 HTTP/1.1 200 OK 2964 Content-Type: application/json 2965 2966 { 2967 "Volumes": [ 2968 { 2969 "Name": "tardis", 2970 "Driver": "local", 2971 "Mountpoint": "/var/lib/docker/volumes/tardis", 2972 "Labels": null, 2973 "Scope": "local" 2974 } 2975 ], 2976 "Warnings": [] 2977 } 2978 2979 **Query parameters**: 2980 2981 - **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the volumes list. Available filters: 2982 - `name=<volume-name>` Matches all or part of a volume name. 2983 - `dangling=<boolean>` When set to `true` (or `1`), returns all volumes that are "dangling" (not in use by a container). When set to `false` (or `0`), only volumes that are in use by one or more containers are returned. 2984 - `driver=<volume-driver-name>` Matches all or part of a volume driver name. 2985 2986 **Status codes**: 2987 2988 - **200** - no error 2989 - **500** - server error 2990 2991 #### Create a volume 2992 2993 `POST /volumes/create` 2994 2995 Create a volume 2996 2997 **Example request**: 2998 2999 POST /v1.24/volumes/create HTTP/1.1 3000 Content-Type: application/json 3001 3002 { 3003 "Name": "tardis", 3004 "Labels": { 3005 "com.example.some-label": "some-value", 3006 "com.example.some-other-label": "some-other-value" 3007 }, 3008 "Driver": "custom" 3009 } 3010 3011 **Example response**: 3012 3013 HTTP/1.1 201 Created 3014 Content-Type: application/json 3015 3016 { 3017 "Name": "tardis", 3018 "Driver": "custom", 3019 "Mountpoint": "/var/lib/docker/volumes/tardis", 3020 "Status": { 3021 "hello": "world" 3022 }, 3023 "Labels": { 3024 "com.example.some-label": "some-value", 3025 "com.example.some-other-label": "some-other-value" 3026 }, 3027 "Scope": "local" 3028 } 3029 3030 **Status codes**: 3031 3032 - **201** - no error 3033 - **500** - server error 3034 3035 **JSON parameters**: 3036 3037 - **Name** - The new volume's name. If not specified, Docker generates a name. 3038 - **Driver** - Name of the volume driver to use. Defaults to `local` for the name. 3039 - **DriverOpts** - A mapping of driver options and values. These options are 3040 passed directly to the driver and are driver specific. 3041 - **Labels** - Labels to set on the volume, specified as a map: `{"key":"value","key2":"value2"}` 3042 3043 **JSON fields in response**: 3044 3045 Refer to the [inspect a volume](#inspect-a-volume) section or details about the 3046 JSON fields returned in the response. 3047 3048 #### Inspect a volume 3049 3050 `GET /volumes/(name)` 3051 3052 Return low-level information on the volume `name` 3053 3054 **Example request**: 3055 3056 GET /v1.24/volumes/tardis 3057 3058 **Example response**: 3059 3060 HTTP/1.1 200 OK 3061 Content-Type: application/json 3062 3063 { 3064 "Name": "tardis", 3065 "Driver": "custom", 3066 "Mountpoint": "/var/lib/docker/volumes/tardis/_data", 3067 "Status": { 3068 "hello": "world" 3069 }, 3070 "Labels": { 3071 "com.example.some-label": "some-value", 3072 "com.example.some-other-label": "some-other-value" 3073 }, 3074 "Scope": "local" 3075 } 3076 3077 **Status codes**: 3078 3079 - **200** - no error 3080 - **404** - no such volume 3081 - **500** - server error 3082 3083 **JSON fields in response**: 3084 3085 The following fields can be returned in the API response. Empty fields, or 3086 fields that are not supported by the volume's driver may be omitted in the 3087 response. 3088 3089 - **Name** - Name of the volume. 3090 - **Driver** - Name of the volume driver used by the volume. 3091 - **Mountpoint** - Mount path of the volume on the host. 3092 - **Status** - Low-level details about the volume, provided by the volume driver. 3093 Details are returned as a map with key/value pairs: `{"key":"value","key2":"value2"}`. 3094 The `Status` field is optional, and is omitted if the volume driver does not 3095 support this feature. 3096 - **Labels** - Labels set on the volume, specified as a map: `{"key":"value","key2":"value2"}`. 3097 - **Scope** - Scope describes the level at which the volume exists, can be one of 3098 `global` for cluster-wide or `local` for machine level. The default is `local`. 3099 3100 #### Remove a volume 3101 3102 `DELETE /volumes/(name)` 3103 3104 Instruct the driver to remove the volume (`name`). 3105 3106 **Example request**: 3107 3108 DELETE /v1.24/volumes/tardis HTTP/1.1 3109 3110 **Example response**: 3111 3112 HTTP/1.1 204 No Content 3113 3114 **Status codes**: 3115 3116 - **204** - no error 3117 - **404** - no such volume or volume driver 3118 - **409** - volume is in use and cannot be removed 3119 - **500** - server error 3120 3121 ### 3.5 Networks 3122 3123 #### List networks 3124 3125 `GET /networks` 3126 3127 **Example request**: 3128 3129 GET /v1.24/networks?filters={"type":{"custom":true}} HTTP/1.1 3130 3131 **Example response**: 3132 3133 ``` 3134 HTTP/1.1 200 OK 3135 Content-Type: application/json 3136 3137 [ 3138 { 3139 "Name": "bridge", 3140 "Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566", 3141 "Scope": "local", 3142 "Driver": "bridge", 3143 "EnableIPv6": false, 3144 "Internal": false, 3145 "IPAM": { 3146 "Driver": "default", 3147 "Config": [ 3148 { 3149 "Subnet": "172.17.0.0/16" 3150 } 3151 ] 3152 }, 3153 "Containers": { 3154 "39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": { 3155 "EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda", 3156 "MacAddress": "02:42:ac:11:00:02", 3157 "IPv4Address": "172.17.0.2/16", 3158 "IPv6Address": "" 3159 } 3160 }, 3161 "Options": { 3162 "com.docker.network.bridge.default_bridge": "true", 3163 "com.docker.network.bridge.enable_icc": "true", 3164 "com.docker.network.bridge.enable_ip_masquerade": "true", 3165 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 3166 "com.docker.network.bridge.name": "docker0", 3167 "com.docker.network.driver.mtu": "1500" 3168 } 3169 }, 3170 { 3171 "Name": "none", 3172 "Id": "e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794", 3173 "Scope": "local", 3174 "Driver": "null", 3175 "EnableIPv6": false, 3176 "Internal": false, 3177 "IPAM": { 3178 "Driver": "default", 3179 "Config": [] 3180 }, 3181 "Containers": {}, 3182 "Options": {} 3183 }, 3184 { 3185 "Name": "host", 3186 "Id": "13e871235c677f196c4e1ecebb9dc733b9b2d2ab589e30c539efeda84a24215e", 3187 "Scope": "local", 3188 "Driver": "host", 3189 "EnableIPv6": false, 3190 "Internal": false, 3191 "IPAM": { 3192 "Driver": "default", 3193 "Config": [] 3194 }, 3195 "Containers": {}, 3196 "Options": {} 3197 } 3198 ] 3199 ``` 3200 3201 **Query parameters**: 3202 3203 - **filters** - JSON encoded network list filter. The filter value is one of: 3204 - `driver=<driver-name>` Matches a network's driver. 3205 - `id=<network-id>` Matches all or part of a network id. 3206 - `label=<key>` or `label=<key>=<value>` of a network label. 3207 - `name=<network-name>` Matches all or part of a network name. 3208 - `type=["custom"|"builtin"]` Filters networks by type. The `custom` keyword returns all user-defined networks. 3209 3210 **Status codes**: 3211 3212 - **200** - no error 3213 - **500** - server error 3214 3215 #### Inspect network 3216 3217 `GET /networks/<network-id>` 3218 3219 **Example request**: 3220 3221 GET /v1.24/networks/7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99 HTTP/1.1 3222 3223 **Example response**: 3224 3225 ``` 3226 HTTP/1.1 200 OK 3227 Content-Type: application/json 3228 3229 { 3230 "Name": "net01", 3231 "Id": "7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99", 3232 "Scope": "local", 3233 "Driver": "bridge", 3234 "EnableIPv6": false, 3235 "IPAM": { 3236 "Driver": "default", 3237 "Config": [ 3238 { 3239 "Subnet": "172.19.0.0/16", 3240 "Gateway": "172.19.0.1" 3241 } 3242 ], 3243 "Options": { 3244 "foo": "bar" 3245 } 3246 }, 3247 "Internal": false, 3248 "Containers": { 3249 "19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c": { 3250 "Name": "test", 3251 "EndpointID": "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a", 3252 "MacAddress": "02:42:ac:13:00:02", 3253 "IPv4Address": "172.19.0.2/16", 3254 "IPv6Address": "" 3255 } 3256 }, 3257 "Options": { 3258 "com.docker.network.bridge.default_bridge": "true", 3259 "com.docker.network.bridge.enable_icc": "true", 3260 "com.docker.network.bridge.enable_ip_masquerade": "true", 3261 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 3262 "com.docker.network.bridge.name": "docker0", 3263 "com.docker.network.driver.mtu": "1500" 3264 }, 3265 "Labels": { 3266 "com.example.some-label": "some-value", 3267 "com.example.some-other-label": "some-other-value" 3268 } 3269 } 3270 ``` 3271 3272 **Status codes**: 3273 3274 - **200** - no error 3275 - **404** - network not found 3276 3277 #### Create a network 3278 3279 `POST /networks/create` 3280 3281 Create a network 3282 3283 **Example request**: 3284 3285 ``` 3286 POST /v1.24/networks/create HTTP/1.1 3287 Content-Type: application/json 3288 3289 { 3290 "Name":"isolated_nw", 3291 "CheckDuplicate":true, 3292 "Driver":"bridge", 3293 "EnableIPv6": true, 3294 "IPAM":{ 3295 "Driver": "default", 3296 "Config":[ 3297 { 3298 "Subnet":"172.20.0.0/16", 3299 "IPRange":"172.20.10.0/24", 3300 "Gateway":"172.20.10.11" 3301 }, 3302 { 3303 "Subnet":"2001:db8:abcd::/64", 3304 "Gateway":"2001:db8:abcd::1011" 3305 } 3306 ], 3307 "Options": { 3308 "foo": "bar" 3309 } 3310 }, 3311 "Internal":true, 3312 "Options": { 3313 "com.docker.network.bridge.default_bridge": "true", 3314 "com.docker.network.bridge.enable_icc": "true", 3315 "com.docker.network.bridge.enable_ip_masquerade": "true", 3316 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 3317 "com.docker.network.bridge.name": "docker0", 3318 "com.docker.network.driver.mtu": "1500" 3319 }, 3320 "Labels": { 3321 "com.example.some-label": "some-value", 3322 "com.example.some-other-label": "some-other-value" 3323 } 3324 } 3325 ``` 3326 3327 **Example response**: 3328 3329 ``` 3330 HTTP/1.1 201 Created 3331 Content-Type: application/json 3332 3333 { 3334 "Id": "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30", 3335 "Warning": "" 3336 } 3337 ``` 3338 3339 **Status codes**: 3340 3341 - **201** - no error 3342 - **403** - operation not supported for pre-defined networks 3343 - **404** - plugin not found 3344 - **500** - server error 3345 3346 **JSON parameters**: 3347 3348 - **Name** - The new network's name. this is a mandatory field 3349 - **CheckDuplicate** - Requests daemon to check for networks with same name. Defaults to `false` 3350 - **Driver** - Name of the network driver plugin to use. Defaults to `bridge` driver 3351 - **Internal** - Restrict external access to the network 3352 - **IPAM** - Optional custom IP scheme for the network 3353 - **Driver** - Name of the IPAM driver to use. Defaults to `default` driver 3354 - **Config** - List of IPAM configuration options, specified as a map: 3355 `{"Subnet": <CIDR>, "IPRange": <CIDR>, "Gateway": <IP address>, "AuxAddress": <device_name:IP address>}` 3356 - **Options** - Driver-specific options, specified as a map: `{"option":"value" [,"option2":"value2"]}` 3357 - **EnableIPv6** - Enable IPv6 on the network 3358 - **Options** - Network specific options to be used by the drivers 3359 - **Labels** - Labels to set on the network, specified as a map: `{"key":"value" [,"key2":"value2"]}` 3360 3361 #### Connect a container to a network 3362 3363 `POST /networks/(id)/connect` 3364 3365 Connect a container to a network 3366 3367 **Example request**: 3368 3369 ``` 3370 POST /v1.24/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/connect HTTP/1.1 3371 Content-Type: application/json 3372 3373 { 3374 "Container":"3613f73ba0e4", 3375 "EndpointConfig": { 3376 "IPAMConfig": { 3377 "IPv4Address":"172.24.56.89", 3378 "IPv6Address":"2001:db8::5689" 3379 } 3380 } 3381 } 3382 ``` 3383 3384 **Example response**: 3385 3386 HTTP/1.1 200 OK 3387 3388 **Status codes**: 3389 3390 - **200** - no error 3391 - **403** - operation not supported for swarm scoped networks 3392 - **404** - network or container is not found 3393 - **500** - Internal Server Error 3394 3395 **JSON parameters**: 3396 3397 - **container** - container-id/name to be connected to the network 3398 3399 #### Disconnect a container from a network 3400 3401 `POST /networks/(id)/disconnect` 3402 3403 Disconnect a container from a network 3404 3405 **Example request**: 3406 3407 ``` 3408 POST /v1.24/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/disconnect HTTP/1.1 3409 Content-Type: application/json 3410 3411 { 3412 "Container":"3613f73ba0e4", 3413 "Force":false 3414 } 3415 ``` 3416 3417 **Example response**: 3418 3419 HTTP/1.1 200 OK 3420 3421 **Status codes**: 3422 3423 - **200** - no error 3424 - **403** - operation not supported for swarm scoped networks 3425 - **404** - network or container not found 3426 - **500** - Internal Server Error 3427 3428 **JSON parameters**: 3429 3430 - **Container** - container-id/name to be disconnected from a network 3431 - **Force** - Force the container to disconnect from a network 3432 3433 #### Remove a network 3434 3435 `DELETE /networks/(id)` 3436 3437 Instruct the driver to remove the network (`id`). 3438 3439 **Example request**: 3440 3441 DELETE /v1.24/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30 HTTP/1.1 3442 3443 **Example response**: 3444 3445 HTTP/1.1 204 No Content 3446 3447 **Status codes**: 3448 3449 - **204** - no error 3450 - **404** - no such network 3451 - **500** - server error 3452 3453 ### 3.6 Plugins (experimental) 3454 3455 #### List plugins 3456 3457 `GET /plugins` 3458 3459 Returns information about installed plugins. 3460 3461 **Example request**: 3462 3463 GET /v1.24/plugins HTTP/1.1 3464 3465 **Example response**: 3466 3467 ``` 3468 HTTP/1.1 200 OK 3469 Content-Type: application/json 3470 3471 [ 3472 { 3473 "Id": "5724e2c8652da337ab2eedd19fc6fc0ec908e4bd907c7421bf6a8dfc70c4c078", 3474 "Name": "tiborvass/no-remove", 3475 "Tag": "latest", 3476 "Active": true, 3477 "Config": { 3478 "Mounts": [ 3479 { 3480 "Name": "", 3481 "Description": "", 3482 "Settable": null, 3483 "Source": "/data", 3484 "Destination": "/data", 3485 "Type": "bind", 3486 "Options": [ 3487 "shared", 3488 "rbind" 3489 ] 3490 }, 3491 { 3492 "Name": "", 3493 "Description": "", 3494 "Settable": null, 3495 "Source": null, 3496 "Destination": "/foobar", 3497 "Type": "tmpfs", 3498 "Options": null 3499 } 3500 ], 3501 "Env": [ 3502 "DEBUG=1" 3503 ], 3504 "Args": null, 3505 "Devices": null 3506 }, 3507 "Manifest": { 3508 "ManifestVersion": "v0", 3509 "Description": "A test plugin for Docker", 3510 "Documentation": "https://docs.docker.com/engine/extend/plugins/", 3511 "Interface": { 3512 "Types": [ 3513 "docker.volumedriver/1.0" 3514 ], 3515 "Socket": "plugins.sock" 3516 }, 3517 "Entrypoint": [ 3518 "plugin-no-remove", 3519 "/data" 3520 ], 3521 "Workdir": "", 3522 "User": { 3523 }, 3524 "Network": { 3525 "Type": "host" 3526 }, 3527 "Capabilities": null, 3528 "Mounts": [ 3529 { 3530 "Name": "", 3531 "Description": "", 3532 "Settable": null, 3533 "Source": "/data", 3534 "Destination": "/data", 3535 "Type": "bind", 3536 "Options": [ 3537 "shared", 3538 "rbind" 3539 ] 3540 }, 3541 { 3542 "Name": "", 3543 "Description": "", 3544 "Settable": null, 3545 "Source": null, 3546 "Destination": "/foobar", 3547 "Type": "tmpfs", 3548 "Options": null 3549 } 3550 ], 3551 "Devices": [ 3552 { 3553 "Name": "device", 3554 "Description": "a host device to mount", 3555 "Settable": null, 3556 "Path": "/dev/cpu_dma_latency" 3557 } 3558 ], 3559 "Env": [ 3560 { 3561 "Name": "DEBUG", 3562 "Description": "If set, prints debug messages", 3563 "Settable": null, 3564 "Value": "1" 3565 } 3566 ], 3567 "Args": { 3568 "Name": "args", 3569 "Description": "command line arguments", 3570 "Settable": null, 3571 "Value": [ 3572 3573 ] 3574 } 3575 } 3576 } 3577 ] 3578 ``` 3579 3580 **Status codes**: 3581 3582 - **200** - no error 3583 - **500** - server error 3584 3585 #### Install a plugin 3586 3587 `POST /plugins/pull?name=<plugin name>` 3588 3589 Pulls and installs a plugin. After the plugin is installed, it can be enabled 3590 using the [`POST /plugins/(plugin name)/enable` endpoint](#enable-a-plugin). 3591 3592 **Example request**: 3593 3594 ``` 3595 POST /v1.24/plugins/pull?name=tiborvass/no-remove:latest HTTP/1.1 3596 ``` 3597 3598 The `:latest` tag is optional, and is used as default if omitted. When using 3599 this endpoint to pull a plugin from the registry, the `X-Registry-Auth` header 3600 can be used to include a base64-encoded AuthConfig object. Refer to the [create 3601 an image](#create-an-image) section for more details. 3602 3603 **Example response**: 3604 3605 ``` 3606 HTTP/1.1 200 OK 3607 Content-Type: application/json 3608 Content-Length: 175 3609 3610 [ 3611 { 3612 "Name": "network", 3613 "Description": "", 3614 "Value": [ 3615 "host" 3616 ] 3617 }, 3618 { 3619 "Name": "mount", 3620 "Description": "", 3621 "Value": [ 3622 "/data" 3623 ] 3624 }, 3625 { 3626 "Name": "device", 3627 "Description": "", 3628 "Value": [ 3629 "/dev/cpu_dma_latency" 3630 ] 3631 } 3632 ] 3633 ``` 3634 3635 **Query parameters**: 3636 3637 - **name** - Name of the plugin to pull. The name may include a tag or digest. 3638 This parameter is required. 3639 3640 **Status codes**: 3641 3642 - **200** - no error 3643 - **500** - error parsing reference / not a valid repository/tag: repository 3644 name must have at least one component 3645 - **500** - plugin already exists 3646 3647 #### Inspect a plugin 3648 3649 `GET /plugins/(plugin name)` 3650 3651 Returns detailed information about an installed plugin. 3652 3653 **Example request**: 3654 3655 ``` 3656 GET /v1.24/plugins/tiborvass/no-remove:latest HTTP/1.1 3657 ``` 3658 3659 The `:latest` tag is optional, and is used as default if omitted. 3660 3661 3662 **Example response**: 3663 3664 ``` 3665 HTTP/1.1 200 OK 3666 Content-Type: application/json 3667 3668 { 3669 "Id": "5724e2c8652da337ab2eedd19fc6fc0ec908e4bd907c7421bf6a8dfc70c4c078", 3670 "Name": "tiborvass/no-remove", 3671 "Tag": "latest", 3672 "Active": false, 3673 "Config": { 3674 "Mounts": [ 3675 { 3676 "Name": "", 3677 "Description": "", 3678 "Settable": null, 3679 "Source": "/data", 3680 "Destination": "/data", 3681 "Type": "bind", 3682 "Options": [ 3683 "shared", 3684 "rbind" 3685 ] 3686 }, 3687 { 3688 "Name": "", 3689 "Description": "", 3690 "Settable": null, 3691 "Source": null, 3692 "Destination": "/foobar", 3693 "Type": "tmpfs", 3694 "Options": null 3695 } 3696 ], 3697 "Env": [ 3698 "DEBUG=1" 3699 ], 3700 "Args": null, 3701 "Devices": null 3702 }, 3703 "Manifest": { 3704 "ManifestVersion": "v0", 3705 "Description": "A test plugin for Docker", 3706 "Documentation": "https://docs.docker.com/engine/extend/plugins/", 3707 "Interface": { 3708 "Types": [ 3709 "docker.volumedriver/1.0" 3710 ], 3711 "Socket": "plugins.sock" 3712 }, 3713 "Entrypoint": [ 3714 "plugin-no-remove", 3715 "/data" 3716 ], 3717 "Workdir": "", 3718 "User": { 3719 }, 3720 "Network": { 3721 "Type": "host" 3722 }, 3723 "Capabilities": null, 3724 "Mounts": [ 3725 { 3726 "Name": "", 3727 "Description": "", 3728 "Settable": null, 3729 "Source": "/data", 3730 "Destination": "/data", 3731 "Type": "bind", 3732 "Options": [ 3733 "shared", 3734 "rbind" 3735 ] 3736 }, 3737 { 3738 "Name": "", 3739 "Description": "", 3740 "Settable": null, 3741 "Source": null, 3742 "Destination": "/foobar", 3743 "Type": "tmpfs", 3744 "Options": null 3745 } 3746 ], 3747 "Devices": [ 3748 { 3749 "Name": "device", 3750 "Description": "a host device to mount", 3751 "Settable": null, 3752 "Path": "/dev/cpu_dma_latency" 3753 } 3754 ], 3755 "Env": [ 3756 { 3757 "Name": "DEBUG", 3758 "Description": "If set, prints debug messages", 3759 "Settable": null, 3760 "Value": "1" 3761 } 3762 ], 3763 "Args": { 3764 "Name": "args", 3765 "Description": "command line arguments", 3766 "Settable": null, 3767 "Value": [ 3768 3769 ] 3770 } 3771 } 3772 } 3773 ``` 3774 3775 **Status codes**: 3776 3777 - **200** - no error 3778 - **404** - plugin not installed 3779 3780 #### Enable a plugin 3781 3782 `POST /plugins/(plugin name)/enable` 3783 3784 Enables a plugin 3785 3786 **Example request**: 3787 3788 ``` 3789 POST /v1.24/plugins/tiborvass/no-remove:latest/enable HTTP/1.1 3790 ``` 3791 3792 The `:latest` tag is optional, and is used as default if omitted. 3793 3794 3795 **Example response**: 3796 3797 ``` 3798 HTTP/1.1 200 OK 3799 Content-Length: 0 3800 Content-Type: text/plain; charset=utf-8 3801 ``` 3802 3803 **Status codes**: 3804 3805 - **200** - no error 3806 - **404** - plugin not installed 3807 - **500** - plugin is already enabled 3808 3809 #### Disable a plugin 3810 3811 `POST /plugins/(plugin name)/disable` 3812 3813 Disables a plugin 3814 3815 **Example request**: 3816 3817 ``` 3818 POST /v1.24/plugins/tiborvass/no-remove:latest/disable HTTP/1.1 3819 ``` 3820 3821 The `:latest` tag is optional, and is used as default if omitted. 3822 3823 3824 **Example response**: 3825 3826 ``` 3827 HTTP/1.1 200 OK 3828 Content-Length: 0 3829 Content-Type: text/plain; charset=utf-8 3830 ``` 3831 3832 **Status codes**: 3833 3834 - **200** - no error 3835 - **404** - plugin not installed 3836 - **500** - plugin is already disabled 3837 3838 #### Remove a plugin 3839 3840 `DELETE /plugins/(plugin name)` 3841 3842 Removes a plugin 3843 3844 **Example request**: 3845 3846 ``` 3847 DELETE /v1.24/plugins/tiborvass/no-remove:latest HTTP/1.1 3848 ``` 3849 3850 The `:latest` tag is optional, and is used as default if omitted. 3851 3852 **Example response**: 3853 3854 ``` 3855 HTTP/1.1 200 OK 3856 Content-Length: 0 3857 Content-Type: text/plain; charset=utf-8 3858 ``` 3859 3860 **Status codes**: 3861 3862 - **200** - no error 3863 - **404** - plugin not installed 3864 - **500** - plugin is active 3865 3866 <!-- TODO Document "docker plugin push" endpoint once we have "plugin build" 3867 3868 #### Push a plugin 3869 3870 `POST /v1.24/plugins/tiborvass/(plugin name)/push HTTP/1.1` 3871 3872 Pushes a plugin to the registry. 3873 3874 **Example request**: 3875 3876 ``` 3877 POST /v1.24/plugins/tiborvass/no-remove:latest HTTP/1.1 3878 ``` 3879 3880 The `:latest` tag is optional, and is used as default if omitted. When using 3881 this endpoint to push a plugin to the registry, the `X-Registry-Auth` header 3882 can be used to include a base64-encoded AuthConfig object. Refer to the [create 3883 an image](#create-an-image) section for more details. 3884 3885 **Example response**: 3886 3887 **Status codes**: 3888 3889 - **200** - no error 3890 - **404** - plugin not installed 3891 3892 --> 3893 3894 ### 3.7 Nodes 3895 3896 **Note**: Node operations require the engine to be part of a swarm. 3897 3898 #### List nodes 3899 3900 3901 `GET /nodes` 3902 3903 List nodes 3904 3905 **Example request**: 3906 3907 GET /v1.24/nodes HTTP/1.1 3908 3909 **Example response**: 3910 3911 HTTP/1.1 200 OK 3912 Content-Type: application/json 3913 3914 [ 3915 { 3916 "ID": "24ifsmvkjbyhk", 3917 "Version": { 3918 "Index": 8 3919 }, 3920 "CreatedAt": "2016-06-07T20:31:11.853781916Z", 3921 "UpdatedAt": "2016-06-07T20:31:11.999868824Z", 3922 "Spec": { 3923 "Name": "my-node", 3924 "Role": "manager", 3925 "Availability": "active" 3926 "Labels": { 3927 "foo": "bar" 3928 } 3929 }, 3930 "Description": { 3931 "Hostname": "bf3067039e47", 3932 "Platform": { 3933 "Architecture": "x86_64", 3934 "OS": "linux" 3935 }, 3936 "Resources": { 3937 "NanoCPUs": 4000000000, 3938 "MemoryBytes": 8272408576 3939 }, 3940 "Engine": { 3941 "EngineVersion": "1.12.0", 3942 "Labels": { 3943 "foo": "bar", 3944 } 3945 "Plugins": [ 3946 { 3947 "Type": "Volume", 3948 "Name": "local" 3949 }, 3950 { 3951 "Type": "Network", 3952 "Name": "bridge" 3953 } 3954 { 3955 "Type": "Network", 3956 "Name": "null" 3957 } 3958 { 3959 "Type": "Network", 3960 "Name": "overlay" 3961 } 3962 ] 3963 } 3964 }, 3965 "Status": { 3966 "State": "ready" 3967 }, 3968 "ManagerStatus": { 3969 "Leader": true, 3970 "Reachability": "reachable", 3971 "Addr": "172.17.0.2:2377"" 3972 } 3973 } 3974 ] 3975 3976 **Query parameters**: 3977 3978 - **filters** – a JSON encoded value of the filters (a `map[string][]string`) to process on the 3979 nodes list. Available filters: 3980 - `id=<node id>` 3981 - `label=<engine label>` 3982 - `membership=`(`accepted`|`pending`)` 3983 - `name=<node name>` 3984 - `role=`(`manager`|`worker`)` 3985 3986 **Status codes**: 3987 3988 - **200** – no error 3989 - **406** - node is not part of a swarm 3990 - **500** – server error 3991 3992 #### Inspect a node 3993 3994 3995 `GET /nodes/(id or name)` 3996 3997 Return low-level information on the node `id` 3998 3999 **Example request**: 4000 4001 GET /v1.24/nodes/24ifsmvkjbyhk HTTP/1.1 4002 4003 **Example response**: 4004 4005 HTTP/1.1 200 OK 4006 Content-Type: application/json 4007 4008 { 4009 "ID": "24ifsmvkjbyhk", 4010 "Version": { 4011 "Index": 8 4012 }, 4013 "CreatedAt": "2016-06-07T20:31:11.853781916Z", 4014 "UpdatedAt": "2016-06-07T20:31:11.999868824Z", 4015 "Spec": { 4016 "Name": "my-node", 4017 "Role": "manager", 4018 "Availability": "active" 4019 "Labels": { 4020 "foo": "bar" 4021 } 4022 }, 4023 "Description": { 4024 "Hostname": "bf3067039e47", 4025 "Platform": { 4026 "Architecture": "x86_64", 4027 "OS": "linux" 4028 }, 4029 "Resources": { 4030 "NanoCPUs": 4000000000, 4031 "MemoryBytes": 8272408576 4032 }, 4033 "Engine": { 4034 "EngineVersion": "1.12.0", 4035 "Labels": { 4036 "foo": "bar", 4037 } 4038 "Plugins": [ 4039 { 4040 "Type": "Volume", 4041 "Name": "local" 4042 }, 4043 { 4044 "Type": "Network", 4045 "Name": "bridge" 4046 } 4047 { 4048 "Type": "Network", 4049 "Name": "null" 4050 } 4051 { 4052 "Type": "Network", 4053 "Name": "overlay" 4054 } 4055 ] 4056 } 4057 }, 4058 "Status": { 4059 "State": "ready" 4060 }, 4061 "ManagerStatus": { 4062 "Leader": true, 4063 "Reachability": "reachable", 4064 "Addr": "172.17.0.2:2377"" 4065 } 4066 } 4067 4068 **Status codes**: 4069 4070 - **200** – no error 4071 - **404** – no such node 4072 - **406** – node is not part of a swarm 4073 - **500** – server error 4074 4075 #### Remove a node 4076 4077 4078 `DELETE /nodes/(id or name)` 4079 4080 Remove a node from the swarm. 4081 4082 **Example request**: 4083 4084 DELETE /v1.24/nodes/24ifsmvkjbyhk HTTP/1.1 4085 4086 **Example response**: 4087 4088 HTTP/1.1 200 OK 4089 Content-Length: 0 4090 Content-Type: text/plain; charset=utf-8 4091 4092 **Query parameters**: 4093 4094 - **force** - 1/True/true or 0/False/false, Force remove a node from the swarm. 4095 Default `false`. 4096 4097 **Status codes**: 4098 4099 - **200** – no error 4100 - **404** – no such node 4101 - **406** – node is not part of a swarm 4102 - **500** – server error 4103 4104 #### Update a node 4105 4106 4107 `POST /nodes/(id)/update` 4108 4109 Update a node. 4110 4111 The payload of the `POST` request is the new `NodeSpec` and 4112 overrides the current `NodeSpec` for the specified node. 4113 4114 If `Availability` or `Role` are omitted, this returns an 4115 error. Any other field omitted resets the current value to either 4116 an empty value or the default cluster-wide value. 4117 4118 **Example Request** 4119 4120 POST /v1.24/nodes/24ifsmvkjbyhk/update?version=8 HTTP/1.1 4121 Content-Type: application/json 4122 4123 { 4124 "Availability": "active", 4125 "Name": "node-name", 4126 "Role": "manager", 4127 "Labels": { 4128 "foo": "bar" 4129 } 4130 } 4131 4132 **Example response**: 4133 4134 HTTP/1.1 200 OK 4135 Content-Length: 0 4136 Content-Type: text/plain; charset=utf-8 4137 4138 **Query parameters**: 4139 4140 - **version** – The version number of the node object being updated. This is 4141 required to avoid conflicting writes. 4142 4143 JSON Parameters: 4144 4145 - **Annotations** – Optional medata to associate with the node. 4146 - **Name** – User-defined name for the node. 4147 - **Labels** – A map of labels to associate with the node (e.g., 4148 `{"key":"value", "key2":"value2"}`). 4149 - **Role** - Role of the node (worker|manager). 4150 - **Availability** - Availability of the node (active|pause|drain). 4151 4152 4153 **Status codes**: 4154 4155 - **200** – no error 4156 - **404** – no such node 4157 - **406** – node is not part of a swarm 4158 - **500** – server error 4159 4160 ### 3.8 Swarm 4161 4162 #### Inspect swarm 4163 4164 4165 `GET /swarm` 4166 4167 Inspect swarm 4168 4169 **Example response**: 4170 4171 HTTP/1.1 200 OK 4172 Content-Type: application/json 4173 4174 { 4175 "CreatedAt" : "2016-08-15T16:00:20.349727406Z", 4176 "Spec" : { 4177 "Dispatcher" : { 4178 "HeartbeatPeriod" : 5000000000 4179 }, 4180 "Orchestration" : { 4181 "TaskHistoryRetentionLimit" : 10 4182 }, 4183 "CAConfig" : { 4184 "NodeCertExpiry" : 7776000000000000 4185 }, 4186 "Raft" : { 4187 "LogEntriesForSlowFollowers" : 500, 4188 "HeartbeatTick" : 1, 4189 "SnapshotInterval" : 10000, 4190 "ElectionTick" : 3 4191 }, 4192 "TaskDefaults" : {}, 4193 "Name" : "default" 4194 }, 4195 "JoinTokens" : { 4196 "Worker" : "SWMTKN-1-1h8aps2yszaiqmz2l3oc5392pgk8e49qhx2aj3nyv0ui0hez2a-6qmn92w6bu3jdvnglku58u11a", 4197 "Manager" : "SWMTKN-1-1h8aps2yszaiqmz2l3oc5392pgk8e49qhx2aj3nyv0ui0hez2a-8llk83c4wm9lwioey2s316r9l" 4198 }, 4199 "ID" : "70ilmkj2f6sp2137c753w2nmt", 4200 "UpdatedAt" : "2016-08-15T16:32:09.623207604Z", 4201 "Version" : { 4202 "Index" : 51 4203 } 4204 } 4205 4206 **Status codes**: 4207 4208 - **200** - no error 4209 - **406** – node is not part of a swarm 4210 - **500** - sever error 4211 4212 #### Initialize a new swarm 4213 4214 4215 `POST /swarm/init` 4216 4217 Initialize a new swarm. The body of the HTTP response includes the node ID. 4218 4219 **Example request**: 4220 4221 POST /v1.24/swarm/init HTTP/1.1 4222 Content-Type: application/json 4223 4224 { 4225 "ListenAddr": "0.0.0.0:2377", 4226 "AdvertiseAddr": "192.168.1.1:2377", 4227 "ForceNewCluster": false, 4228 "Spec": { 4229 "Orchestration": {}, 4230 "Raft": {}, 4231 "Dispatcher": {}, 4232 "CAConfig": {} 4233 } 4234 } 4235 4236 **Example response**: 4237 4238 HTTP/1.1 200 OK 4239 Content-Length: 28 4240 Content-Type: application/json 4241 Date: Thu, 01 Sep 2016 21:49:13 GMT 4242 Server: Docker/1.12.0 (linux) 4243 4244 "7v2t30z9blmxuhnyo6s4cpenp" 4245 4246 **Status codes**: 4247 4248 - **200** – no error 4249 - **400** – bad parameter 4250 - **406** – node is already part of a swarm 4251 - **500** - server error 4252 4253 JSON Parameters: 4254 4255 - **ListenAddr** – Listen address used for inter-manager communication, as well as determining 4256 the networking interface used for the VXLAN Tunnel Endpoint (VTEP). This can either be an 4257 address/port combination in the form `192.168.1.1:4567`, or an interface followed by a port 4258 number, like `eth0:4567`. If the port number is omitted, the default swarm listening port is 4259 used. 4260 - **AdvertiseAddr** – Externally reachable address advertised to other nodes. This can either be 4261 an address/port combination in the form `192.168.1.1:4567`, or an interface followed by a port 4262 number, like `eth0:4567`. If the port number is omitted, the port number from the listen 4263 address is used. If `AdvertiseAddr` is not specified, it will be automatically detected when 4264 possible. 4265 - **ForceNewCluster** – Force creation of a new swarm. 4266 - **Spec** – Configuration settings for the new swarm. 4267 - **Orchestration** – Configuration settings for the orchestration aspects of the swarm. 4268 - **TaskHistoryRetentionLimit** – Maximum number of tasks history stored. 4269 - **Raft** – Raft related configuration. 4270 - **SnapshotInterval** – Number of logs entries between snapshot. 4271 - **KeepOldSnapshots** – Number of snapshots to keep beyond the current snapshot. 4272 - **LogEntriesForSlowFollowers** – Number of log entries to keep around to sync up slow 4273 followers after a snapshot is created. 4274 - **HeartbeatTick** – Amount of ticks (in seconds) between each heartbeat. 4275 - **ElectionTick** – Amount of ticks (in seconds) needed without a leader to trigger a new 4276 election. 4277 - **Dispatcher** – Configuration settings for the task dispatcher. 4278 - **HeartbeatPeriod** – The delay for an agent to send a heartbeat to the dispatcher. 4279 - **CAConfig** – Certificate authority configuration. 4280 - **NodeCertExpiry** – Automatic expiry for nodes certificates. 4281 - **ExternalCA** - Configuration for forwarding signing requests to an external 4282 certificate authority. 4283 - **Protocol** - Protocol for communication with the external CA 4284 (currently only "cfssl" is supported). 4285 - **URL** - URL where certificate signing requests should be sent. 4286 - **Options** - An object with key/value pairs that are interpreted 4287 as protocol-specific options for the external CA driver. 4288 4289 #### Join an existing swarm 4290 4291 `POST /swarm/join` 4292 4293 Join an existing swarm 4294 4295 **Example request**: 4296 4297 POST /v1.24/swarm/join HTTP/1.1 4298 Content-Type: application/json 4299 4300 { 4301 "ListenAddr": "0.0.0.0:2377", 4302 "AdvertiseAddr": "192.168.1.1:2377", 4303 "RemoteAddrs": ["node1:2377"], 4304 "JoinToken": "SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2" 4305 } 4306 4307 **Example response**: 4308 4309 HTTP/1.1 200 OK 4310 Content-Length: 0 4311 Content-Type: text/plain; charset=utf-8 4312 4313 **Status codes**: 4314 4315 - **200** – no error 4316 - **400** – bad parameter 4317 - **406** – node is already part of a swarm 4318 - **500** - server error 4319 4320 JSON Parameters: 4321 4322 - **ListenAddr** – Listen address used for inter-manager communication if the node gets promoted to 4323 manager, as well as determining the networking interface used for the VXLAN Tunnel Endpoint (VTEP). 4324 - **AdvertiseAddr** – Externally reachable address advertised to other nodes. This can either be 4325 an address/port combination in the form `192.168.1.1:4567`, or an interface followed by a port 4326 number, like `eth0:4567`. If the port number is omitted, the port number from the listen 4327 address is used. If `AdvertiseAddr` is not specified, it will be automatically detected when 4328 possible. 4329 - **RemoteAddr** – Address of any manager node already participating in the swarm. 4330 - **JoinToken** – Secret token for joining this swarm. 4331 4332 #### Leave a swarm 4333 4334 4335 `POST /swarm/leave` 4336 4337 Leave a swarm 4338 4339 **Example request**: 4340 4341 POST /v1.24/swarm/leave HTTP/1.1 4342 4343 **Example response**: 4344 4345 HTTP/1.1 200 OK 4346 Content-Length: 0 4347 Content-Type: text/plain; charset=utf-8 4348 4349 **Query parameters**: 4350 4351 - **force** - Boolean (0/1, false/true). Force leave swarm, even if this is the last manager or that it will break the cluster. 4352 4353 **Status codes**: 4354 4355 - **200** – no error 4356 - **406** – node is not part of a swarm 4357 - **500** - server error 4358 4359 #### Update a swarm 4360 4361 4362 `POST /swarm/update` 4363 4364 Update a swarm 4365 4366 **Example request**: 4367 4368 POST /v1.24/swarm/update HTTP/1.1 4369 4370 { 4371 "Name": "default", 4372 "Orchestration": { 4373 "TaskHistoryRetentionLimit": 10 4374 }, 4375 "Raft": { 4376 "SnapshotInterval": 10000, 4377 "LogEntriesForSlowFollowers": 500, 4378 "HeartbeatTick": 1, 4379 "ElectionTick": 3 4380 }, 4381 "Dispatcher": { 4382 "HeartbeatPeriod": 5000000000 4383 }, 4384 "CAConfig": { 4385 "NodeCertExpiry": 7776000000000000 4386 }, 4387 "JoinTokens": { 4388 "Worker": "SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-1awxwuwd3z9j1z3puu7rcgdbx", 4389 "Manager": "SWMTKN-1-3pu6hszjas19xyp7ghgosyx9k8atbfcr8p2is99znpy26u2lkl-7p73s1dx5in4tatdymyhg9hu2" 4390 } 4391 } 4392 4393 4394 **Example response**: 4395 4396 HTTP/1.1 200 OK 4397 Content-Length: 0 4398 Content-Type: text/plain; charset=utf-8 4399 4400 **Query parameters**: 4401 4402 - **version** – The version number of the swarm object being updated. This is 4403 required to avoid conflicting writes. 4404 - **rotateWorkerToken** - Set to `true` (or `1`) to rotate the worker join token. 4405 - **rotateManagerToken** - Set to `true` (or `1`) to rotate the manager join token. 4406 4407 **Status codes**: 4408 4409 - **200** – no error 4410 - **400** – bad parameter 4411 - **406** – node is not part of a swarm 4412 - **500** - server error 4413 4414 JSON Parameters: 4415 4416 - **Orchestration** – Configuration settings for the orchestration aspects of the swarm. 4417 - **TaskHistoryRetentionLimit** – Maximum number of tasks history stored. 4418 - **Raft** – Raft related configuration. 4419 - **SnapshotInterval** – Number of logs entries between snapshot. 4420 - **KeepOldSnapshots** – Number of snapshots to keep beyond the current snapshot. 4421 - **LogEntriesForSlowFollowers** – Number of log entries to keep around to sync up slow 4422 followers after a snapshot is created. 4423 - **HeartbeatTick** – Amount of ticks (in seconds) between each heartbeat. 4424 - **ElectionTick** – Amount of ticks (in seconds) needed without a leader to trigger a new 4425 election. 4426 - **Dispatcher** – Configuration settings for the task dispatcher. 4427 - **HeartbeatPeriod** – The delay for an agent to send a heartbeat to the dispatcher. 4428 - **CAConfig** – CA configuration. 4429 - **NodeCertExpiry** – Automatic expiry for nodes certificates. 4430 - **ExternalCA** - Configuration for forwarding signing requests to an external 4431 certificate authority. 4432 - **Protocol** - Protocol for communication with the external CA 4433 (currently only "cfssl" is supported). 4434 - **URL** - URL where certificate signing requests should be sent. 4435 - **Options** - An object with key/value pairs that are interpreted 4436 as protocol-specific options for the external CA driver. 4437 - **JoinTokens** - Tokens that can be used by other nodes to join the swarm. 4438 - **Worker** - Token to use for joining as a worker. 4439 - **Manager** - Token to use for joining as a manager. 4440 4441 ### 3.9 Services 4442 4443 **Note**: Service operations require to first be part of a swarm. 4444 4445 #### List services 4446 4447 4448 `GET /services` 4449 4450 List services 4451 4452 **Example request**: 4453 4454 GET /v1.24/services HTTP/1.1 4455 4456 **Example response**: 4457 4458 HTTP/1.1 200 OK 4459 Content-Type: application/json 4460 4461 [ 4462 { 4463 "ID": "9mnpnzenvg8p8tdbtq4wvbkcz", 4464 "Version": { 4465 "Index": 19 4466 }, 4467 "CreatedAt": "2016-06-07T21:05:51.880065305Z", 4468 "UpdatedAt": "2016-06-07T21:07:29.962229872Z", 4469 "Spec": { 4470 "Name": "hopeful_cori", 4471 "TaskTemplate": { 4472 "ContainerSpec": { 4473 "Image": "redis" 4474 }, 4475 "Resources": { 4476 "Limits": {}, 4477 "Reservations": {} 4478 }, 4479 "RestartPolicy": { 4480 "Condition": "any", 4481 "MaxAttempts": 0 4482 }, 4483 "Placement": { 4484 "Constraints": [ 4485 "node.role == worker" 4486 ] 4487 } 4488 }, 4489 "Mode": { 4490 "Replicated": { 4491 "Replicas": 1 4492 } 4493 }, 4494 "UpdateConfig": { 4495 "Parallelism": 1, 4496 "FailureAction": "pause" 4497 }, 4498 "EndpointSpec": { 4499 "Mode": "vip", 4500 "Ports": [ 4501 { 4502 "Protocol": "tcp", 4503 "TargetPort": 6379, 4504 "PublishedPort": 30001 4505 } 4506 ] 4507 } 4508 }, 4509 "Endpoint": { 4510 "Spec": { 4511 "Mode": "vip", 4512 "Ports": [ 4513 { 4514 "Protocol": "tcp", 4515 "TargetPort": 6379, 4516 "PublishedPort": 30001 4517 } 4518 ] 4519 }, 4520 "Ports": [ 4521 { 4522 "Protocol": "tcp", 4523 "TargetPort": 6379, 4524 "PublishedPort": 30001 4525 } 4526 ], 4527 "VirtualIPs": [ 4528 { 4529 "NetworkID": "4qvuz4ko70xaltuqbt8956gd1", 4530 "Addr": "10.255.0.2/16" 4531 }, 4532 { 4533 "NetworkID": "4qvuz4ko70xaltuqbt8956gd1", 4534 "Addr": "10.255.0.3/16" 4535 } 4536 ] 4537 } 4538 } 4539 ] 4540 4541 **Query parameters**: 4542 4543 - **filters** – a JSON encoded value of the filters (a `map[string][]string`) to process on the 4544 services list. Available filters: 4545 - `id=<service id>` 4546 - `label=<service label>` 4547 - `name=<service name>` 4548 4549 **Status codes**: 4550 4551 - **200** – no error 4552 - **406** – node is not part of a swarm 4553 - **500** – server error 4554 4555 #### Create a service 4556 4557 `POST /services/create` 4558 4559 Create a service. When using this endpoint to create a service using a private 4560 repository from the registry, the `X-Registry-Auth` header must be used to 4561 include a base64-encoded AuthConfig object. Refer to the [create an 4562 image](#create-an-image) section for more details. 4563 4564 **Example request**: 4565 4566 POST /v1.24/services/create HTTP/1.1 4567 Content-Type: application/json 4568 4569 { 4570 "Name": "web", 4571 "TaskTemplate": { 4572 "ContainerSpec": { 4573 "Image": "nginx:alpine", 4574 "Mounts": [ 4575 { 4576 "ReadOnly": true, 4577 "Source": "web-data", 4578 "Target": "/usr/share/nginx/html", 4579 "Type": "volume", 4580 "VolumeOptions": { 4581 "DriverConfig": { 4582 }, 4583 "Labels": { 4584 "com.example.something": "something-value" 4585 } 4586 } 4587 } 4588 ], 4589 "User": "33" 4590 }, 4591 "Networks": [ 4592 { 4593 "Target": "overlay1" 4594 } 4595 ], 4596 "LogDriver": { 4597 "Name": "json-file", 4598 "Options": { 4599 "max-file": "3", 4600 "max-size": "10M" 4601 } 4602 }, 4603 "Placement": { 4604 "Constraints": [ 4605 "node.role == worker" 4606 ] 4607 }, 4608 "Resources": { 4609 "Limits": { 4610 "MemoryBytes": 104857600 4611 }, 4612 "Reservations": { 4613 } 4614 }, 4615 "RestartPolicy": { 4616 "Condition": "on-failure", 4617 "Delay": 10000000000, 4618 "MaxAttempts": 10 4619 } 4620 }, 4621 "Mode": { 4622 "Replicated": { 4623 "Replicas": 4 4624 } 4625 }, 4626 "UpdateConfig": { 4627 "Delay": 30000000000, 4628 "Parallelism": 2, 4629 "FailureAction": "pause" 4630 }, 4631 "EndpointSpec": { 4632 "Ports": [ 4633 { 4634 "Protocol": "tcp", 4635 "PublishedPort": 8080, 4636 "TargetPort": 80 4637 } 4638 ] 4639 }, 4640 "Labels": { 4641 "foo": "bar" 4642 } 4643 } 4644 4645 **Example response**: 4646 4647 HTTP/1.1 201 Created 4648 Content-Type: application/json 4649 4650 { 4651 "ID":"ak7w3gjqoa3kuz8xcpnyy0pvl" 4652 } 4653 4654 **Status codes**: 4655 4656 - **201** – no error 4657 - **403** - network is not eligible for services 4658 - **406** – node is not part of a swarm 4659 - **409** – name conflicts with an existing object 4660 - **500** - server error 4661 4662 **JSON Parameters**: 4663 4664 - **Name** – User-defined name for the service. 4665 - **Labels** – A map of labels to associate with the service (e.g., `{"key":"value", "key2":"value2"}`). 4666 - **TaskTemplate** – Specification of the tasks to start as part of the new service. 4667 - **ContainerSpec** - Container settings for containers started as part of this task. 4668 - **Image** – A string specifying the image name to use for the container. 4669 - **Command** – The command to be run in the image. 4670 - **Args** – Arguments to the command. 4671 - **Env** – A list of environment variables in the form of `["VAR=value"[,"VAR2=value2"]]`. 4672 - **Dir** – A string specifying the working directory for commands to run in. 4673 - **User** – A string value specifying the user inside the container. 4674 - **Labels** – A map of labels to associate with the service (e.g., 4675 `{"key":"value", "key2":"value2"}`). 4676 - **Mounts** – Specification for mounts to be added to containers 4677 created as part of the service. 4678 - **Target** – Container path. 4679 - **Source** – Mount source (e.g. a volume name, a host path). 4680 - **Type** – The mount type (`bind`, or `volume`). 4681 - **ReadOnly** – A boolean indicating whether the mount should be read-only. 4682 - **BindOptions** - Optional configuration for the `bind` type. 4683 - **Propagation** – A propagation mode with the value `[r]private`, `[r]shared`, or `[r]slave`. 4684 - **VolumeOptions** – Optional configuration for the `volume` type. 4685 - **NoCopy** – A boolean indicating if volume should be 4686 populated with the data from the target. (Default false) 4687 - **Labels** – User-defined name and labels for the volume. 4688 - **DriverConfig** – Map of driver-specific options. 4689 - **Name** - Name of the driver to use to create the volume. 4690 - **Options** - key/value map of driver specific options. 4691 - **StopGracePeriod** – Amount of time to wait for the container to terminate before 4692 forcefully killing it. 4693 - **LogDriver** - Log configuration for containers created as part of the 4694 service. 4695 - **Name** - Name of the logging driver to use (`json-file`, `syslog`, 4696 `journald`, `gelf`, `fluentd`, `awslogs`, `splunk`, `etwlogs`, `none`). 4697 - **Options** - Driver-specific options. 4698 - **Resources** – Resource requirements which apply to each individual container created as part 4699 of the service. 4700 - **Limits** – Define resources limits. 4701 - **NanoCPUs** – CPU limit in units of 10<sup>-9</sup> CPU shares. 4702 - **MemoryBytes** – Memory limit in Bytes. 4703 - **Reservation** – Define resources reservation. 4704 - **NanoCPUs** – CPU reservation in units of 10<sup>-9</sup> CPU shares. 4705 - **MemoryBytes** – Memory reservation in Bytes. 4706 - **RestartPolicy** – Specification for the restart policy which applies to containers created 4707 as part of this service. 4708 - **Condition** – Condition for restart (`none`, `on-failure`, or `any`). 4709 - **Delay** – Delay between restart attempts. 4710 - **MaxAttempts** – Maximum attempts to restart a given container before giving up (default value 4711 is 0, which is ignored). 4712 - **Window** – Windows is the time window used to evaluate the restart policy (default value is 4713 0, which is unbounded). 4714 - **Placement** – Restrictions on where a service can run. 4715 - **Constraints** – An array of constraints, e.g. `[ "node.role == manager" ]`. 4716 - **Mode** – Scheduling mode for the service (`replicated` or `global`, defaults to `replicated`). 4717 - **UpdateConfig** – Specification for the update strategy of the service. 4718 - **Parallelism** – Maximum number of tasks to be updated in one iteration (0 means unlimited 4719 parallelism). 4720 - **Delay** – Amount of time between updates. 4721 - **FailureAction** - Action to take if an updated task fails to run, or stops running during the 4722 update. Values are `continue` and `pause`. 4723 - **Networks** – Array of network names or IDs to attach the service to. 4724 - **EndpointSpec** – Properties that can be configured to access and load balance a service. 4725 - **Mode** – The mode of resolution to use for internal load balancing 4726 between tasks (`vip` or `dnsrr`). Defaults to `vip` if not provided. 4727 - **Ports** – List of exposed ports that this service is accessible on from 4728 the outside, in the form of: 4729 `{"Protocol": <"tcp"|"udp">, "PublishedPort": <port>, "TargetPort": <port>}`. 4730 Ports can only be provided if `vip` resolution mode is used. 4731 4732 **Request Headers**: 4733 4734 - **Content-type** – Set to `"application/json"`. 4735 - **X-Registry-Auth** – base64-encoded AuthConfig object, containing either 4736 login information, or a token. Refer to the [create an image](#create-an-image) 4737 section for more details. 4738 4739 4740 #### Remove a service 4741 4742 4743 `DELETE /services/(id or name)` 4744 4745 Stop and remove the service `id` 4746 4747 **Example request**: 4748 4749 DELETE /v1.24/services/16253994b7c4 HTTP/1.1 4750 4751 **Example response**: 4752 4753 HTTP/1.1 200 OK 4754 Content-Length: 0 4755 Content-Type: text/plain; charset=utf-8 4756 4757 **Status codes**: 4758 4759 - **200** – no error 4760 - **404** – no such service 4761 - **406** - node is not part of a swarm 4762 - **500** – server error 4763 4764 #### Inspect one or more services 4765 4766 4767 `GET /services/(id or name)` 4768 4769 Return information on the service `id`. 4770 4771 **Example request**: 4772 4773 GET /v1.24/services/1cb4dnqcyx6m66g2t538x3rxha HTTP/1.1 4774 4775 **Example response**: 4776 4777 { 4778 "ID": "ak7w3gjqoa3kuz8xcpnyy0pvl", 4779 "Version": { 4780 "Index": 95 4781 }, 4782 "CreatedAt": "2016-06-07T21:10:20.269723157Z", 4783 "UpdatedAt": "2016-06-07T21:10:20.276301259Z", 4784 "Spec": { 4785 "Name": "redis", 4786 "TaskTemplate": { 4787 "ContainerSpec": { 4788 "Image": "redis" 4789 }, 4790 "Resources": { 4791 "Limits": {}, 4792 "Reservations": {} 4793 }, 4794 "RestartPolicy": { 4795 "Condition": "any", 4796 "MaxAttempts": 0 4797 }, 4798 "Placement": {} 4799 }, 4800 "Mode": { 4801 "Replicated": { 4802 "Replicas": 1 4803 } 4804 }, 4805 "UpdateConfig": { 4806 "Parallelism": 1, 4807 "FailureAction": "pause" 4808 }, 4809 "EndpointSpec": { 4810 "Mode": "vip", 4811 "Ports": [ 4812 { 4813 "Protocol": "tcp", 4814 "TargetPort": 6379, 4815 "PublishedPort": 30001 4816 } 4817 ] 4818 } 4819 }, 4820 "Endpoint": { 4821 "Spec": { 4822 "Mode": "vip", 4823 "Ports": [ 4824 { 4825 "Protocol": "tcp", 4826 "TargetPort": 6379, 4827 "PublishedPort": 30001 4828 } 4829 ] 4830 }, 4831 "Ports": [ 4832 { 4833 "Protocol": "tcp", 4834 "TargetPort": 6379, 4835 "PublishedPort": 30001 4836 } 4837 ], 4838 "VirtualIPs": [ 4839 { 4840 "NetworkID": "4qvuz4ko70xaltuqbt8956gd1", 4841 "Addr": "10.255.0.4/16" 4842 } 4843 ] 4844 } 4845 } 4846 4847 **Status codes**: 4848 4849 - **200** – no error 4850 - **404** – no such service 4851 - **406** - node is not part of a swarm 4852 - **500** – server error 4853 4854 #### Update a service 4855 4856 `POST /services/(id)/update` 4857 4858 Update a service. When using this endpoint to create a service using a 4859 private repository from the registry, the `X-Registry-Auth` header can be used 4860 to update the authentication information for that is stored for the service. 4861 The header contains a base64-encoded AuthConfig object. Refer to the [create an 4862 image](#create-an-image) section for more details. 4863 4864 **Example request**: 4865 4866 POST /v1.24/services/1cb4dnqcyx6m66g2t538x3rxha/update?version=23 HTTP/1.1 4867 Content-Type: application/json 4868 4869 { 4870 "Name": "top", 4871 "TaskTemplate": { 4872 "ContainerSpec": { 4873 "Image": "busybox", 4874 "Args": [ 4875 "top" 4876 ] 4877 }, 4878 "Resources": { 4879 "Limits": {}, 4880 "Reservations": {} 4881 }, 4882 "RestartPolicy": { 4883 "Condition": "any", 4884 "MaxAttempts": 0 4885 }, 4886 "Placement": {} 4887 }, 4888 "Mode": { 4889 "Replicated": { 4890 "Replicas": 1 4891 } 4892 }, 4893 "UpdateConfig": { 4894 "Parallelism": 1 4895 }, 4896 "EndpointSpec": { 4897 "Mode": "vip" 4898 } 4899 } 4900 4901 **Example response**: 4902 4903 HTTP/1.1 200 OK 4904 Content-Length: 0 4905 Content-Type: text/plain; charset=utf-8 4906 4907 **JSON Parameters**: 4908 4909 - **Name** – User-defined name for the service. Note that renaming services is not supported. 4910 - **Labels** – A map of labels to associate with the service (e.g., `{"key":"value", "key2":"value2"}`). 4911 - **TaskTemplate** – Specification of the tasks to start as part of the new service. 4912 - **ContainerSpec** - Container settings for containers started as part of this task. 4913 - **Image** – A string specifying the image name to use for the container. 4914 - **Command** – The command to be run in the image. 4915 - **Args** – Arguments to the command. 4916 - **Env** – A list of environment variables in the form of `["VAR=value"[,"VAR2=value2"]]`. 4917 - **Dir** – A string specifying the working directory for commands to run in. 4918 - **User** – A string value specifying the user inside the container. 4919 - **Labels** – A map of labels to associate with the service (e.g., 4920 `{"key":"value", "key2":"value2"}`). 4921 - **Mounts** – Specification for mounts to be added to containers created as part of the new 4922 service. 4923 - **Target** – Container path. 4924 - **Source** – Mount source (e.g. a volume name, a host path). 4925 - **Type** – The mount type (`bind`, or `volume`). 4926 - **ReadOnly** – A boolean indicating whether the mount should be read-only. 4927 - **BindOptions** - Optional configuration for the `bind` type 4928 - **Propagation** – A propagation mode with the value `[r]private`, `[r]shared`, or `[r]slave`. 4929 - **VolumeOptions** – Optional configuration for the `volume` type. 4930 - **NoCopy** – A boolean indicating if volume should be 4931 populated with the data from the target. (Default false) 4932 - **Labels** – User-defined name and labels for the volume. 4933 - **DriverConfig** – Map of driver-specific options. 4934 - **Name** - Name of the driver to use to create the volume 4935 - **Options** - key/value map of driver specific options 4936 - **StopGracePeriod** – Amount of time to wait for the container to terminate before 4937 forcefully killing it. 4938 - **Resources** – Resource requirements which apply to each individual container created as part 4939 of the service. 4940 - **Limits** – Define resources limits. 4941 - **CPU** – CPU limit 4942 - **Memory** – Memory limit 4943 - **Reservation** – Define resources reservation. 4944 - **CPU** – CPU reservation 4945 - **Memory** – Memory reservation 4946 - **RestartPolicy** – Specification for the restart policy which applies to containers created 4947 as part of this service. 4948 - **Condition** – Condition for restart (`none`, `on-failure`, or `any`). 4949 - **Delay** – Delay between restart attempts. 4950 - **MaxAttempts** – Maximum attempts to restart a given container before giving up (default value 4951 is 0, which is ignored). 4952 - **Window** – Windows is the time window used to evaluate the restart policy (default value is 4953 0, which is unbounded). 4954 - **Placement** – Restrictions on where a service can run. 4955 - **Constraints** – An array of constraints, e.g. `[ "node.role == manager" ]`. 4956 - **Mode** – Scheduling mode for the service (`replicated` or `global`, defaults to `replicated`). 4957 - **UpdateConfig** – Specification for the update strategy of the service. 4958 - **Parallelism** – Maximum number of tasks to be updated in one iteration (0 means unlimited 4959 parallelism). 4960 - **Delay** – Amount of time between updates. 4961 - **Networks** – Array of network names or IDs to attach the service to. 4962 - **EndpointSpec** – Properties that can be configured to access and load balance a service. 4963 - **Mode** – The mode of resolution to use for internal load balancing 4964 between tasks (`vip` or `dnsrr`). Defaults to `vip` if not provided. 4965 - **Ports** – List of exposed ports that this service is accessible on from 4966 the outside, in the form of: 4967 `{"Protocol": <"tcp"|"udp">, "PublishedPort": <port>, "TargetPort": <port>}`. 4968 Ports can only be provided if `vip` resolution mode is used. 4969 4970 **Query parameters**: 4971 4972 - **version** – The version number of the service object being updated. This is 4973 required to avoid conflicting writes. 4974 4975 **Request Headers**: 4976 4977 - **Content-type** – Set to `"application/json"`. 4978 - **X-Registry-Auth** – base64-encoded AuthConfig object, containing either 4979 login information, or a token. Refer to the [create an image](#create-an-image) 4980 section for more details. 4981 4982 **Status codes**: 4983 4984 - **200** – no error 4985 - **404** – no such service 4986 - **406** - node is not part of a swarm 4987 - **500** – server error 4988 4989 ### 3.10 Tasks 4990 4991 **Note**: Task operations require the engine to be part of a swarm. 4992 4993 #### List tasks 4994 4995 4996 `GET /tasks` 4997 4998 List tasks 4999 5000 **Example request**: 5001 5002 GET /v1.24/tasks HTTP/1.1 5003 5004 **Example response**: 5005 5006 [ 5007 { 5008 "ID": "0kzzo1i0y4jz6027t0k7aezc7", 5009 "Version": { 5010 "Index": 71 5011 }, 5012 "CreatedAt": "2016-06-07T21:07:31.171892745Z", 5013 "UpdatedAt": "2016-06-07T21:07:31.376370513Z", 5014 "Spec": { 5015 "ContainerSpec": { 5016 "Image": "redis" 5017 }, 5018 "Resources": { 5019 "Limits": {}, 5020 "Reservations": {} 5021 }, 5022 "RestartPolicy": { 5023 "Condition": "any", 5024 "MaxAttempts": 0 5025 }, 5026 "Placement": {} 5027 }, 5028 "ServiceID": "9mnpnzenvg8p8tdbtq4wvbkcz", 5029 "Slot": 1, 5030 "NodeID": "60gvrl6tm78dmak4yl7srz94v", 5031 "Status": { 5032 "Timestamp": "2016-06-07T21:07:31.290032978Z", 5033 "State": "running", 5034 "Message": "started", 5035 "ContainerStatus": { 5036 "ContainerID": "e5d62702a1b48d01c3e02ca1e0212a250801fa8d67caca0b6f35919ebc12f035", 5037 "PID": 677 5038 } 5039 }, 5040 "DesiredState": "running", 5041 "NetworksAttachments": [ 5042 { 5043 "Network": { 5044 "ID": "4qvuz4ko70xaltuqbt8956gd1", 5045 "Version": { 5046 "Index": 18 5047 }, 5048 "CreatedAt": "2016-06-07T20:31:11.912919752Z", 5049 "UpdatedAt": "2016-06-07T21:07:29.955277358Z", 5050 "Spec": { 5051 "Name": "ingress", 5052 "Labels": { 5053 "com.docker.swarm.internal": "true" 5054 }, 5055 "DriverConfiguration": {}, 5056 "IPAMOptions": { 5057 "Driver": {}, 5058 "Configs": [ 5059 { 5060 "Subnet": "10.255.0.0/16", 5061 "Gateway": "10.255.0.1" 5062 } 5063 ] 5064 } 5065 }, 5066 "DriverState": { 5067 "Name": "overlay", 5068 "Options": { 5069 "com.docker.network.driver.overlay.vxlanid_list": "256" 5070 } 5071 }, 5072 "IPAMOptions": { 5073 "Driver": { 5074 "Name": "default" 5075 }, 5076 "Configs": [ 5077 { 5078 "Subnet": "10.255.0.0/16", 5079 "Gateway": "10.255.0.1" 5080 } 5081 ] 5082 } 5083 }, 5084 "Addresses": [ 5085 "10.255.0.10/16" 5086 ] 5087 } 5088 ], 5089 }, 5090 { 5091 "ID": "1yljwbmlr8er2waf8orvqpwms", 5092 "Version": { 5093 "Index": 30 5094 }, 5095 "CreatedAt": "2016-06-07T21:07:30.019104782Z", 5096 "UpdatedAt": "2016-06-07T21:07:30.231958098Z", 5097 "Name": "hopeful_cori", 5098 "Spec": { 5099 "ContainerSpec": { 5100 "Image": "redis" 5101 }, 5102 "Resources": { 5103 "Limits": {}, 5104 "Reservations": {} 5105 }, 5106 "RestartPolicy": { 5107 "Condition": "any", 5108 "MaxAttempts": 0 5109 }, 5110 "Placement": {} 5111 }, 5112 "ServiceID": "9mnpnzenvg8p8tdbtq4wvbkcz", 5113 "Slot": 1, 5114 "NodeID": "60gvrl6tm78dmak4yl7srz94v", 5115 "Status": { 5116 "Timestamp": "2016-06-07T21:07:30.202183143Z", 5117 "State": "shutdown", 5118 "Message": "shutdown", 5119 "ContainerStatus": { 5120 "ContainerID": "1cf8d63d18e79668b0004a4be4c6ee58cddfad2dae29506d8781581d0688a213" 5121 } 5122 }, 5123 "DesiredState": "shutdown", 5124 "NetworksAttachments": [ 5125 { 5126 "Network": { 5127 "ID": "4qvuz4ko70xaltuqbt8956gd1", 5128 "Version": { 5129 "Index": 18 5130 }, 5131 "CreatedAt": "2016-06-07T20:31:11.912919752Z", 5132 "UpdatedAt": "2016-06-07T21:07:29.955277358Z", 5133 "Spec": { 5134 "Name": "ingress", 5135 "Labels": { 5136 "com.docker.swarm.internal": "true" 5137 }, 5138 "DriverConfiguration": {}, 5139 "IPAMOptions": { 5140 "Driver": {}, 5141 "Configs": [ 5142 { 5143 "Subnet": "10.255.0.0/16", 5144 "Gateway": "10.255.0.1" 5145 } 5146 ] 5147 } 5148 }, 5149 "DriverState": { 5150 "Name": "overlay", 5151 "Options": { 5152 "com.docker.network.driver.overlay.vxlanid_list": "256" 5153 } 5154 }, 5155 "IPAMOptions": { 5156 "Driver": { 5157 "Name": "default" 5158 }, 5159 "Configs": [ 5160 { 5161 "Subnet": "10.255.0.0/16", 5162 "Gateway": "10.255.0.1" 5163 } 5164 ] 5165 } 5166 }, 5167 "Addresses": [ 5168 "10.255.0.5/16" 5169 ] 5170 } 5171 ] 5172 } 5173 ] 5174 5175 **Query parameters**: 5176 5177 - **filters** – a JSON encoded value of the filters (a `map[string][]string`) to process on the 5178 services list. Available filters: 5179 - `id=<task id>` 5180 - `name=<task name>` 5181 - `service=<service name>` 5182 - `node=<node id or name>` 5183 - `label=key` or `label="key=value"` 5184 - `desired-state=(running | shutdown | accepted)` 5185 5186 **Status codes**: 5187 5188 - **200** – no error 5189 - **406** - node is not part of a swarm 5190 - **500** – server error 5191 5192 #### Inspect a task 5193 5194 5195 `GET /tasks/(id)` 5196 5197 Get details on the task `id` 5198 5199 **Example request**: 5200 5201 GET /v1.24/tasks/0kzzo1i0y4jz6027t0k7aezc7 HTTP/1.1 5202 5203 **Example response**: 5204 5205 { 5206 "ID": "0kzzo1i0y4jz6027t0k7aezc7", 5207 "Version": { 5208 "Index": 71 5209 }, 5210 "CreatedAt": "2016-06-07T21:07:31.171892745Z", 5211 "UpdatedAt": "2016-06-07T21:07:31.376370513Z", 5212 "Spec": { 5213 "ContainerSpec": { 5214 "Image": "redis" 5215 }, 5216 "Resources": { 5217 "Limits": {}, 5218 "Reservations": {} 5219 }, 5220 "RestartPolicy": { 5221 "Condition": "any", 5222 "MaxAttempts": 0 5223 }, 5224 "Placement": {} 5225 }, 5226 "ServiceID": "9mnpnzenvg8p8tdbtq4wvbkcz", 5227 "Slot": 1, 5228 "NodeID": "60gvrl6tm78dmak4yl7srz94v", 5229 "Status": { 5230 "Timestamp": "2016-06-07T21:07:31.290032978Z", 5231 "State": "running", 5232 "Message": "started", 5233 "ContainerStatus": { 5234 "ContainerID": "e5d62702a1b48d01c3e02ca1e0212a250801fa8d67caca0b6f35919ebc12f035", 5235 "PID": 677 5236 } 5237 }, 5238 "DesiredState": "running", 5239 "NetworksAttachments": [ 5240 { 5241 "Network": { 5242 "ID": "4qvuz4ko70xaltuqbt8956gd1", 5243 "Version": { 5244 "Index": 18 5245 }, 5246 "CreatedAt": "2016-06-07T20:31:11.912919752Z", 5247 "UpdatedAt": "2016-06-07T21:07:29.955277358Z", 5248 "Spec": { 5249 "Name": "ingress", 5250 "Labels": { 5251 "com.docker.swarm.internal": "true" 5252 }, 5253 "DriverConfiguration": {}, 5254 "IPAMOptions": { 5255 "Driver": {}, 5256 "Configs": [ 5257 { 5258 "Subnet": "10.255.0.0/16", 5259 "Gateway": "10.255.0.1" 5260 } 5261 ] 5262 } 5263 }, 5264 "DriverState": { 5265 "Name": "overlay", 5266 "Options": { 5267 "com.docker.network.driver.overlay.vxlanid_list": "256" 5268 } 5269 }, 5270 "IPAMOptions": { 5271 "Driver": { 5272 "Name": "default" 5273 }, 5274 "Configs": [ 5275 { 5276 "Subnet": "10.255.0.0/16", 5277 "Gateway": "10.255.0.1" 5278 } 5279 ] 5280 } 5281 }, 5282 "Addresses": [ 5283 "10.255.0.10/16" 5284 ] 5285 } 5286 ] 5287 } 5288 5289 **Status codes**: 5290 5291 - **200** – no error 5292 - **404** – unknown task 5293 - **406** - node is not part of a swarm 5294 - **500** – server error 5295 5296 ## 4. Going further 5297 5298 ### 4.1 Inside `docker run` 5299 5300 As an example, the `docker run` command line makes the following API calls: 5301 5302 - Create the container 5303 5304 - If the status code is 404, it means the image doesn't exist: 5305 - Try to pull it. 5306 - Then, retry to create the container. 5307 5308 - Start the container. 5309 5310 - If you are not in detached mode: 5311 - Attach to the container, using `logs=1` (to have `stdout` and 5312 `stderr` from the container's start) and `stream=1` 5313 5314 - If in detached mode or only `stdin` is attached, display the container's id. 5315 5316 ### 4.2 Hijacking 5317 5318 In this version of the API, `/attach`, uses hijacking to transport `stdin`, 5319 `stdout`, and `stderr` on the same socket. 5320 5321 To hint potential proxies about connection hijacking, Docker client sends 5322 connection upgrade headers similarly to websocket. 5323 5324 Upgrade: tcp 5325 Connection: Upgrade 5326 5327 When Docker daemon detects the `Upgrade` header, it switches its status code 5328 from **200 OK** to **101 UPGRADED** and resends the same headers. 5329 5330 5331 ### 4.3 CORS Requests 5332 5333 To set cross origin requests to the Engine API please give values to 5334 `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, 5335 default or blank means CORS disabled 5336 5337 $ dockerd -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"