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