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