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