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