gitee.com/bomy/docker.git@v1.13.1/docs/api/v1.23.md (about) 1 --- 2 title: "Engine API v1.23" 3 description: "API Documentation for Docker" 4 keywords: "API, Docker, rcli, REST, documentation" 5 redirect_from: 6 - /engine/reference/api/docker_remote_api_v1.23/ 7 - /reference/api/docker_remote_api_v1.23/ 8 --- 9 10 <!-- This file is maintained within the docker/docker Github 11 repository at https://github.com/docker/docker/. Make all 12 pull requests against that repo. If you see this file in 13 another repository, consider it read-only there, as it will 14 periodically be overwritten by the definitive file. Pull 15 requests which include edits to this file in other repositories 16 will be rejected. 17 --> 18 19 ## 1. Brief introduction 20 21 - The daemon listens on `unix:///var/run/docker.sock` but you can 22 [Bind Docker to another host/port or a Unix socket](../reference/commandline/dockerd.md#bind-docker-to-another-host-port-or-a-unix-socket). 23 - The API tends to be REST. However, for some complex commands, like `attach` 24 or `pull`, the HTTP connection is hijacked to transport `stdout`, 25 `stdin` and `stderr`. 26 - 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. Endpoints 30 31 ### 2.1 Containers 32 33 #### List containers 34 35 `GET /containers/json` 36 37 List containers 38 39 **Example request**: 40 41 GET /v1.23/containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1 42 43 **Example response**: 44 45 HTTP/1.1 200 OK 46 Content-Type: application/json 47 48 [ 49 { 50 "Id": "8dfafdbc3a40", 51 "Names":["/boring_feynman"], 52 "Image": "ubuntu:latest", 53 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", 54 "Command": "echo 1", 55 "Created": 1367854155, 56 "State": "Exited", 57 "Status": "Exit 0", 58 "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}], 59 "Labels": { 60 "com.example.vendor": "Acme", 61 "com.example.license": "GPL", 62 "com.example.version": "1.0" 63 }, 64 "SizeRw": 12288, 65 "SizeRootFs": 0, 66 "HostConfig": { 67 "NetworkMode": "default" 68 }, 69 "NetworkSettings": { 70 "Networks": { 71 "bridge": { 72 "IPAMConfig": null, 73 "Links": null, 74 "Aliases": null, 75 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 76 "EndpointID": "2cdc4edb1ded3631c81f57966563e5c8525b81121bb3706a9a9a3ae102711f3f", 77 "Gateway": "172.17.0.1", 78 "IPAddress": "172.17.0.2", 79 "IPPrefixLen": 16, 80 "IPv6Gateway": "", 81 "GlobalIPv6Address": "", 82 "GlobalIPv6PrefixLen": 0, 83 "MacAddress": "02:42:ac:11:00:02" 84 } 85 } 86 }, 87 "Mounts": [ 88 { 89 "Name": "fac362...80535", 90 "Source": "/data", 91 "Destination": "/data", 92 "Driver": "local", 93 "Mode": "ro,Z", 94 "RW": false, 95 "Propagation": "" 96 } 97 ] 98 }, 99 { 100 "Id": "9cd87474be90", 101 "Names":["/coolName"], 102 "Image": "ubuntu:latest", 103 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", 104 "Command": "echo 222222", 105 "Created": 1367854155, 106 "State": "Exited", 107 "Status": "Exit 0", 108 "Ports": [], 109 "Labels": {}, 110 "SizeRw": 12288, 111 "SizeRootFs": 0, 112 "HostConfig": { 113 "NetworkMode": "default" 114 }, 115 "NetworkSettings": { 116 "Networks": { 117 "bridge": { 118 "IPAMConfig": null, 119 "Links": null, 120 "Aliases": null, 121 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 122 "EndpointID": "88eaed7b37b38c2a3f0c4bc796494fdf51b270c2d22656412a2ca5d559a64d7a", 123 "Gateway": "172.17.0.1", 124 "IPAddress": "172.17.0.8", 125 "IPPrefixLen": 16, 126 "IPv6Gateway": "", 127 "GlobalIPv6Address": "", 128 "GlobalIPv6PrefixLen": 0, 129 "MacAddress": "02:42:ac:11:00:08" 130 } 131 } 132 }, 133 "Mounts": [] 134 }, 135 { 136 "Id": "3176a2479c92", 137 "Names":["/sleepy_dog"], 138 "Image": "ubuntu:latest", 139 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", 140 "Command": "echo 3333333333333333", 141 "Created": 1367854154, 142 "State": "Exited", 143 "Status": "Exit 0", 144 "Ports":[], 145 "Labels": {}, 146 "SizeRw":12288, 147 "SizeRootFs":0, 148 "HostConfig": { 149 "NetworkMode": "default" 150 }, 151 "NetworkSettings": { 152 "Networks": { 153 "bridge": { 154 "IPAMConfig": null, 155 "Links": null, 156 "Aliases": null, 157 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 158 "EndpointID": "8b27c041c30326d59cd6e6f510d4f8d1d570a228466f956edf7815508f78e30d", 159 "Gateway": "172.17.0.1", 160 "IPAddress": "172.17.0.6", 161 "IPPrefixLen": 16, 162 "IPv6Gateway": "", 163 "GlobalIPv6Address": "", 164 "GlobalIPv6PrefixLen": 0, 165 "MacAddress": "02:42:ac:11:00:06" 166 } 167 } 168 }, 169 "Mounts": [] 170 }, 171 { 172 "Id": "4cb07b47f9fb", 173 "Names":["/running_cat"], 174 "Image": "ubuntu:latest", 175 "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", 176 "Command": "echo 444444444444444444444444444444444", 177 "Created": 1367854152, 178 "State": "Exited", 179 "Status": "Exit 0", 180 "Ports": [], 181 "Labels": {}, 182 "SizeRw": 12288, 183 "SizeRootFs": 0, 184 "HostConfig": { 185 "NetworkMode": "default" 186 }, 187 "NetworkSettings": { 188 "Networks": { 189 "bridge": { 190 "IPAMConfig": null, 191 "Links": null, 192 "Aliases": null, 193 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 194 "EndpointID": "d91c7b2f0644403d7ef3095985ea0e2370325cd2332ff3a3225c4247328e66e9", 195 "Gateway": "172.17.0.1", 196 "IPAddress": "172.17.0.5", 197 "IPPrefixLen": 16, 198 "IPv6Gateway": "", 199 "GlobalIPv6Address": "", 200 "GlobalIPv6PrefixLen": 0, 201 "MacAddress": "02:42:ac:11:00:05" 202 } 203 } 204 }, 205 "Mounts": [] 206 } 207 ] 208 209 **Query parameters**: 210 211 - **all** – 1/True/true or 0/False/false, Show all containers. 212 Only running containers are shown by default (i.e., this defaults to false) 213 - **limit** – Show `limit` last created 214 containers, include non-running ones. 215 - **since** – Show only containers created since Id, include 216 non-running ones. 217 - **before** – Show only containers created before Id, include 218 non-running ones. 219 - **size** – 1/True/true or 0/False/false, Show the containers 220 sizes 221 - **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters: 222 - `exited=<int>`; -- containers with exit code of `<int>` ; 223 - `status=`(`created`|`restarting`|`running`|`paused`|`exited`|`dead`) 224 - `label=key` or `label="key=value"` of a container label 225 - `isolation=`(`default`|`process`|`hyperv`) (Windows daemon only) 226 - `ancestor`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) 227 - `before`=(`<container id>` or `<container name>`) 228 - `since`=(`<container id>` or `<container name>`) 229 - `volume`=(`<volume name>` or `<mount point destination>`) 230 231 **Status codes**: 232 233 - **200** – no error 234 - **400** – bad parameter 235 - **500** – server error 236 237 #### Create a container 238 239 `POST /containers/create` 240 241 Create a container 242 243 **Example request**: 244 245 POST /v1.23/containers/create HTTP/1.1 246 Content-Type: application/json 247 248 { 249 "Hostname": "", 250 "Domainname": "", 251 "User": "", 252 "AttachStdin": false, 253 "AttachStdout": true, 254 "AttachStderr": true, 255 "Tty": false, 256 "OpenStdin": false, 257 "StdinOnce": false, 258 "Env": [ 259 "FOO=bar", 260 "BAZ=quux" 261 ], 262 "Cmd": [ 263 "date" 264 ], 265 "Entrypoint": "", 266 "Image": "ubuntu", 267 "Labels": { 268 "com.example.vendor": "Acme", 269 "com.example.license": "GPL", 270 "com.example.version": "1.0" 271 }, 272 "Volumes": { 273 "/volumes/data": {} 274 }, 275 "WorkingDir": "", 276 "NetworkDisabled": false, 277 "MacAddress": "12:34:56:78:9a:bc", 278 "ExposedPorts": { 279 "22/tcp": {} 280 }, 281 "StopSignal": "SIGTERM", 282 "HostConfig": { 283 "Binds": ["/tmp:/tmp"], 284 "Tmpfs": { "/run": "rw,noexec,nosuid,size=65536k" }, 285 "Links": ["redis3:redis"], 286 "Memory": 0, 287 "MemorySwap": 0, 288 "MemoryReservation": 0, 289 "KernelMemory": 0, 290 "CpuShares": 512, 291 "CpuPeriod": 100000, 292 "CpuQuota": 50000, 293 "CpusetCpus": "0,1", 294 "CpusetMems": "0,1", 295 "BlkioWeight": 300, 296 "BlkioWeightDevice": [{}], 297 "BlkioDeviceReadBps": [{}], 298 "BlkioDeviceReadIOps": [{}], 299 "BlkioDeviceWriteBps": [{}], 300 "BlkioDeviceWriteIOps": [{}], 301 "MemorySwappiness": 60, 302 "OomKillDisable": false, 303 "OomScoreAdj": 500, 304 "PidMode": "", 305 "PidsLimit": -1, 306 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] }, 307 "PublishAllPorts": false, 308 "Privileged": false, 309 "ReadonlyRootfs": false, 310 "Dns": ["8.8.8.8"], 311 "DnsOptions": [""], 312 "DnsSearch": [""], 313 "ExtraHosts": null, 314 "VolumesFrom": ["parent", "other:ro"], 315 "CapAdd": ["NET_ADMIN"], 316 "CapDrop": ["MKNOD"], 317 "GroupAdd": ["newgroup"], 318 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 }, 319 "NetworkMode": "bridge", 320 "Devices": [], 321 "Ulimits": [{}], 322 "LogConfig": { "Type": "json-file", "Config": {} }, 323 "SecurityOpt": [], 324 "CgroupParent": "", 325 "VolumeDriver": "", 326 "ShmSize": 67108864 327 }, 328 "NetworkingConfig": { 329 "EndpointsConfig": { 330 "isolated_nw" : { 331 "IPAMConfig": { 332 "IPv4Address":"172.20.30.33", 333 "IPv6Address":"2001:db8:abcd::3033" 334 }, 335 "Links":["container_1", "container_2"], 336 "Aliases":["server_x", "server_y"] 337 } 338 } 339 } 340 } 341 342 **Example response**: 343 344 HTTP/1.1 201 Created 345 Content-Type: application/json 346 347 { 348 "Id":"e90e34656806", 349 "Warnings":[] 350 } 351 352 **JSON parameters**: 353 354 - **Hostname** - A string value containing the hostname to use for the 355 container. 356 - **Domainname** - A string value containing the domain name to use 357 for the container. 358 - **User** - A string value specifying the user inside the container. 359 - **AttachStdin** - Boolean value, attaches to `stdin`. 360 - **AttachStdout** - Boolean value, attaches to `stdout`. 361 - **AttachStderr** - Boolean value, attaches to `stderr`. 362 - **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed. 363 - **OpenStdin** - Boolean value, opens `stdin`, 364 - **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects. 365 - **Env** - A list of environment variables in the form of `["VAR=value", ...]` 366 - **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value", ... }` 367 - **Cmd** - Command to run specified as a string or an array of strings. 368 - **Entrypoint** - Set the entry point for the container as a string or an array 369 of strings. 370 - **Image** - A string specifying the image name to use for the container. 371 - **Volumes** - An object mapping mount point paths (strings) inside the 372 container to empty objects. 373 - **WorkingDir** - A string specifying the working directory for commands to 374 run in. 375 - **NetworkDisabled** - Boolean value, when true disables networking for the 376 container 377 - **ExposedPorts** - An object mapping ports to an empty object in the form of: 378 `"ExposedPorts": { "<port>/<tcp|udp>: {}" }` 379 - **StopSignal** - Signal to stop a container as a string or unsigned integer. `SIGTERM` by default. 380 - **HostConfig** 381 - **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms: 382 + `host-src:container-dest` to bind-mount a host path into the 383 container. Both `host-src`, and `container-dest` must be an 384 _absolute_ path. 385 + `host-src:container-dest:ro` to make the bind-mount read-only 386 inside the container. Both `host-src`, and `container-dest` must be 387 an _absolute_ path. 388 + `volume-name:container-dest` to bind-mount a volume managed by a 389 volume driver into the container. `container-dest` must be an 390 _absolute_ path. 391 + `volume-name:container-dest:ro` to mount the volume read-only 392 inside the container. `container-dest` must be an _absolute_ path. 393 - **Tmpfs** – A map of container directories which should be replaced by tmpfs mounts, and their corresponding 394 mount options. A JSON object in the form `{ "/run": "rw,noexec,nosuid,size=65536k" }`. 395 - **Links** - A list of links for the container. Each link entry should be 396 in the form of `container_name:alias`. 397 - **Memory** - Memory limit in bytes. 398 - **MemorySwap** - Total memory limit (memory + swap); set `-1` to enable unlimited swap. 399 You must use this with `memory` and make the swap value larger than `memory`. 400 - **MemoryReservation** - Memory soft limit in bytes. 401 - **KernelMemory** - Kernel memory limit in bytes. 402 - **CpuShares** - An integer value containing the container's CPU Shares 403 (ie. the relative weight vs other containers). 404 - **CpuPeriod** - The length of a CPU period in microseconds. 405 - **CpuQuota** - Microseconds of CPU time that the container can get in a CPU period. 406 - **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use. 407 - **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. 408 - **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000. 409 - **BlkioWeightDevice** - Block IO weight (relative device weight) in the form of: `"BlkioWeightDevice": [{"Path": "device_path", "Weight": weight}]` 410 - **BlkioDeviceReadBps** - Limit read rate (bytes per second) from a device in the form of: `"BlkioDeviceReadBps": [{"Path": "device_path", "Rate": rate}]`, for example: 411 `"BlkioDeviceReadBps": [{"Path": "/dev/sda", "Rate": "1024"}]"` 412 - **BlkioDeviceWriteBps** - Limit write rate (bytes per second) to a device in the form of: `"BlkioDeviceWriteBps": [{"Path": "device_path", "Rate": rate}]`, for example: 413 `"BlkioDeviceWriteBps": [{"Path": "/dev/sda", "Rate": "1024"}]"` 414 - **BlkioDeviceReadIOps** - Limit read rate (IO per second) from a device in the form of: `"BlkioDeviceReadIOps": [{"Path": "device_path", "Rate": rate}]`, for example: 415 `"BlkioDeviceReadIOps": [{"Path": "/dev/sda", "Rate": "1000"}]` 416 - **BlkioDeviceWiiteIOps** - Limit write rate (IO per second) to a device in the form of: `"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]`, for example: 417 `"BlkioDeviceWriteIOps": [{"Path": "/dev/sda", "Rate": "1000"}]` 418 - **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100. 419 - **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not. 420 - **OomScoreAdj** - An integer value containing the score given to the container in order to tune OOM killer preferences. 421 - **PidMode** - Set the PID (Process) Namespace mode for the container; 422 `"container:<name|id>"`: joins another container's PID namespace 423 `"host"`: use the host's PID namespace inside the container 424 - **PidsLimit** - Tune a container's pids limit. Set -1 for unlimited. 425 - **PortBindings** - A map of exposed container ports and the host port they 426 should map to. A JSON object in the form 427 `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }` 428 Take note that `port` is specified as a string and not an integer value. 429 - **PublishAllPorts** - Allocates a random host port for all of a container's 430 exposed ports. Specified as a boolean value. 431 - **Privileged** - Gives the container full access to the host. Specified as 432 a boolean value. 433 - **ReadonlyRootfs** - Mount the container's root filesystem as read only. 434 Specified as a boolean value. 435 - **Dns** - A list of DNS servers for the container to use. 436 - **DnsOptions** - A list of DNS options 437 - **DnsSearch** - A list of DNS search domains 438 - **ExtraHosts** - A list of hostnames/IP mappings to add to the 439 container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`. 440 - **VolumesFrom** - A list of volumes to inherit from another container. 441 Specified in the form `<container name>[:<ro|rw>]` 442 - **CapAdd** - A list of kernel capabilities to add to the container. 443 - **Capdrop** - A list of kernel capabilities to drop from the container. 444 - **GroupAdd** - A list of additional groups that the container process will run as 445 - **RestartPolicy** – The behavior to apply when the container exits. The 446 value is an object with a `Name` property of either `"always"` to 447 always restart, `"unless-stopped"` to restart always except when 448 user has manually stopped the container or `"on-failure"` to restart only when the container 449 exit code is non-zero. If `on-failure` is used, `MaximumRetryCount` 450 controls the number of times to retry before giving up. 451 The default is not to restart. (optional) 452 An ever increasing delay (double the previous delay, starting at 100mS) 453 is added before each restart to prevent flooding the server. 454 - **UsernsMode** - Sets the usernamespace mode for the container when usernamespace remapping option is enabled. 455 supported values are: `host`. 456 - **NetworkMode** - Sets the networking mode for the container. Supported 457 standard values are: `bridge`, `host`, `none`, and `container:<name|id>`. Any other value is taken 458 as a custom network's name to which this container should connect to. 459 - **Devices** - A list of devices to add to the container specified as a JSON object in the 460 form 461 `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}` 462 - **Ulimits** - A list of ulimits to set in the container, specified as 463 `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example: 464 `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }` 465 - **SecurityOpt**: A list of string values to customize labels for MLS 466 systems, such as SELinux. 467 - **LogConfig** - Log configuration for the container, specified as a JSON object in the form 468 `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`. 469 Available types: `json-file`, `syslog`, `journald`, `gelf`, `fluentd`, `awslogs`, `splunk`, `etwlogs`, `none`. 470 `json-file` logging driver. 471 - **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. 472 - **VolumeDriver** - Driver that this container users to mount volumes. 473 - **ShmSize** - Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB. 474 475 **Query parameters**: 476 477 - **name** – Assign the specified name to the container. Must 478 match `/?[a-zA-Z0-9_-]+`. 479 480 **Status codes**: 481 482 - **201** – no error 483 - **400** – bad parameter 484 - **404** – no such container 485 - **406** – impossible to attach (container not running) 486 - **409** – conflict 487 - **500** – server error 488 489 #### Inspect a container 490 491 `GET /containers/(id or name)/json` 492 493 Return low-level information on the container `id` 494 495 **Example request**: 496 497 GET /v1.23/containers/4fa6e0f0c678/json HTTP/1.1 498 499 **Example response**: 500 501 HTTP/1.1 200 OK 502 Content-Type: application/json 503 504 { 505 "AppArmorProfile": "", 506 "Args": [ 507 "-c", 508 "exit 9" 509 ], 510 "Config": { 511 "AttachStderr": true, 512 "AttachStdin": false, 513 "AttachStdout": true, 514 "Cmd": [ 515 "/bin/sh", 516 "-c", 517 "exit 9" 518 ], 519 "Domainname": "", 520 "Entrypoint": null, 521 "Env": [ 522 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 523 ], 524 "ExposedPorts": null, 525 "Hostname": "ba033ac44011", 526 "Image": "ubuntu", 527 "Labels": { 528 "com.example.vendor": "Acme", 529 "com.example.license": "GPL", 530 "com.example.version": "1.0" 531 }, 532 "MacAddress": "", 533 "NetworkDisabled": false, 534 "OnBuild": null, 535 "OpenStdin": false, 536 "StdinOnce": false, 537 "Tty": false, 538 "User": "", 539 "Volumes": { 540 "/volumes/data": {} 541 }, 542 "WorkingDir": "", 543 "StopSignal": "SIGTERM" 544 }, 545 "Created": "2015-01-06T15:47:31.485331387Z", 546 "Driver": "devicemapper", 547 "ExecIDs": null, 548 "HostConfig": { 549 "Binds": null, 550 "BlkioWeight": 0, 551 "BlkioWeightDevice": [{}], 552 "BlkioDeviceReadBps": [{}], 553 "BlkioDeviceWriteBps": [{}], 554 "BlkioDeviceReadIOps": [{}], 555 "BlkioDeviceWriteIOps": [{}], 556 "CapAdd": null, 557 "CapDrop": null, 558 "ContainerIDFile": "", 559 "CpusetCpus": "", 560 "CpusetMems": "", 561 "CpuShares": 0, 562 "CpuPeriod": 100000, 563 "Devices": [], 564 "Dns": null, 565 "DnsOptions": null, 566 "DnsSearch": null, 567 "ExtraHosts": null, 568 "IpcMode": "", 569 "Links": null, 570 "LxcConf": [], 571 "Memory": 0, 572 "MemorySwap": 0, 573 "MemoryReservation": 0, 574 "KernelMemory": 0, 575 "OomKillDisable": false, 576 "OomScoreAdj": 500, 577 "NetworkMode": "bridge", 578 "PidMode": "", 579 "PortBindings": {}, 580 "Privileged": false, 581 "ReadonlyRootfs": false, 582 "PublishAllPorts": false, 583 "RestartPolicy": { 584 "MaximumRetryCount": 2, 585 "Name": "on-failure" 586 }, 587 "LogConfig": { 588 "Config": null, 589 "Type": "json-file" 590 }, 591 "SecurityOpt": null, 592 "VolumesFrom": null, 593 "Ulimits": [{}], 594 "VolumeDriver": "", 595 "ShmSize": 67108864 596 }, 597 "HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname", 598 "HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts", 599 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log", 600 "Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39", 601 "Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2", 602 "MountLabel": "", 603 "Name": "/boring_euclid", 604 "NetworkSettings": { 605 "Bridge": "", 606 "SandboxID": "", 607 "HairpinMode": false, 608 "LinkLocalIPv6Address": "", 609 "LinkLocalIPv6PrefixLen": 0, 610 "Ports": null, 611 "SandboxKey": "", 612 "SecondaryIPAddresses": null, 613 "SecondaryIPv6Addresses": null, 614 "EndpointID": "", 615 "Gateway": "", 616 "GlobalIPv6Address": "", 617 "GlobalIPv6PrefixLen": 0, 618 "IPAddress": "", 619 "IPPrefixLen": 0, 620 "IPv6Gateway": "", 621 "MacAddress": "", 622 "Networks": { 623 "bridge": { 624 "NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", 625 "EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d", 626 "Gateway": "172.17.0.1", 627 "IPAddress": "172.17.0.2", 628 "IPPrefixLen": 16, 629 "IPv6Gateway": "", 630 "GlobalIPv6Address": "", 631 "GlobalIPv6PrefixLen": 0, 632 "MacAddress": "02:42:ac:12:00:02" 633 } 634 } 635 }, 636 "Path": "/bin/sh", 637 "ProcessLabel": "", 638 "ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf", 639 "RestartCount": 1, 640 "State": { 641 "Error": "", 642 "ExitCode": 9, 643 "FinishedAt": "2015-01-06T15:47:32.080254511Z", 644 "OOMKilled": false, 645 "Dead": false, 646 "Paused": false, 647 "Pid": 0, 648 "Restarting": false, 649 "Running": true, 650 "StartedAt": "2015-01-06T15:47:32.072697474Z", 651 "Status": "running" 652 }, 653 "Mounts": [ 654 { 655 "Name": "fac362...80535", 656 "Source": "/data", 657 "Destination": "/data", 658 "Driver": "local", 659 "Mode": "ro,Z", 660 "RW": false, 661 "Propagation": "" 662 } 663 ] 664 } 665 666 **Example request, with size information**: 667 668 GET /v1.23/containers/4fa6e0f0c678/json?size=1 HTTP/1.1 669 670 **Example response, with size information**: 671 672 HTTP/1.1 200 OK 673 Content-Type: application/json 674 675 { 676 .... 677 "SizeRw": 0, 678 "SizeRootFs": 972, 679 .... 680 } 681 682 **Query parameters**: 683 684 - **size** – 1/True/true or 0/False/false, return container size information. Default is `false`. 685 686 **Status codes**: 687 688 - **200** – no error 689 - **404** – no such container 690 - **500** – server error 691 692 #### List processes running inside a container 693 694 `GET /containers/(id or name)/top` 695 696 List processes running inside the container `id`. On Unix systems this 697 is done by running the `ps` command. This endpoint is not 698 supported on Windows. 699 700 **Example request**: 701 702 GET /v1.23/containers/4fa6e0f0c678/top HTTP/1.1 703 704 **Example response**: 705 706 HTTP/1.1 200 OK 707 Content-Type: application/json 708 709 { 710 "Titles" : [ 711 "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD" 712 ], 713 "Processes" : [ 714 [ 715 "root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash" 716 ], 717 [ 718 "root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10" 719 ] 720 ] 721 } 722 723 **Example request**: 724 725 GET /v1.23/containers/4fa6e0f0c678/top?ps_args=aux HTTP/1.1 726 727 **Example response**: 728 729 HTTP/1.1 200 OK 730 Content-Type: application/json 731 732 { 733 "Titles" : [ 734 "USER","PID","%CPU","%MEM","VSZ","RSS","TTY","STAT","START","TIME","COMMAND" 735 ] 736 "Processes" : [ 737 [ 738 "root","13642","0.0","0.1","18172","3184","pts/0","Ss","17:03","0:00","/bin/bash" 739 ], 740 [ 741 "root","13895","0.0","0.0","4348","692","pts/0","S+","17:15","0:00","sleep 10" 742 ] 743 ], 744 } 745 746 **Query parameters**: 747 748 - **ps_args** – `ps` arguments to use (e.g., `aux`), defaults to `-ef` 749 750 **Status codes**: 751 752 - **200** – no error 753 - **404** – no such container 754 - **500** – server error 755 756 #### Get container logs 757 758 `GET /containers/(id or name)/logs` 759 760 Get `stdout` and `stderr` logs from the container ``id`` 761 762 > **Note**: 763 > This endpoint works only for containers with the `json-file` or `journald` logging drivers. 764 765 **Example request**: 766 767 GET /v1.23/containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1 768 769 **Example response**: 770 771 HTTP/1.1 101 UPGRADED 772 Content-Type: application/vnd.docker.raw-stream 773 Connection: Upgrade 774 Upgrade: tcp 775 776 {% raw %} 777 {{ STREAM }} 778 {% endraw %} 779 780 **Query parameters**: 781 782 - **follow** – 1/True/true or 0/False/false, return stream. Default `false`. 783 - **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`. 784 - **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`. 785 - **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp 786 will only output log-entries since that timestamp. Default: 0 (unfiltered) 787 - **timestamps** – 1/True/true or 0/False/false, print timestamps for 788 every log line. Default `false`. 789 - **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all. 790 791 **Status codes**: 792 793 - **101** – no error, hints proxy about hijacking 794 - **200** – no error, no upgrade header found 795 - **404** – no such container 796 - **500** – server error 797 798 #### Inspect changes on a container's filesystem 799 800 `GET /containers/(id or name)/changes` 801 802 Inspect changes on container `id`'s filesystem 803 804 **Example request**: 805 806 GET /v1.23/containers/4fa6e0f0c678/changes HTTP/1.1 807 808 **Example response**: 809 810 HTTP/1.1 200 OK 811 Content-Type: application/json 812 813 [ 814 { 815 "Path": "/dev", 816 "Kind": 0 817 }, 818 { 819 "Path": "/dev/kmsg", 820 "Kind": 1 821 }, 822 { 823 "Path": "/test", 824 "Kind": 1 825 } 826 ] 827 828 Values for `Kind`: 829 830 - `0`: Modify 831 - `1`: Add 832 - `2`: Delete 833 834 **Status codes**: 835 836 - **200** – no error 837 - **404** – no such container 838 - **500** – server error 839 840 #### Export a container 841 842 `GET /containers/(id or name)/export` 843 844 Export the contents of container `id` 845 846 **Example request**: 847 848 GET /v1.23/containers/4fa6e0f0c678/export HTTP/1.1 849 850 **Example response**: 851 852 HTTP/1.1 200 OK 853 Content-Type: application/octet-stream 854 855 {% raw %} 856 {{ TAR STREAM }} 857 {% endraw %} 858 859 **Status codes**: 860 861 - **200** – no error 862 - **404** – no such container 863 - **500** – server error 864 865 #### Get container stats based on resource usage 866 867 `GET /containers/(id or name)/stats` 868 869 This endpoint returns a live stream of a container's resource usage statistics. 870 871 **Example request**: 872 873 GET /v1.23/containers/redis1/stats HTTP/1.1 874 875 **Example response**: 876 877 HTTP/1.1 200 OK 878 Content-Type: application/json 879 880 { 881 "read" : "2015-01-08T22:57:31.547920715Z", 882 "pids_stats": { 883 "current": 3 884 }, 885 "networks": { 886 "eth0": { 887 "rx_bytes": 5338, 888 "rx_dropped": 0, 889 "rx_errors": 0, 890 "rx_packets": 36, 891 "tx_bytes": 648, 892 "tx_dropped": 0, 893 "tx_errors": 0, 894 "tx_packets": 8 895 }, 896 "eth5": { 897 "rx_bytes": 4641, 898 "rx_dropped": 0, 899 "rx_errors": 0, 900 "rx_packets": 26, 901 "tx_bytes": 690, 902 "tx_dropped": 0, 903 "tx_errors": 0, 904 "tx_packets": 9 905 } 906 }, 907 "memory_stats" : { 908 "stats" : { 909 "total_pgmajfault" : 0, 910 "cache" : 0, 911 "mapped_file" : 0, 912 "total_inactive_file" : 0, 913 "pgpgout" : 414, 914 "rss" : 6537216, 915 "total_mapped_file" : 0, 916 "writeback" : 0, 917 "unevictable" : 0, 918 "pgpgin" : 477, 919 "total_unevictable" : 0, 920 "pgmajfault" : 0, 921 "total_rss" : 6537216, 922 "total_rss_huge" : 6291456, 923 "total_writeback" : 0, 924 "total_inactive_anon" : 0, 925 "rss_huge" : 6291456, 926 "hierarchical_memory_limit" : 67108864, 927 "total_pgfault" : 964, 928 "total_active_file" : 0, 929 "active_anon" : 6537216, 930 "total_active_anon" : 6537216, 931 "total_pgpgout" : 414, 932 "total_cache" : 0, 933 "inactive_anon" : 0, 934 "active_file" : 0, 935 "pgfault" : 964, 936 "inactive_file" : 0, 937 "total_pgpgin" : 477 938 }, 939 "max_usage" : 6651904, 940 "usage" : 6537216, 941 "failcnt" : 0, 942 "limit" : 67108864 943 }, 944 "blkio_stats" : {}, 945 "cpu_stats" : { 946 "cpu_usage" : { 947 "percpu_usage" : [ 948 8646879, 949 24472255, 950 36438778, 951 30657443 952 ], 953 "usage_in_usermode" : 50000000, 954 "total_usage" : 100215355, 955 "usage_in_kernelmode" : 30000000 956 }, 957 "system_cpu_usage" : 739306590000000, 958 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0} 959 }, 960 "precpu_stats" : { 961 "cpu_usage" : { 962 "percpu_usage" : [ 963 8646879, 964 24350896, 965 36438778, 966 30657443 967 ], 968 "usage_in_usermode" : 50000000, 969 "total_usage" : 100093996, 970 "usage_in_kernelmode" : 30000000 971 }, 972 "system_cpu_usage" : 9492140000000, 973 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0} 974 } 975 } 976 977 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. 978 979 **Query parameters**: 980 981 - **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`. 982 983 **Status codes**: 984 985 - **200** – no error 986 - **404** – no such container 987 - **500** – server error 988 989 #### Resize a container TTY 990 991 `POST /containers/(id or name)/resize` 992 993 Resize the TTY for container with `id`. The unit is number of characters. You must restart the container for the resize to take effect. 994 995 **Example request**: 996 997 POST /v1.23/containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1 998 999 **Example response**: 1000 1001 HTTP/1.1 200 OK 1002 Content-Length: 0 1003 Content-Type: text/plain; charset=utf-8 1004 1005 **Query parameters**: 1006 1007 - **h** – height of `tty` session 1008 - **w** – width 1009 1010 **Status codes**: 1011 1012 - **200** – no error 1013 - **404** – No such container 1014 - **500** – Cannot resize container 1015 1016 #### Start a container 1017 1018 `POST /containers/(id or name)/start` 1019 1020 Start the container `id` 1021 1022 > **Note**: 1023 > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body. 1024 > See [create a container](#create-a-container) for details. 1025 1026 **Example request**: 1027 1028 POST /v1.23/containers/e90e34656806/start HTTP/1.1 1029 1030 **Example response**: 1031 1032 HTTP/1.1 204 No Content 1033 1034 **Query parameters**: 1035 1036 - **detachKeys** – Override the key sequence for detaching a 1037 container. Format is a single character `[a-Z]` or `ctrl-<value>` 1038 where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 1039 1040 **Status codes**: 1041 1042 - **204** – no error 1043 - **304** – container already started 1044 - **404** – no such container 1045 - **500** – server error 1046 1047 #### Stop a container 1048 1049 `POST /containers/(id or name)/stop` 1050 1051 Stop the container `id` 1052 1053 **Example request**: 1054 1055 POST /v1.23/containers/e90e34656806/stop?t=5 HTTP/1.1 1056 1057 **Example response**: 1058 1059 HTTP/1.1 204 No Content 1060 1061 **Query parameters**: 1062 1063 - **t** – number of seconds to wait before killing the container 1064 1065 **Status codes**: 1066 1067 - **204** – no error 1068 - **304** – container already stopped 1069 - **404** – no such container 1070 - **500** – server error 1071 1072 #### Restart a container 1073 1074 `POST /containers/(id or name)/restart` 1075 1076 Restart the container `id` 1077 1078 **Example request**: 1079 1080 POST /v1.23/containers/e90e34656806/restart?t=5 HTTP/1.1 1081 1082 **Example response**: 1083 1084 HTTP/1.1 204 No Content 1085 1086 **Query parameters**: 1087 1088 - **t** – number of seconds to wait before killing the container 1089 1090 **Status codes**: 1091 1092 - **204** – no error 1093 - **404** – no such container 1094 - **500** – server error 1095 1096 #### Kill a container 1097 1098 `POST /containers/(id or name)/kill` 1099 1100 Kill the container `id` 1101 1102 **Example request**: 1103 1104 POST /v1.23/containers/e90e34656806/kill HTTP/1.1 1105 1106 **Example response**: 1107 1108 HTTP/1.1 204 No Content 1109 1110 **Query parameters**: 1111 1112 - **signal** - Signal to send to the container: integer or string like `SIGINT`. 1113 When not set, `SIGKILL` is assumed and the call waits for the container to exit. 1114 1115 **Status codes**: 1116 1117 - **204** – no error 1118 - **404** – no such container 1119 - **500** – server error 1120 1121 #### Update a container 1122 1123 `POST /containers/(id or name)/update` 1124 1125 Update configuration of one or more containers. 1126 1127 **Example request**: 1128 1129 POST /v1.23/containers/e90e34656806/update HTTP/1.1 1130 Content-Type: application/json 1131 1132 { 1133 "BlkioWeight": 300, 1134 "CpuShares": 512, 1135 "CpuPeriod": 100000, 1136 "CpuQuota": 50000, 1137 "CpusetCpus": "0,1", 1138 "CpusetMems": "0", 1139 "Memory": 314572800, 1140 "MemorySwap": 514288000, 1141 "MemoryReservation": 209715200, 1142 "KernelMemory": 52428800, 1143 "RestartPolicy": { 1144 "MaximumRetryCount": 4, 1145 "Name": "on-failure" 1146 }, 1147 } 1148 1149 **Example response**: 1150 1151 HTTP/1.1 200 OK 1152 Content-Type: application/json 1153 1154 { 1155 "Warnings": [] 1156 } 1157 1158 **Status codes**: 1159 1160 - **200** – no error 1161 - **400** – bad parameter 1162 - **404** – no such container 1163 - **500** – server error 1164 1165 #### Rename a container 1166 1167 `POST /containers/(id or name)/rename` 1168 1169 Rename the container `id` to a `new_name` 1170 1171 **Example request**: 1172 1173 POST /v1.23/containers/e90e34656806/rename?name=new_name HTTP/1.1 1174 1175 **Example response**: 1176 1177 HTTP/1.1 204 No Content 1178 1179 **Query parameters**: 1180 1181 - **name** – new name for the container 1182 1183 **Status codes**: 1184 1185 - **204** – no error 1186 - **404** – no such container 1187 - **409** - conflict name already assigned 1188 - **500** – server error 1189 1190 #### Pause a container 1191 1192 `POST /containers/(id or name)/pause` 1193 1194 Pause the container `id` 1195 1196 **Example request**: 1197 1198 POST /v1.23/containers/e90e34656806/pause HTTP/1.1 1199 1200 **Example response**: 1201 1202 HTTP/1.1 204 No Content 1203 1204 **Status codes**: 1205 1206 - **204** – no error 1207 - **404** – no such container 1208 - **500** – server error 1209 1210 #### Unpause a container 1211 1212 `POST /containers/(id or name)/unpause` 1213 1214 Unpause the container `id` 1215 1216 **Example request**: 1217 1218 POST /v1.23/containers/e90e34656806/unpause HTTP/1.1 1219 1220 **Example response**: 1221 1222 HTTP/1.1 204 No Content 1223 1224 **Status codes**: 1225 1226 - **204** – no error 1227 - **404** – no such container 1228 - **500** – server error 1229 1230 #### Attach to a container 1231 1232 `POST /containers/(id or name)/attach` 1233 1234 Attach to the container `id` 1235 1236 **Example request**: 1237 1238 POST /v1.23/containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1 1239 1240 **Example response**: 1241 1242 HTTP/1.1 101 UPGRADED 1243 Content-Type: application/vnd.docker.raw-stream 1244 Connection: Upgrade 1245 Upgrade: tcp 1246 1247 {% raw %} 1248 {{ STREAM }} 1249 {% endraw %} 1250 1251 **Query parameters**: 1252 1253 - **detachKeys** – Override the key sequence for detaching a 1254 container. Format is a single character `[a-Z]` or `ctrl-<value>` 1255 where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 1256 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`. 1257 - **stream** – 1/True/true or 0/False/false, return stream. 1258 Default `false`. 1259 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach 1260 to `stdin`. Default `false`. 1261 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return 1262 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`. 1263 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return 1264 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`. 1265 1266 **Status codes**: 1267 1268 - **101** – no error, hints proxy about hijacking 1269 - **200** – no error, no upgrade header found 1270 - **400** – bad parameter 1271 - **404** – no such container 1272 - **409** - container is paused 1273 - **500** – server error 1274 1275 **Stream details**: 1276 1277 When using the TTY setting is enabled in 1278 [`POST /containers/create` 1279 ](#create-a-container), 1280 the stream is the raw data from the process PTY and client's `stdin`. 1281 When the TTY is disabled, then the stream is multiplexed to separate 1282 `stdout` and `stderr`. 1283 1284 The format is a **Header** and a **Payload** (frame). 1285 1286 **HEADER** 1287 1288 The header contains the information which the stream writes (`stdout` or 1289 `stderr`). It also contains the size of the associated frame encoded in the 1290 last four bytes (`uint32`). 1291 1292 It is encoded on the first eight bytes like this: 1293 1294 header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} 1295 1296 `STREAM_TYPE` can be: 1297 1298 - 0: `stdin` (is written on `stdout`) 1299 - 1: `stdout` 1300 - 2: `stderr` 1301 1302 `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of 1303 the `uint32` size encoded as big endian. 1304 1305 **PAYLOAD** 1306 1307 The payload is the raw stream. 1308 1309 **IMPLEMENTATION** 1310 1311 The simplest way to implement the Attach protocol is the following: 1312 1313 1. Read eight bytes. 1314 2. Choose `stdout` or `stderr` depending on the first byte. 1315 3. Extract the frame size from the last four bytes. 1316 4. Read the extracted size and output it on the correct output. 1317 5. Goto 1. 1318 1319 #### Attach to a container (websocket) 1320 1321 `GET /containers/(id or name)/attach/ws` 1322 1323 Attach to the container `id` via websocket 1324 1325 Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455) 1326 1327 **Example request** 1328 1329 GET /v1.23/containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1 1330 1331 **Example response** 1332 1333 {% raw %} 1334 {{ STREAM }} 1335 {% endraw %} 1336 1337 **Query parameters**: 1338 1339 - **detachKeys** – Override the key sequence for detaching a 1340 container. Format is a single character `[a-Z]` or `ctrl-<value>` 1341 where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 1342 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`. 1343 - **stream** – 1/True/true or 0/False/false, return stream. 1344 Default `false`. 1345 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach 1346 to `stdin`. Default `false`. 1347 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return 1348 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`. 1349 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return 1350 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`. 1351 1352 **Status codes**: 1353 1354 - **200** – no error 1355 - **400** – bad parameter 1356 - **404** – no such container 1357 - **500** – server error 1358 1359 #### Wait a container 1360 1361 `POST /containers/(id or name)/wait` 1362 1363 Block until container `id` stops, then returns the exit code 1364 1365 **Example request**: 1366 1367 POST /v1.23/containers/16253994b7c4/wait HTTP/1.1 1368 1369 **Example response**: 1370 1371 HTTP/1.1 200 OK 1372 Content-Type: application/json 1373 1374 {"StatusCode": 0} 1375 1376 **Status codes**: 1377 1378 - **200** – no error 1379 - **404** – no such container 1380 - **500** – server error 1381 1382 #### Remove a container 1383 1384 `DELETE /containers/(id or name)` 1385 1386 Remove the container `id` from the filesystem 1387 1388 **Example request**: 1389 1390 DELETE /v1.23/containers/16253994b7c4?v=1 HTTP/1.1 1391 1392 **Example response**: 1393 1394 HTTP/1.1 204 No Content 1395 1396 **Query parameters**: 1397 1398 - **v** – 1/True/true or 0/False/false, Remove the volumes 1399 associated to the container. Default `false`. 1400 - **force** - 1/True/true or 0/False/false, Kill then remove the container. 1401 Default `false`. 1402 1403 **Status codes**: 1404 1405 - **204** – no error 1406 - **400** – bad parameter 1407 - **404** – no such container 1408 - **409** – conflict 1409 - **500** – server error 1410 1411 #### Copy files or folders from a container 1412 1413 `POST /containers/(id or name)/copy` 1414 1415 Copy files or folders of container `id` 1416 1417 **Deprecated** in favor of the `archive` endpoint below. 1418 1419 **Example request**: 1420 1421 POST /v1.23/containers/4fa6e0f0c678/copy HTTP/1.1 1422 Content-Type: application/json 1423 1424 { 1425 "Resource": "test.txt" 1426 } 1427 1428 **Example response**: 1429 1430 HTTP/1.1 200 OK 1431 Content-Type: application/x-tar 1432 1433 {% raw %} 1434 {{ TAR STREAM }} 1435 {% endraw %} 1436 1437 **Status codes**: 1438 1439 - **200** – no error 1440 - **404** – no such container 1441 - **500** – server error 1442 1443 #### Retrieving information about files and folders in a container 1444 1445 `HEAD /containers/(id or name)/archive` 1446 1447 See the description of the `X-Docker-Container-Path-Stat` header in the 1448 following section. 1449 1450 #### Get an archive of a filesystem resource in a container 1451 1452 `GET /containers/(id or name)/archive` 1453 1454 Get a tar archive of a resource in the filesystem of container `id`. 1455 1456 **Query parameters**: 1457 1458 - **path** - resource in the container's filesystem to archive. Required. 1459 1460 If not an absolute path, it is relative to the container's root directory. 1461 The resource specified by **path** must exist. To assert that the resource 1462 is expected to be a directory, **path** should end in `/` or `/.` 1463 (assuming a path separator of `/`). If **path** ends in `/.` then this 1464 indicates that only the contents of the **path** directory should be 1465 copied. A symlink is always resolved to its target. 1466 1467 > **Note**: It is not possible to copy certain system files such as resources 1468 > under `/proc`, `/sys`, `/dev`, and mounts created by the user in the 1469 > container. 1470 1471 **Example request**: 1472 1473 GET /v1.23/containers/8cce319429b2/archive?path=/root HTTP/1.1 1474 1475 **Example response**: 1476 1477 HTTP/1.1 200 OK 1478 Content-Type: application/x-tar 1479 X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= 1480 1481 {% raw %} 1482 {{ TAR STREAM }} 1483 {% endraw %} 1484 1485 On success, a response header `X-Docker-Container-Path-Stat` will be set to a 1486 base64-encoded JSON object containing some filesystem header information about 1487 the archived resource. The above example value would decode to the following 1488 JSON object (whitespace added for readability): 1489 1490 ```json 1491 { 1492 "name": "root", 1493 "size": 4096, 1494 "mode": 2147484096, 1495 "mtime": "2014-02-27T20:51:23Z", 1496 "linkTarget": "" 1497 } 1498 ``` 1499 1500 A `HEAD` request can also be made to this endpoint if only this information is 1501 desired. 1502 1503 **Status codes**: 1504 1505 - **200** - success, returns archive of copied resource 1506 - **400** - client error, bad parameter, details in JSON response body, one of: 1507 - must specify path parameter (**path** cannot be empty) 1508 - not a directory (**path** was asserted to be a directory but exists as a 1509 file) 1510 - **404** - client error, resource not found, one of: 1511 – no such container (container `id` does not exist) 1512 - no such file or directory (**path** does not exist) 1513 - **500** - server error 1514 1515 #### Extract an archive of files or folders to a directory in a container 1516 1517 `PUT /containers/(id or name)/archive` 1518 1519 Upload a tar archive to be extracted to a path in the filesystem of container 1520 `id`. 1521 1522 **Query parameters**: 1523 1524 - **path** - path to a directory in the container 1525 to extract the archive's contents into. Required. 1526 1527 If not an absolute path, it is relative to the container's root directory. 1528 The **path** resource must exist. 1529 - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error 1530 if unpacking the given content would cause an existing directory to be 1531 replaced with a non-directory and vice versa. 1532 1533 **Example request**: 1534 1535 PUT /v1.23/containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 1536 Content-Type: application/x-tar 1537 1538 {% raw %} 1539 {{ TAR STREAM }} 1540 {% endraw %} 1541 1542 **Example response**: 1543 1544 HTTP/1.1 200 OK 1545 1546 **Status codes**: 1547 1548 - **200** – the content was extracted successfully 1549 - **400** - client error, bad parameter, details in JSON response body, one of: 1550 - must specify path parameter (**path** cannot be empty) 1551 - not a directory (**path** should be a directory but exists as a file) 1552 - unable to overwrite existing directory with non-directory 1553 (if **noOverwriteDirNonDir**) 1554 - unable to overwrite existing non-directory with directory 1555 (if **noOverwriteDirNonDir**) 1556 - **403** - client error, permission denied, the volume 1557 or container rootfs is marked as read-only. 1558 - **404** - client error, resource not found, one of: 1559 – no such container (container `id` does not exist) 1560 - no such file or directory (**path** resource does not exist) 1561 - **500** – server error 1562 1563 ### 2.2 Images 1564 1565 #### List Images 1566 1567 `GET /images/json` 1568 1569 **Example request**: 1570 1571 GET /v1.23/images/json?all=0 HTTP/1.1 1572 1573 **Example response**: 1574 1575 HTTP/1.1 200 OK 1576 Content-Type: application/json 1577 1578 [ 1579 { 1580 "RepoTags": [ 1581 "ubuntu:12.04", 1582 "ubuntu:precise", 1583 "ubuntu:latest" 1584 ], 1585 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 1586 "Created": 1365714795, 1587 "Size": 131506275, 1588 "VirtualSize": 131506275, 1589 "Labels": {} 1590 }, 1591 { 1592 "RepoTags": [ 1593 "ubuntu:12.10", 1594 "ubuntu:quantal" 1595 ], 1596 "ParentId": "27cf784147099545", 1597 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1598 "Created": 1364102658, 1599 "Size": 24653, 1600 "VirtualSize": 180116135, 1601 "Labels": { 1602 "com.example.version": "v1" 1603 } 1604 } 1605 ] 1606 1607 **Example request, with digest information**: 1608 1609 GET /v1.23/images/json?digests=1 HTTP/1.1 1610 1611 **Example response, with digest information**: 1612 1613 HTTP/1.1 200 OK 1614 Content-Type: application/json 1615 1616 [ 1617 { 1618 "Created": 1420064636, 1619 "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125", 1620 "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2", 1621 "RepoDigests": [ 1622 "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" 1623 ], 1624 "RepoTags": [ 1625 "localhost:5000/test/busybox:latest", 1626 "playdate:latest" 1627 ], 1628 "Size": 0, 1629 "VirtualSize": 2429728, 1630 "Labels": {} 1631 } 1632 ] 1633 1634 The response shows a single image `Id` associated with two repositories 1635 (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use 1636 either of the `RepoTags` values `localhost:5000/test/busybox:latest` or 1637 `playdate:latest` to reference the image. 1638 1639 You can also use `RepoDigests` values to reference an image. In this response, 1640 the array has only one reference and that is to the 1641 `localhost:5000/test/busybox` repository; the `playdate` repository has no 1642 digest. You can reference this digest using the value: 1643 `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...` 1644 1645 See the `docker run` and `docker build` commands for examples of digest and tag 1646 references on the command line. 1647 1648 **Query parameters**: 1649 1650 - **all** – 1/True/true or 0/False/false, default false 1651 - **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters: 1652 - `dangling=true` 1653 - `label=key` or `label="key=value"` of an image label 1654 - **filter** - only return images with the specified name 1655 1656 #### Build image from a Dockerfile 1657 1658 `POST /build` 1659 1660 Build an image from a Dockerfile 1661 1662 **Example request**: 1663 1664 POST /v1.23/build HTTP/1.1 1665 1666 {% raw %} 1667 {{ TAR STREAM }} 1668 {% endraw %} 1669 1670 **Example response**: 1671 1672 HTTP/1.1 200 OK 1673 Content-Type: application/json 1674 1675 {"stream": "Step 1/5..."} 1676 {"stream": "..."} 1677 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 1678 1679 The input stream must be a `tar` archive compressed with one of the 1680 following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`. 1681 1682 The archive must include a build instructions file, typically called 1683 `Dockerfile` at the archive's root. The `dockerfile` parameter may be 1684 used to specify a different build instructions file. To do this, its value must be 1685 the path to the alternate build instructions file to use. 1686 1687 The archive may include any number of other files, 1688 which are accessible in the build context (See the [*ADD build 1689 command*](../reference/builder.md#add)). 1690 1691 The Docker daemon performs a preliminary validation of the `Dockerfile` before 1692 starting the build, and returns an error if the syntax is incorrect. After that, 1693 each instruction is run one-by-one until the ID of the new image is output. 1694 1695 The build is canceled if the client drops the connection by quitting 1696 or being killed. 1697 1698 **Query parameters**: 1699 1700 - **dockerfile** - Path within the build context to the `Dockerfile`. This is 1701 ignored if `remote` is specified and points to an external `Dockerfile`. 1702 - **t** – A name and optional tag to apply to the image in the `name:tag` format. 1703 If you omit the `tag` the default `latest` value is assumed. 1704 You can provide one or more `t` parameters. 1705 - **remote** – A Git repository URI or HTTP/HTTPS context URI. If the 1706 URI points to a single text file, the file's contents are placed into 1707 a file called `Dockerfile` and the image is built from that file. If 1708 the URI points to a tarball, the file is downloaded by the daemon and 1709 the contents therein used as the context for the build. If the URI 1710 points to a tarball and the `dockerfile` parameter is also specified, 1711 there must be a file with the corresponding path inside the tarball. 1712 - **q** – Suppress verbose build output. 1713 - **nocache** – Do not use the cache when building the image. 1714 - **pull** - Attempt to pull the image even if an older image exists locally. 1715 - **rm** - Remove intermediate containers after a successful build (default behavior). 1716 - **forcerm** - Always remove intermediate containers (includes `rm`). 1717 - **memory** - Set memory limit for build. 1718 - **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap. 1719 - **cpushares** - CPU shares (relative weight). 1720 - **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`). 1721 - **cpuperiod** - The length of a CPU period in microseconds. 1722 - **cpuquota** - Microseconds of CPU time that the container can get in a CPU period. 1723 - **buildargs** – JSON map of string pairs for build-time variables. Users pass 1724 these values at build-time. Docker uses the `buildargs` as the environment 1725 context for command(s) run via the Dockerfile's `RUN` instruction or for 1726 variable expansion in other Dockerfile instructions. This is not meant for 1727 passing secret values. [Read more about the buildargs instruction](../reference/builder.md#arg) 1728 - **shmsize** - Size of `/dev/shm` in bytes. The size must be greater than 0. If omitted the system uses 64MB. 1729 - **labels** – JSON map of string pairs for labels to set on the image. 1730 1731 **Request Headers**: 1732 1733 - **Content-type** – Set to `"application/tar"`. 1734 - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON 1735 object with the following structure: 1736 1737 { 1738 "docker.example.com": { 1739 "username": "janedoe", 1740 "password": "hunter2" 1741 }, 1742 "https://index.docker.io/v1/": { 1743 "username": "mobydock", 1744 "password": "conta1n3rize14" 1745 } 1746 } 1747 1748 This object maps the hostname of a registry to an object containing the 1749 "username" and "password" for that registry. Multiple registries may 1750 be specified as the build may be based on an image requiring 1751 authentication to pull from any arbitrary registry. Only the registry 1752 domain name (and port if not the default "443") are required. However 1753 (for legacy reasons) the "official" Docker, Inc. hosted registry must 1754 be specified with both a "https://" prefix and a "/v1/" suffix even 1755 though Docker will prefer to use the v2 registry API. 1756 1757 **Status codes**: 1758 1759 - **200** – no error 1760 - **500** – server error 1761 1762 #### Create an image 1763 1764 `POST /images/create` 1765 1766 Create an image either by pulling it from the registry or by importing it 1767 1768 **Example request**: 1769 1770 POST /v1.23/images/create?fromImage=busybox&tag=latest HTTP/1.1 1771 1772 **Example response**: 1773 1774 HTTP/1.1 200 OK 1775 Content-Type: application/json 1776 1777 {"status": "Pulling..."} 1778 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 1779 {"error": "Invalid..."} 1780 ... 1781 1782 When using this endpoint to pull an image from the registry, the 1783 `X-Registry-Auth` header can be used to include 1784 a base64-encoded AuthConfig object. 1785 1786 **Query parameters**: 1787 1788 - **fromImage** – Name of the image to pull. The name may include a tag or 1789 digest. This parameter may only be used when pulling an image. 1790 The pull is cancelled if the HTTP connection is closed. 1791 - **fromSrc** – Source to import. The value may be a URL from which the image 1792 can be retrieved or `-` to read the image from the request body. 1793 This parameter may only be used when importing an image. 1794 - **repo** – Repository name given to an image when it is imported. 1795 The repo may include a tag. This parameter may only be used when importing 1796 an image. 1797 - **tag** – Tag or digest. If empty when pulling an image, this causes all tags 1798 for the given image to be pulled. 1799 1800 **Request Headers**: 1801 1802 - **X-Registry-Auth** – base64-encoded AuthConfig object, containing either login information, or a token 1803 - Credential based login: 1804 1805 ``` 1806 { 1807 "username": "jdoe", 1808 "password": "secret", 1809 "email": "jdoe@acme.com" 1810 } 1811 ``` 1812 1813 - Token based login: 1814 1815 ``` 1816 { 1817 "identitytoken": "9cbaf023786cd7..." 1818 } 1819 ``` 1820 1821 **Status codes**: 1822 1823 - **200** – no error 1824 - **404** - repository does not exist or no read access 1825 - **500** – server error 1826 1827 1828 1829 #### Inspect an image 1830 1831 `GET /images/(name)/json` 1832 1833 Return low-level information on the image `name` 1834 1835 **Example request**: 1836 1837 GET /v1.23/images/example/json HTTP/1.1 1838 1839 **Example response**: 1840 1841 HTTP/1.1 200 OK 1842 Content-Type: application/json 1843 1844 { 1845 "Id" : "sha256:85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c", 1846 "Container" : "cb91e48a60d01f1e27028b4fc6819f4f290b3cf12496c8176ec714d0d390984a", 1847 "Comment" : "", 1848 "Os" : "linux", 1849 "Architecture" : "amd64", 1850 "Parent" : "sha256:91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c", 1851 "ContainerConfig" : { 1852 "Tty" : false, 1853 "Hostname" : "e611e15f9c9d", 1854 "Volumes" : null, 1855 "Domainname" : "", 1856 "AttachStdout" : false, 1857 "PublishService" : "", 1858 "AttachStdin" : false, 1859 "OpenStdin" : false, 1860 "StdinOnce" : false, 1861 "NetworkDisabled" : false, 1862 "OnBuild" : [], 1863 "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c", 1864 "User" : "", 1865 "WorkingDir" : "", 1866 "Entrypoint" : null, 1867 "MacAddress" : "", 1868 "AttachStderr" : false, 1869 "Labels" : { 1870 "com.example.license" : "GPL", 1871 "com.example.version" : "1.0", 1872 "com.example.vendor" : "Acme" 1873 }, 1874 "Env" : [ 1875 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 1876 ], 1877 "ExposedPorts" : null, 1878 "Cmd" : [ 1879 "/bin/sh", 1880 "-c", 1881 "#(nop) LABEL com.example.vendor=Acme com.example.license=GPL com.example.version=1.0" 1882 ] 1883 }, 1884 "DockerVersion" : "1.9.0-dev", 1885 "VirtualSize" : 188359297, 1886 "Size" : 0, 1887 "Author" : "", 1888 "Created" : "2015-09-10T08:30:53.26995814Z", 1889 "GraphDriver" : { 1890 "Name" : "aufs", 1891 "Data" : null 1892 }, 1893 "RepoDigests" : [ 1894 "localhost:5000/test/busybox/example@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" 1895 ], 1896 "RepoTags" : [ 1897 "example:1.0", 1898 "example:latest", 1899 "example:stable" 1900 ], 1901 "Config" : { 1902 "Image" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c", 1903 "NetworkDisabled" : false, 1904 "OnBuild" : [], 1905 "StdinOnce" : false, 1906 "PublishService" : "", 1907 "AttachStdin" : false, 1908 "OpenStdin" : false, 1909 "Domainname" : "", 1910 "AttachStdout" : false, 1911 "Tty" : false, 1912 "Hostname" : "e611e15f9c9d", 1913 "Volumes" : null, 1914 "Cmd" : [ 1915 "/bin/bash" 1916 ], 1917 "ExposedPorts" : null, 1918 "Env" : [ 1919 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 1920 ], 1921 "Labels" : { 1922 "com.example.vendor" : "Acme", 1923 "com.example.version" : "1.0", 1924 "com.example.license" : "GPL" 1925 }, 1926 "Entrypoint" : null, 1927 "MacAddress" : "", 1928 "AttachStderr" : false, 1929 "WorkingDir" : "", 1930 "User" : "" 1931 }, 1932 "RootFS": { 1933 "Type": "layers", 1934 "Layers": [ 1935 "sha256:1834950e52ce4d5a88a1bbd131c537f4d0e56d10ff0dd69e66be3b7dfa9df7e6", 1936 "sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef" 1937 ] 1938 } 1939 } 1940 1941 **Status codes**: 1942 1943 - **200** – no error 1944 - **404** – no such image 1945 - **500** – server error 1946 1947 #### Get the history of an image 1948 1949 `GET /images/(name)/history` 1950 1951 Return the history of the image `name` 1952 1953 **Example request**: 1954 1955 GET /v1.23/images/ubuntu/history HTTP/1.1 1956 1957 **Example response**: 1958 1959 HTTP/1.1 200 OK 1960 Content-Type: application/json 1961 1962 [ 1963 { 1964 "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710", 1965 "Created": 1398108230, 1966 "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /", 1967 "Tags": [ 1968 "ubuntu:lucid", 1969 "ubuntu:10.04" 1970 ], 1971 "Size": 182964289, 1972 "Comment": "" 1973 }, 1974 { 1975 "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8", 1976 "Created": 1398108222, 1977 "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/", 1978 "Tags": null, 1979 "Size": 0, 1980 "Comment": "" 1981 }, 1982 { 1983 "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158", 1984 "Created": 1371157430, 1985 "CreatedBy": "", 1986 "Tags": [ 1987 "scratch12:latest", 1988 "scratch:latest" 1989 ], 1990 "Size": 0, 1991 "Comment": "Imported from -" 1992 } 1993 ] 1994 1995 **Status codes**: 1996 1997 - **200** – no error 1998 - **404** – no such image 1999 - **500** – server error 2000 2001 #### Push an image on the registry 2002 2003 `POST /images/(name)/push` 2004 2005 Push the image `name` on the registry 2006 2007 **Example request**: 2008 2009 POST /v1.23/images/test/push HTTP/1.1 2010 2011 **Example response**: 2012 2013 HTTP/1.1 200 OK 2014 Content-Type: application/json 2015 2016 {"status": "Pushing..."} 2017 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 2018 {"error": "Invalid..."} 2019 ... 2020 2021 If you wish to push an image on to a private registry, that image must already have a tag 2022 into a repository which references that registry `hostname` and `port`. This repository name should 2023 then be used in the URL. This duplicates the command line's flow. 2024 2025 The push is cancelled if the HTTP connection is closed. 2026 2027 **Example request**: 2028 2029 POST /v1.23/images/registry.acme.com:5000/test/push HTTP/1.1 2030 2031 2032 **Query parameters**: 2033 2034 - **tag** – The tag to associate with the image on the registry. This is optional. 2035 2036 **Request Headers**: 2037 2038 - **X-Registry-Auth** – base64-encoded AuthConfig object, containing either login information, or a token 2039 - Credential based login: 2040 2041 ``` 2042 { 2043 "username": "jdoe", 2044 "password": "secret", 2045 "email": "jdoe@acme.com", 2046 } 2047 ``` 2048 2049 - Identity token based login: 2050 2051 ``` 2052 { 2053 "identitytoken": "9cbaf023786cd7..." 2054 } 2055 ``` 2056 2057 **Status codes**: 2058 2059 - **200** – no error 2060 - **404** – no such image 2061 - **500** – server error 2062 2063 #### Tag an image into a repository 2064 2065 `POST /images/(name)/tag` 2066 2067 Tag the image `name` into a repository 2068 2069 **Example request**: 2070 2071 POST /v1.23/images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1 2072 2073 **Example response**: 2074 2075 HTTP/1.1 201 Created 2076 2077 **Query parameters**: 2078 2079 - **repo** – The repository to tag in 2080 - **force** – 1/True/true or 0/False/false, default false 2081 - **tag** - The new tag name 2082 2083 **Status codes**: 2084 2085 - **201** – no error 2086 - **400** – bad parameter 2087 - **404** – no such image 2088 - **409** – conflict 2089 - **500** – server error 2090 2091 #### Remove an image 2092 2093 `DELETE /images/(name)` 2094 2095 Remove the image `name` from the filesystem 2096 2097 **Example request**: 2098 2099 DELETE /v1.23/images/test HTTP/1.1 2100 2101 **Example response**: 2102 2103 HTTP/1.1 200 OK 2104 Content-type: application/json 2105 2106 [ 2107 {"Untagged": "3e2f21a89f"}, 2108 {"Deleted": "3e2f21a89f"}, 2109 {"Deleted": "53b4f83ac9"} 2110 ] 2111 2112 **Query parameters**: 2113 2114 - **force** – 1/True/true or 0/False/false, default false 2115 - **noprune** – 1/True/true or 0/False/false, default false 2116 2117 **Status codes**: 2118 2119 - **200** – no error 2120 - **404** – no such image 2121 - **409** – conflict 2122 - **500** – server error 2123 2124 #### Search images 2125 2126 `GET /images/search` 2127 2128 Search for an image on [Docker Hub](https://hub.docker.com). 2129 2130 > **Note**: 2131 > The response keys have changed from API v1.6 to reflect the JSON 2132 > sent by the registry server to the docker daemon's request. 2133 2134 **Example request**: 2135 2136 GET /v1.23/images/search?term=sshd HTTP/1.1 2137 2138 **Example response**: 2139 2140 HTTP/1.1 200 OK 2141 Content-Type: application/json 2142 2143 [ 2144 { 2145 "description": "", 2146 "is_official": false, 2147 "is_automated": false, 2148 "name": "wma55/u1210sshd", 2149 "star_count": 0 2150 }, 2151 { 2152 "description": "", 2153 "is_official": false, 2154 "is_automated": false, 2155 "name": "jdswinbank/sshd", 2156 "star_count": 0 2157 }, 2158 { 2159 "description": "", 2160 "is_official": false, 2161 "is_automated": false, 2162 "name": "vgauthier/sshd", 2163 "star_count": 0 2164 } 2165 ... 2166 ] 2167 2168 **Query parameters**: 2169 2170 - **term** – term to search 2171 2172 **Status codes**: 2173 2174 - **200** – no error 2175 - **500** – server error 2176 2177 ### 2.3 Misc 2178 2179 #### Check auth configuration 2180 2181 `POST /auth` 2182 2183 Validate credentials for a registry and get identity token, 2184 if available, for accessing the registry without password. 2185 2186 **Example request**: 2187 2188 POST /v1.23/auth HTTP/1.1 2189 Content-Type: application/json 2190 2191 { 2192 "username": "hannibal", 2193 "password": "xxxx", 2194 "serveraddress": "https://index.docker.io/v1/" 2195 } 2196 2197 **Example response**: 2198 2199 HTTP/1.1 200 OK 2200 2201 { 2202 "Status": "Login Succeeded", 2203 "IdentityToken": "9cbaf023786cd7..." 2204 } 2205 2206 **Status codes**: 2207 2208 - **200** – no error 2209 - **204** – no error 2210 - **500** – server error 2211 2212 #### Display system-wide information 2213 2214 `GET /info` 2215 2216 Display system-wide information 2217 2218 **Example request**: 2219 2220 GET /v1.23/info HTTP/1.1 2221 2222 **Example response**: 2223 2224 HTTP/1.1 200 OK 2225 Content-Type: application/json 2226 2227 { 2228 "Architecture": "x86_64", 2229 "ClusterStore": "etcd://localhost:2379", 2230 "CgroupDriver": "cgroupfs", 2231 "Containers": 11, 2232 "ContainersRunning": 7, 2233 "ContainersStopped": 3, 2234 "ContainersPaused": 1, 2235 "CpuCfsPeriod": true, 2236 "CpuCfsQuota": true, 2237 "Debug": false, 2238 "DockerRootDir": "/var/lib/docker", 2239 "Driver": "btrfs", 2240 "DriverStatus": [[""]], 2241 "ExecutionDriver": "native-0.1", 2242 "ExperimentalBuild": false, 2243 "HttpProxy": "http://test:test@localhost:8080", 2244 "HttpsProxy": "https://test:test@localhost:8080", 2245 "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS", 2246 "IPv4Forwarding": true, 2247 "Images": 16, 2248 "IndexServerAddress": "https://index.docker.io/v1/", 2249 "InitPath": "/usr/bin/docker", 2250 "InitSha1": "", 2251 "KernelMemory": true, 2252 "KernelVersion": "3.12.0-1-amd64", 2253 "Labels": [ 2254 "storage=ssd" 2255 ], 2256 "MemTotal": 2099236864, 2257 "MemoryLimit": true, 2258 "NCPU": 1, 2259 "NEventsListener": 0, 2260 "NFd": 11, 2261 "NGoroutines": 21, 2262 "Name": "prod-server-42", 2263 "NoProxy": "9.81.1.160", 2264 "OomKillDisable": true, 2265 "OSType": "linux", 2266 "OperatingSystem": "Boot2Docker", 2267 "Plugins": { 2268 "Volume": [ 2269 "local" 2270 ], 2271 "Network": [ 2272 "null", 2273 "host", 2274 "bridge" 2275 ] 2276 }, 2277 "RegistryConfig": { 2278 "IndexConfigs": { 2279 "docker.io": { 2280 "Mirrors": null, 2281 "Name": "docker.io", 2282 "Official": true, 2283 "Secure": true 2284 } 2285 }, 2286 "InsecureRegistryCIDRs": [ 2287 "127.0.0.0/8" 2288 ] 2289 }, 2290 "ServerVersion": "1.9.0", 2291 "SwapLimit": false, 2292 "SystemStatus": [["State", "Healthy"]], 2293 "SystemTime": "2015-03-10T11:11:23.730591467-07:00" 2294 } 2295 2296 **Status codes**: 2297 2298 - **200** – no error 2299 - **500** – server error 2300 2301 #### Show the docker version information 2302 2303 `GET /version` 2304 2305 Show the docker version information 2306 2307 **Example request**: 2308 2309 GET /v1.23/version HTTP/1.1 2310 2311 **Example response**: 2312 2313 HTTP/1.1 200 OK 2314 Content-Type: application/json 2315 2316 { 2317 "Version": "1.11.0", 2318 "Os": "linux", 2319 "KernelVersion": "3.19.0-23-generic", 2320 "GoVersion": "go1.4.2", 2321 "GitCommit": "e75da4b", 2322 "Arch": "amd64", 2323 "ApiVersion": "1.23", 2324 "BuildTime": "2015-12-01T07:09:13.444803460+00:00", 2325 "Experimental": true 2326 } 2327 2328 **Status codes**: 2329 2330 - **200** – no error 2331 - **500** – server error 2332 2333 #### Ping the docker server 2334 2335 `GET /_ping` 2336 2337 Ping the docker server 2338 2339 **Example request**: 2340 2341 GET /v1.23/_ping HTTP/1.1 2342 2343 **Example response**: 2344 2345 HTTP/1.1 200 OK 2346 Content-Type: text/plain 2347 2348 OK 2349 2350 **Status codes**: 2351 2352 - **200** - no error 2353 - **500** - server error 2354 2355 #### Create a new image from a container's changes 2356 2357 `POST /commit` 2358 2359 Create a new image from a container's changes 2360 2361 **Example request**: 2362 2363 POST /v1.23/commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1 2364 Content-Type: application/json 2365 2366 { 2367 "Hostname": "", 2368 "Domainname": "", 2369 "User": "", 2370 "AttachStdin": false, 2371 "AttachStdout": true, 2372 "AttachStderr": true, 2373 "Tty": false, 2374 "OpenStdin": false, 2375 "StdinOnce": false, 2376 "Env": null, 2377 "Cmd": [ 2378 "date" 2379 ], 2380 "Mounts": [ 2381 { 2382 "Source": "/data", 2383 "Destination": "/data", 2384 "Mode": "ro,Z", 2385 "RW": false 2386 } 2387 ], 2388 "Labels": { 2389 "key1": "value1", 2390 "key2": "value2" 2391 }, 2392 "WorkingDir": "", 2393 "NetworkDisabled": false, 2394 "ExposedPorts": { 2395 "22/tcp": {} 2396 } 2397 } 2398 2399 **Example response**: 2400 2401 HTTP/1.1 201 Created 2402 Content-Type: application/json 2403 2404 {"Id": "596069db4bf5"} 2405 2406 **JSON parameters**: 2407 2408 - **config** - the container's configuration 2409 2410 **Query parameters**: 2411 2412 - **container** – source container 2413 - **repo** – repository 2414 - **tag** – tag 2415 - **comment** – commit message 2416 - **author** – author (e.g., "John Hannibal Smith 2417 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 2418 - **pause** – 1/True/true or 0/False/false, whether to pause the container before committing 2419 - **changes** – Dockerfile instructions to apply while committing 2420 2421 **Status codes**: 2422 2423 - **201** – no error 2424 - **404** – no such container 2425 - **500** – server error 2426 2427 #### Monitor Docker's events 2428 2429 `GET /events` 2430 2431 Get container events from docker, in real time via streaming. 2432 2433 Docker containers report the following events: 2434 2435 attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update 2436 2437 Docker images report the following events: 2438 2439 delete, import, pull, push, tag, untag 2440 2441 Docker volumes report the following events: 2442 2443 create, mount, unmount, destroy 2444 2445 Docker networks report the following events: 2446 2447 create, connect, disconnect, destroy 2448 2449 **Example request**: 2450 2451 GET /v1.23/events?since=1374067924 2452 2453 **Example response**: 2454 2455 HTTP/1.1 200 OK 2456 Content-Type: application/json 2457 Server: Docker/1.11.0 (linux) 2458 Date: Fri, 29 Apr 2016 15:18:06 GMT 2459 Transfer-Encoding: chunked 2460 2461 { 2462 "status": "pull", 2463 "id": "alpine:latest", 2464 "Type": "image", 2465 "Action": "pull", 2466 "Actor": { 2467 "ID": "alpine:latest", 2468 "Attributes": { 2469 "name": "alpine" 2470 } 2471 }, 2472 "time": 1461943101, 2473 "timeNano": 1461943101301854122 2474 } 2475 { 2476 "status": "create", 2477 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2478 "from": "alpine", 2479 "Type": "container", 2480 "Action": "create", 2481 "Actor": { 2482 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2483 "Attributes": { 2484 "com.example.some-label": "some-label-value", 2485 "image": "alpine", 2486 "name": "my-container" 2487 } 2488 }, 2489 "time": 1461943101, 2490 "timeNano": 1461943101381709551 2491 } 2492 { 2493 "status": "attach", 2494 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2495 "from": "alpine", 2496 "Type": "container", 2497 "Action": "attach", 2498 "Actor": { 2499 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2500 "Attributes": { 2501 "com.example.some-label": "some-label-value", 2502 "image": "alpine", 2503 "name": "my-container" 2504 } 2505 }, 2506 "time": 1461943101, 2507 "timeNano": 1461943101383858412 2508 } 2509 { 2510 "Type": "network", 2511 "Action": "connect", 2512 "Actor": { 2513 "ID": "7dc8ac97d5d29ef6c31b6052f3938c1e8f2749abbd17d1bd1febf2608db1b474", 2514 "Attributes": { 2515 "container": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2516 "name": "bridge", 2517 "type": "bridge" 2518 } 2519 }, 2520 "time": 1461943101, 2521 "timeNano": 1461943101394865557 2522 } 2523 { 2524 "status": "start", 2525 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2526 "from": "alpine", 2527 "Type": "container", 2528 "Action": "start", 2529 "Actor": { 2530 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2531 "Attributes": { 2532 "com.example.some-label": "some-label-value", 2533 "image": "alpine", 2534 "name": "my-container" 2535 } 2536 }, 2537 "time": 1461943101, 2538 "timeNano": 1461943101607533796 2539 } 2540 { 2541 "status": "resize", 2542 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2543 "from": "alpine", 2544 "Type": "container", 2545 "Action": "resize", 2546 "Actor": { 2547 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2548 "Attributes": { 2549 "com.example.some-label": "some-label-value", 2550 "height": "46", 2551 "image": "alpine", 2552 "name": "my-container", 2553 "width": "204" 2554 } 2555 }, 2556 "time": 1461943101, 2557 "timeNano": 1461943101610269268 2558 } 2559 { 2560 "status": "die", 2561 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2562 "from": "alpine", 2563 "Type": "container", 2564 "Action": "die", 2565 "Actor": { 2566 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2567 "Attributes": { 2568 "com.example.some-label": "some-label-value", 2569 "exitCode": "0", 2570 "image": "alpine", 2571 "name": "my-container" 2572 } 2573 }, 2574 "time": 1461943105, 2575 "timeNano": 1461943105079144137 2576 } 2577 { 2578 "Type": "network", 2579 "Action": "disconnect", 2580 "Actor": { 2581 "ID": "7dc8ac97d5d29ef6c31b6052f3938c1e8f2749abbd17d1bd1febf2608db1b474", 2582 "Attributes": { 2583 "container": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2584 "name": "bridge", 2585 "type": "bridge" 2586 } 2587 }, 2588 "time": 1461943105, 2589 "timeNano": 1461943105230860245 2590 } 2591 { 2592 "status": "destroy", 2593 "id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2594 "from": "alpine", 2595 "Type": "container", 2596 "Action": "destroy", 2597 "Actor": { 2598 "ID": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743", 2599 "Attributes": { 2600 "com.example.some-label": "some-label-value", 2601 "image": "alpine", 2602 "name": "my-container" 2603 } 2604 }, 2605 "time": 1461943105, 2606 "timeNano": 1461943105338056026 2607 } 2608 2609 **Query parameters**: 2610 2611 - **since** – Timestamp. Show all events created since timestamp and then stream 2612 - **until** – Timestamp. Show events created until given timestamp and stop streaming 2613 - **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters: 2614 - `container=<string>`; -- container to filter 2615 - `event=<string>`; -- event to filter 2616 - `image=<string>`; -- image to filter 2617 - `label=<string>`; -- image and container label to filter 2618 - `type=<string>`; -- either `container` or `image` or `volume` or `network` 2619 - `volume=<string>`; -- volume to filter 2620 - `network=<string>`; -- network to filter 2621 2622 **Status codes**: 2623 2624 - **200** – no error 2625 - **500** – server error 2626 2627 #### Get a tarball containing all images in a repository 2628 2629 `GET /images/(name)/get` 2630 2631 Get a tarball containing all images and metadata for the repository specified 2632 by `name`. 2633 2634 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image 2635 (and its parents) are returned. If `name` is an image ID, similarly only that 2636 image (and its parents) are returned, but with the exclusion of the 2637 'repositories' file in the tarball, as there were no image names referenced. 2638 2639 See the [image tarball format](#image-tarball-format) for more details. 2640 2641 **Example request** 2642 2643 GET /v1.23/images/ubuntu/get 2644 2645 **Example response**: 2646 2647 HTTP/1.1 200 OK 2648 Content-Type: application/x-tar 2649 2650 Binary data stream 2651 2652 **Status codes**: 2653 2654 - **200** – no error 2655 - **500** – server error 2656 2657 #### Get a tarball containing all images 2658 2659 `GET /images/get` 2660 2661 Get a tarball containing all images and metadata for one or more repositories. 2662 2663 For each value of the `names` parameter: if it is a specific name and tag (e.g. 2664 `ubuntu:latest`), then only that image (and its parents) are returned; if it is 2665 an image ID, similarly only that image (and its parents) are returned and there 2666 would be no names referenced in the 'repositories' file for this image ID. 2667 2668 See the [image tarball format](#image-tarball-format) for more details. 2669 2670 **Example request** 2671 2672 GET /v1.23/images/get?names=myname%2Fmyapp%3Alatest&names=busybox 2673 2674 **Example response**: 2675 2676 HTTP/1.1 200 OK 2677 Content-Type: application/x-tar 2678 2679 Binary data stream 2680 2681 **Status codes**: 2682 2683 - **200** – no error 2684 - **500** – server error 2685 2686 #### Load a tarball with a set of images and tags into docker 2687 2688 `POST /images/load` 2689 2690 Load a set of images and tags into a Docker repository. 2691 See the [image tarball format](#image-tarball-format) for more details. 2692 2693 **Example request** 2694 2695 POST /v1.23/images/load 2696 Content-Type: application/x-tar 2697 2698 Tarball in body 2699 2700 **Example response**: 2701 2702 HTTP/1.1 200 OK 2703 Content-Type: application/json 2704 Transfer-Encoding: chunked 2705 2706 {"status":"Loading layer","progressDetail":{"current":32768,"total":1292800},"progress":"[= ] 32.77 kB/1.293 MB","id":"8ac8bfaff55a"} 2707 {"status":"Loading layer","progressDetail":{"current":65536,"total":1292800},"progress":"[== ] 65.54 kB/1.293 MB","id":"8ac8bfaff55a"} 2708 {"status":"Loading layer","progressDetail":{"current":98304,"total":1292800},"progress":"[=== ] 98.3 kB/1.293 MB","id":"8ac8bfaff55a"} 2709 {"status":"Loading layer","progressDetail":{"current":131072,"total":1292800},"progress":"[===== ] 131.1 kB/1.293 MB","id":"8ac8bfaff55a"} 2710 ... 2711 {"stream":"Loaded image: busybox:latest\n"} 2712 2713 **Example response**: 2714 2715 If the "quiet" query parameter is set to `true` / `1` (`?quiet=1`), progress 2716 details are suppressed, and only a confirmation message is returned once the 2717 action completes. 2718 2719 HTTP/1.1 200 OK 2720 Content-Type: application/json 2721 Transfer-Encoding: chunked 2722 2723 {"stream":"Loaded image: busybox:latest\n"} 2724 2725 **Query parameters**: 2726 2727 - **quiet** – Boolean value, suppress progress details during load. Defaults 2728 to `0` / `false` if omitted. 2729 2730 **Status codes**: 2731 2732 - **200** – no error 2733 - **500** – server error 2734 2735 #### Image tarball format 2736 2737 An image tarball contains one directory per image layer (named using its long ID), 2738 each containing these files: 2739 2740 - `VERSION`: currently `1.0` - the file format version 2741 - `json`: detailed layer information, similar to `docker inspect layer_id` 2742 - `layer.tar`: A tarfile containing the filesystem changes in this layer 2743 2744 The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories 2745 for storing attribute changes and deletions. 2746 2747 If the tarball defines a repository, the tarball should also include a `repositories` file at 2748 the root that contains a list of repository and tag names mapped to layer IDs. 2749 2750 ``` 2751 {"hello-world": 2752 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 2753 } 2754 ``` 2755 2756 #### Exec Create 2757 2758 `POST /containers/(id or name)/exec` 2759 2760 Sets up an exec instance in a running container `id` 2761 2762 **Example request**: 2763 2764 POST /v1.23/containers/e90e34656806/exec HTTP/1.1 2765 Content-Type: application/json 2766 2767 { 2768 "AttachStdin": true, 2769 "AttachStdout": true, 2770 "AttachStderr": true, 2771 "Cmd": ["sh"], 2772 "DetachKeys": "ctrl-p,ctrl-q", 2773 "Privileged": true, 2774 "Tty": true, 2775 "User": "123:456" 2776 } 2777 2778 **Example response**: 2779 2780 HTTP/1.1 201 Created 2781 Content-Type: application/json 2782 2783 { 2784 "Id": "f90e34656806", 2785 "Warnings":[] 2786 } 2787 2788 **JSON parameters**: 2789 2790 - **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command. 2791 - **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command. 2792 - **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command. 2793 - **DetachKeys** – Override the key sequence for detaching a 2794 container. Format is a single character `[a-Z]` or `ctrl-<value>` 2795 where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. 2796 - **Tty** - Boolean value to allocate a pseudo-TTY. 2797 - **Cmd** - Command to run specified as a string or an array of strings. 2798 - **Privileged** - Boolean value, runs the exec process with extended privileges. 2799 - **User** - A string value specifying the user, and optionally, group to run 2800 the exec process inside the container. Format is one of: `"user"`, 2801 `"user:group"`, `"uid"`, or `"uid:gid"`. 2802 2803 **Status codes**: 2804 2805 - **201** – no error 2806 - **404** – no such container 2807 - **409** - container is paused 2808 - **500** - server error 2809 2810 #### Exec Start 2811 2812 `POST /exec/(id)/start` 2813 2814 Starts a previously set up `exec` instance `id`. If `detach` is true, this API 2815 returns after starting the `exec` command. Otherwise, this API sets up an 2816 interactive session with the `exec` command. 2817 2818 **Example request**: 2819 2820 POST /v1.23/exec/e90e34656806/start HTTP/1.1 2821 Content-Type: application/json 2822 2823 { 2824 "Detach": false, 2825 "Tty": false 2826 } 2827 2828 **Example response**: 2829 2830 HTTP/1.1 200 OK 2831 Content-Type: application/vnd.docker.raw-stream 2832 2833 {% raw %} 2834 {{ STREAM }} 2835 {% endraw %} 2836 2837 **JSON parameters**: 2838 2839 - **Detach** - Detach from the `exec` command. 2840 - **Tty** - Boolean value to allocate a pseudo-TTY. 2841 2842 **Status codes**: 2843 2844 - **200** – no error 2845 - **404** – no such exec instance 2846 - **409** - container is paused 2847 2848 **Stream details**: 2849 2850 Similar to the stream behavior of `POST /containers/(id or name)/attach` API 2851 2852 #### Exec Resize 2853 2854 `POST /exec/(id)/resize` 2855 2856 Resizes the `tty` session used by the `exec` command `id`. The unit is number of characters. 2857 This API is valid only if `tty` was specified as part of creating and starting the `exec` command. 2858 2859 **Example request**: 2860 2861 POST /v1.23/exec/e90e34656806/resize?h=40&w=80 HTTP/1.1 2862 Content-Type: text/plain 2863 2864 **Example response**: 2865 2866 HTTP/1.1 201 Created 2867 Content-Type: text/plain 2868 2869 **Query parameters**: 2870 2871 - **h** – height of `tty` session 2872 - **w** – width 2873 2874 **Status codes**: 2875 2876 - **201** – no error 2877 - **404** – no such exec instance 2878 2879 #### Exec Inspect 2880 2881 `GET /exec/(id)/json` 2882 2883 Return low-level information about the `exec` command `id`. 2884 2885 **Example request**: 2886 2887 GET /v1.23/exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1 2888 2889 **Example response**: 2890 2891 HTTP/1.1 200 OK 2892 Content-Type: application/json 2893 2894 { 2895 "CanRemove": false, 2896 "ContainerID": "b53ee82b53a40c7dca428523e34f741f3abc51d9f297a14ff874bf761b995126", 2897 "DetachKeys": "", 2898 "ExitCode": 2, 2899 "ID": "f33bbfb39f5b142420f4759b2348913bd4a8d1a6d7fd56499cb41a1bb91d7b3b", 2900 "OpenStderr": true, 2901 "OpenStdin": true, 2902 "OpenStdout": true, 2903 "ProcessConfig": { 2904 "arguments": [ 2905 "-c", 2906 "exit 2" 2907 ], 2908 "entrypoint": "sh", 2909 "privileged": false, 2910 "tty": true, 2911 "user": "1000" 2912 }, 2913 "Running": false 2914 } 2915 2916 **Status codes**: 2917 2918 - **200** – no error 2919 - **404** – no such exec instance 2920 - **500** - server error 2921 2922 ### 2.4 Volumes 2923 2924 #### List volumes 2925 2926 `GET /volumes` 2927 2928 **Example request**: 2929 2930 GET /v1.23/volumes HTTP/1.1 2931 2932 **Example response**: 2933 2934 HTTP/1.1 200 OK 2935 Content-Type: application/json 2936 2937 { 2938 "Volumes": [ 2939 { 2940 "Name": "tardis", 2941 "Driver": "local", 2942 "Mountpoint": "/var/lib/docker/volumes/tardis" 2943 } 2944 ], 2945 "Warnings": [] 2946 } 2947 2948 **Query parameters**: 2949 2950 - **filters** - JSON encoded value of the filters (a `map[string][]string`) to process on the volumes list. There is one available filter: `dangling=true` 2951 2952 **Status codes**: 2953 2954 - **200** - no error 2955 - **500** - server error 2956 2957 #### Create a volume 2958 2959 `POST /volumes/create` 2960 2961 Create a volume 2962 2963 **Example request**: 2964 2965 POST /v1.23/volumes/create HTTP/1.1 2966 Content-Type: application/json 2967 2968 { 2969 "Name": "tardis", 2970 "Labels": { 2971 "com.example.some-label": "some-value", 2972 "com.example.some-other-label": "some-other-value" 2973 } 2974 } 2975 2976 **Example response**: 2977 2978 HTTP/1.1 201 Created 2979 Content-Type: application/json 2980 2981 { 2982 "Name": "tardis", 2983 "Driver": "local", 2984 "Mountpoint": "/var/lib/docker/volumes/tardis", 2985 "Labels": { 2986 "com.example.some-label": "some-value", 2987 "com.example.some-other-label": "some-other-value" 2988 } 2989 } 2990 2991 **Status codes**: 2992 2993 - **201** - no error 2994 - **500** - server error 2995 2996 **JSON parameters**: 2997 2998 - **Name** - The new volume's name. If not specified, Docker generates a name. 2999 - **Driver** - Name of the volume driver to use. Defaults to `local` for the name. 3000 - **DriverOpts** - A mapping of driver options and values. These options are 3001 passed directly to the driver and are driver specific. 3002 - **Labels** - Labels to set on the volume, specified as a map: `{"key":"value","key2":"value2"}` 3003 3004 #### Inspect a volume 3005 3006 `GET /volumes/(name)` 3007 3008 Return low-level information on the volume `name` 3009 3010 **Example request**: 3011 3012 GET /v1.23/volumes/tardis 3013 3014 **Example response**: 3015 3016 HTTP/1.1 200 OK 3017 Content-Type: application/json 3018 3019 { 3020 "Name": "tardis", 3021 "Driver": "local", 3022 "Mountpoint": "/var/lib/docker/volumes/tardis/_data", 3023 "Labels": { 3024 "com.example.some-label": "some-value", 3025 "com.example.some-other-label": "some-other-value" 3026 } 3027 } 3028 3029 **Status codes**: 3030 3031 - **200** - no error 3032 - **404** - no such volume 3033 - **500** - server error 3034 3035 #### Remove a volume 3036 3037 `DELETE /volumes/(name)` 3038 3039 Instruct the driver to remove the volume (`name`). 3040 3041 **Example request**: 3042 3043 DELETE /v1.23/volumes/tardis HTTP/1.1 3044 3045 **Example response**: 3046 3047 HTTP/1.1 204 No Content 3048 3049 **Status codes**: 3050 3051 - **204** - no error 3052 - **404** - no such volume or volume driver 3053 - **409** - volume is in use and cannot be removed 3054 - **500** - server error 3055 3056 ### 3.5 Networks 3057 3058 #### List networks 3059 3060 `GET /networks` 3061 3062 **Example request**: 3063 3064 GET /v1.23/networks?filters={"type":{"custom":true}} HTTP/1.1 3065 3066 **Example response**: 3067 3068 ``` 3069 HTTP/1.1 200 OK 3070 Content-Type: application/json 3071 3072 [ 3073 { 3074 "Name": "bridge", 3075 "Id": "f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566", 3076 "Scope": "local", 3077 "Driver": "bridge", 3078 "EnableIPv6": false, 3079 "Internal": false, 3080 "IPAM": { 3081 "Driver": "default", 3082 "Config": [ 3083 { 3084 "Subnet": "172.17.0.0/16" 3085 } 3086 ] 3087 }, 3088 "Containers": { 3089 "39b69226f9d79f5634485fb236a23b2fe4e96a0a94128390a7fbbcc167065867": { 3090 "EndpointID": "ed2419a97c1d9954d05b46e462e7002ea552f216e9b136b80a7db8d98b442eda", 3091 "MacAddress": "02:42:ac:11:00:02", 3092 "IPv4Address": "172.17.0.2/16", 3093 "IPv6Address": "" 3094 } 3095 }, 3096 "Options": { 3097 "com.docker.network.bridge.default_bridge": "true", 3098 "com.docker.network.bridge.enable_icc": "true", 3099 "com.docker.network.bridge.enable_ip_masquerade": "true", 3100 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 3101 "com.docker.network.bridge.name": "docker0", 3102 "com.docker.network.driver.mtu": "1500" 3103 } 3104 }, 3105 { 3106 "Name": "none", 3107 "Id": "e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794", 3108 "Scope": "local", 3109 "Driver": "null", 3110 "EnableIPv6": false, 3111 "Internal": false, 3112 "IPAM": { 3113 "Driver": "default", 3114 "Config": [] 3115 }, 3116 "Containers": {}, 3117 "Options": {} 3118 }, 3119 { 3120 "Name": "host", 3121 "Id": "13e871235c677f196c4e1ecebb9dc733b9b2d2ab589e30c539efeda84a24215e", 3122 "Scope": "local", 3123 "Driver": "host", 3124 "EnableIPv6": false, 3125 "Internal": false, 3126 "IPAM": { 3127 "Driver": "default", 3128 "Config": [] 3129 }, 3130 "Containers": {}, 3131 "Options": {} 3132 } 3133 ] 3134 ``` 3135 3136 **Query parameters**: 3137 3138 - **filters** - JSON encoded network list filter. The filter value is one of: 3139 - `id=<network-id>` Matches all or part of a network id. 3140 - `name=<network-name>` Matches all or part of a network name. 3141 - `type=["custom"|"builtin"]` Filters networks by type. The `custom` keyword returns all user-defined networks. 3142 3143 **Status codes**: 3144 3145 - **200** - no error 3146 - **500** - server error 3147 3148 #### Inspect network 3149 3150 `GET /networks/<network-id>` 3151 3152 **Example request**: 3153 3154 GET /v1.23/networks/7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99 HTTP/1.1 3155 3156 **Example response**: 3157 3158 ``` 3159 HTTP/1.1 200 OK 3160 Content-Type: application/json 3161 3162 { 3163 "Name": "net01", 3164 "Id": "7d86d31b1478e7cca9ebed7e73aa0fdeec46c5ca29497431d3007d2d9e15ed99", 3165 "Scope": "local", 3166 "Driver": "bridge", 3167 "EnableIPv6": false, 3168 "IPAM": { 3169 "Driver": "default", 3170 "Config": [ 3171 { 3172 "Subnet": "172.19.0.0/16", 3173 "Gateway": "172.19.0.1/16" 3174 } 3175 ], 3176 "Options": { 3177 "foo": "bar" 3178 } 3179 }, 3180 "Internal": false, 3181 "Containers": { 3182 "19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c": { 3183 "Name": "test", 3184 "EndpointID": "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a", 3185 "MacAddress": "02:42:ac:13:00:02", 3186 "IPv4Address": "172.19.0.2/16", 3187 "IPv6Address": "" 3188 } 3189 }, 3190 "Options": { 3191 "com.docker.network.bridge.default_bridge": "true", 3192 "com.docker.network.bridge.enable_icc": "true", 3193 "com.docker.network.bridge.enable_ip_masquerade": "true", 3194 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 3195 "com.docker.network.bridge.name": "docker0", 3196 "com.docker.network.driver.mtu": "1500" 3197 }, 3198 "Labels": { 3199 "com.example.some-label": "some-value", 3200 "com.example.some-other-label": "some-other-value" 3201 } 3202 } 3203 ``` 3204 3205 **Status codes**: 3206 3207 - **200** - no error 3208 - **404** - network not found 3209 3210 #### Create a network 3211 3212 `POST /networks/create` 3213 3214 Create a network 3215 3216 **Example request**: 3217 3218 ``` 3219 POST /v1.23/networks/create HTTP/1.1 3220 Content-Type: application/json 3221 3222 { 3223 "Name":"isolated_nw", 3224 "CheckDuplicate":true, 3225 "Driver":"bridge", 3226 "EnableIPv6": true, 3227 "IPAM":{ 3228 "Driver": "default", 3229 "Config":[ 3230 { 3231 "Subnet":"172.20.0.0/16", 3232 "IPRange":"172.20.10.0/24", 3233 "Gateway":"172.20.10.11" 3234 }, 3235 { 3236 "Subnet":"2001:db8:abcd::/64", 3237 "Gateway":"2001:db8:abcd::1011" 3238 } 3239 ], 3240 "Options": { 3241 "foo": "bar" 3242 } 3243 }, 3244 "Internal":true, 3245 "Options": { 3246 "com.docker.network.bridge.default_bridge": "true", 3247 "com.docker.network.bridge.enable_icc": "true", 3248 "com.docker.network.bridge.enable_ip_masquerade": "true", 3249 "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0", 3250 "com.docker.network.bridge.name": "docker0", 3251 "com.docker.network.driver.mtu": "1500" 3252 }, 3253 "Labels": { 3254 "com.example.some-label": "some-value", 3255 "com.example.some-other-label": "some-other-value" 3256 } 3257 } 3258 ``` 3259 3260 **Example response**: 3261 3262 ``` 3263 HTTP/1.1 201 Created 3264 Content-Type: application/json 3265 3266 { 3267 "Id": "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30", 3268 "Warning": "" 3269 } 3270 ``` 3271 3272 **Status codes**: 3273 3274 - **201** - no error 3275 - **404** - plugin not found 3276 - **500** - server error 3277 3278 **JSON parameters**: 3279 3280 - **Name** - The new network's name. this is a mandatory field 3281 - **CheckDuplicate** - Requests daemon to check for networks with same name. Defaults to `false` 3282 - **Driver** - Name of the network driver plugin to use. Defaults to `bridge` driver 3283 - **Internal** - Restrict external access to the network 3284 - **IPAM** - Optional custom IP scheme for the network 3285 - **Driver** - Name of the IPAM driver to use. Defaults to `default` driver 3286 - **Config** - List of IPAM configuration options, specified as a map: 3287 `{"Subnet": <CIDR>, "IPRange": <CIDR>, "Gateway": <IP address>, "AuxAddress": <device_name:IP address>}` 3288 - **Options** - Driver-specific options, specified as a map: `{"option":"value" [,"option2":"value2"]}` 3289 - **EnableIPv6** - Enable IPv6 on the network 3290 - **Options** - Network specific options to be used by the drivers 3291 - **Labels** - Labels to set on the network, specified as a map: `{"key":"value" [,"key2":"value2"]}` 3292 3293 #### Connect a container to a network 3294 3295 `POST /networks/(id)/connect` 3296 3297 Connect a container to a network 3298 3299 **Example request**: 3300 3301 ``` 3302 POST /v1.23/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/connect HTTP/1.1 3303 Content-Type: application/json 3304 3305 { 3306 "Container":"3613f73ba0e4", 3307 "EndpointConfig": { 3308 "IPAMConfig": { 3309 "IPv4Address":"172.24.56.89", 3310 "IPv6Address":"2001:db8::5689" 3311 } 3312 } 3313 } 3314 ``` 3315 3316 **Example response**: 3317 3318 HTTP/1.1 200 OK 3319 3320 **Status codes**: 3321 3322 - **200** - no error 3323 - **404** - network or container is not found 3324 - **500** - Internal Server Error 3325 3326 **JSON parameters**: 3327 3328 - **container** - container-id/name to be connected to the network 3329 3330 #### Disconnect a container from a network 3331 3332 `POST /networks/(id)/disconnect` 3333 3334 Disconnect a container from a network 3335 3336 **Example request**: 3337 3338 ``` 3339 POST /v1.23/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30/disconnect HTTP/1.1 3340 Content-Type: application/json 3341 3342 { 3343 "Container":"3613f73ba0e4", 3344 "Force":false 3345 } 3346 ``` 3347 3348 **Example response**: 3349 3350 HTTP/1.1 200 OK 3351 3352 **Status codes**: 3353 3354 - **200** - no error 3355 - **404** - network or container not found 3356 - **500** - Internal Server Error 3357 3358 **JSON parameters**: 3359 3360 - **Container** - container-id/name to be disconnected from a network 3361 - **Force** - Force the container to disconnect from a network 3362 3363 #### Remove a network 3364 3365 `DELETE /networks/(id)` 3366 3367 Instruct the driver to remove the network (`id`). 3368 3369 **Example request**: 3370 3371 DELETE /v1.23/networks/22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30 HTTP/1.1 3372 3373 **Example response**: 3374 3375 HTTP/1.1 204 No Content 3376 3377 **Status codes**: 3378 3379 - **204** - no error 3380 - **404** - no such network 3381 - **500** - server error 3382 3383 ## 3. Going further 3384 3385 ### 3.1 Inside `docker run` 3386 3387 As an example, the `docker run` command line makes the following API calls: 3388 3389 - Create the container 3390 3391 - If the status code is 404, it means the image doesn't exist: 3392 - Try to pull it. 3393 - Then, retry to create the container. 3394 3395 - Start the container. 3396 3397 - If you are not in detached mode: 3398 - Attach to the container, using `logs=1` (to have `stdout` and 3399 `stderr` from the container's start) and `stream=1` 3400 3401 - If in detached mode or only `stdin` is attached, display the container's id. 3402 3403 ### 3.2 Hijacking 3404 3405 In this version of the API, `/attach`, uses hijacking to transport `stdin`, 3406 `stdout`, and `stderr` on the same socket. 3407 3408 To hint potential proxies about connection hijacking, Docker client sends 3409 connection upgrade headers similarly to websocket. 3410 3411 Upgrade: tcp 3412 Connection: Upgrade 3413 3414 When Docker daemon detects the `Upgrade` header, it switches its status code 3415 from **200 OK** to **101 UPGRADED** and resends the same headers. 3416 3417 3418 ### 3.3 CORS Requests 3419 3420 To set cross origin requests to the Engine API please give values to 3421 `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, 3422 default or blank means CORS disabled 3423 3424 $ dockerd -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"