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