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