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