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