github.com/kobeld/docker@v1.12.0-rc1/docs/reference/api/docker_remote_api_v1.20.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Remote API v1.20" 4 description = "API Documentation for Docker" 5 keywords = ["API, Docker, rcli, REST, documentation"] 6 [menu.main] 7 parent="engine_remoteapi" 8 weight = 1 9 +++ 10 <![end-metadata]--> 11 12 # Docker Remote API v1.20 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](../commandline/dockerd.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 "Command": "echo 1", 50 "Created": 1367854155, 51 "Status": "Exit 0", 52 "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}], 53 "Labels": { 54 "com.example.vendor": "Acme", 55 "com.example.license": "GPL", 56 "com.example.version": "1.0" 57 }, 58 "SizeRw": 12288, 59 "SizeRootFs": 0 60 }, 61 { 62 "Id": "9cd87474be90", 63 "Names":["/coolName"], 64 "Image": "ubuntu:latest", 65 "Command": "echo 222222", 66 "Created": 1367854155, 67 "Status": "Exit 0", 68 "Ports": [], 69 "Labels": {}, 70 "SizeRw": 12288, 71 "SizeRootFs": 0 72 }, 73 { 74 "Id": "3176a2479c92", 75 "Names":["/sleepy_dog"], 76 "Image": "ubuntu:latest", 77 "Command": "echo 3333333333333333", 78 "Created": 1367854154, 79 "Status": "Exit 0", 80 "Ports":[], 81 "Labels": {}, 82 "SizeRw":12288, 83 "SizeRootFs":0 84 }, 85 { 86 "Id": "4cb07b47f9fb", 87 "Names":["/running_cat"], 88 "Image": "ubuntu:latest", 89 "Command": "echo 444444444444444444444444444444444", 90 "Created": 1367854152, 91 "Status": "Exit 0", 92 "Ports": [], 93 "Labels": {}, 94 "SizeRw": 12288, 95 "SizeRootFs": 0 96 } 97 ] 98 99 Query Parameters: 100 101 - **all** – 1/True/true or 0/False/false, Show all containers. 102 Only running containers are shown by default (i.e., this defaults to false) 103 - **limit** – Show `limit` last created 104 containers, include non-running ones. 105 - **since** – Show only containers created since Id, include 106 non-running ones. 107 - **before** – Show only containers created before Id, include 108 non-running ones. 109 - **size** – 1/True/true or 0/False/false, Show the containers 110 sizes 111 - **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters: 112 - `exited=<int>`; -- containers with exit code of `<int>` ; 113 - `status=`(`created`|`restarting`|`running`|`paused`|`exited`) 114 - `label=key` or `label="key=value"` of a container label 115 116 Status Codes: 117 118 - **200** – no error 119 - **400** – bad parameter 120 - **500** – server error 121 122 ### Create a container 123 124 `POST /containers/create` 125 126 Create a container 127 128 **Example request**: 129 130 POST /containers/create HTTP/1.1 131 Content-Type: application/json 132 133 { 134 "Hostname": "", 135 "Domainname": "", 136 "User": "", 137 "AttachStdin": false, 138 "AttachStdout": true, 139 "AttachStderr": true, 140 "Tty": false, 141 "OpenStdin": false, 142 "StdinOnce": false, 143 "Env": [ 144 "FOO=bar", 145 "BAZ=quux" 146 ], 147 "Cmd": [ 148 "date" 149 ], 150 "Entrypoint": "", 151 "Image": "ubuntu", 152 "Labels": { 153 "com.example.vendor": "Acme", 154 "com.example.license": "GPL", 155 "com.example.version": "1.0" 156 }, 157 "Volumes": { 158 "/volumes/data": {} 159 }, 160 "WorkingDir": "", 161 "NetworkDisabled": false, 162 "MacAddress": "12:34:56:78:9a:bc", 163 "ExposedPorts": { 164 "22/tcp": {} 165 }, 166 "HostConfig": { 167 "Binds": ["/tmp:/tmp"], 168 "Links": ["redis3:redis"], 169 "LxcConf": {"lxc.utsname":"docker"}, 170 "Memory": 0, 171 "MemorySwap": 0, 172 "CpuShares": 512, 173 "CpuPeriod": 100000, 174 "CpuQuota": 50000, 175 "CpusetCpus": "0,1", 176 "CpusetMems": "0,1", 177 "BlkioWeight": 300, 178 "MemorySwappiness": 60, 179 "OomKillDisable": false, 180 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] }, 181 "PublishAllPorts": false, 182 "Privileged": false, 183 "ReadonlyRootfs": false, 184 "Dns": ["8.8.8.8"], 185 "DnsSearch": [""], 186 "ExtraHosts": null, 187 "VolumesFrom": ["parent", "other:ro"], 188 "CapAdd": ["NET_ADMIN"], 189 "CapDrop": ["MKNOD"], 190 "GroupAdd": ["newgroup"], 191 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 }, 192 "NetworkMode": "bridge", 193 "Devices": [], 194 "Ulimits": [{}], 195 "LogConfig": { "Type": "json-file", "Config": {} }, 196 "SecurityOpt": [], 197 "CgroupParent": "" 198 } 199 } 200 201 **Example response**: 202 203 HTTP/1.1 201 Created 204 Content-Type: application/json 205 206 { 207 "Id":"e90e34656806", 208 "Warnings":[] 209 } 210 211 Json Parameters: 212 213 - **Hostname** - A string value containing the hostname to use for the 214 container. 215 - **Domainname** - A string value containing the domain name to use 216 for the container. 217 - **User** - A string value specifying the user inside the container. 218 - **AttachStdin** - Boolean value, attaches to `stdin`. 219 - **AttachStdout** - Boolean value, attaches to `stdout`. 220 - **AttachStderr** - Boolean value, attaches to `stderr`. 221 - **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed. 222 - **OpenStdin** - Boolean value, opens stdin, 223 - **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects. 224 - **Env** - A list of environment variables in the form of `["VAR=value"[,"VAR2=value2"]]` 225 - **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}` 226 - **Cmd** - Command to run specified as a string or an array of strings. 227 - **Entrypoint** - Set the entry point for the container as a string or an array 228 of strings. 229 - **Image** - A string specifying the image name to use for the container. 230 - **Volumes** - An object mapping mount point paths (strings) inside the 231 container to empty objects. 232 - **WorkingDir** - A string specifying the working directory for commands to 233 run in. 234 - **NetworkDisabled** - Boolean value, when true disables networking for the 235 container 236 - **ExposedPorts** - An object mapping ports to an empty object in the form of: 237 `"ExposedPorts": { "<port>/<tcp|udp>: {}" }` 238 - **HostConfig** 239 - **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms: 240 + `container_path` to create a new volume for the container 241 + `host_path:container_path` to bind-mount a host path into the container 242 + `host_path:container_path:ro` to make the bind-mount read-only inside the container. 243 - **Links** - A list of links for the container. Each link entry should be 244 in the form of `container_name:alias`. 245 - **LxcConf** - LXC specific configurations. These configurations only 246 work when using the `lxc` execution driver. 247 - **Memory** - Memory limit in bytes. 248 - **MemorySwap** - Total memory limit (memory + swap); set `-1` to enable unlimited swap. 249 You must use this with `memory` and make the swap value larger than `memory`. 250 - **CpuShares** - An integer value containing the container's CPU Shares 251 (ie. the relative weight vs other containers). 252 - **CpuPeriod** - The length of a CPU period in microseconds. 253 - **CpuQuota** - Microseconds of CPU time that the container can get in a CPU period. 254 - **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use. 255 - **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. 256 - **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000. 257 - **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100. 258 - **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not. 259 - **PortBindings** - A map of exposed container ports and the host port they 260 should map to. A JSON object in the form 261 `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }` 262 Take note that `port` is specified as a string and not an integer value. 263 - **PublishAllPorts** - Allocates a random host port for all of a container's 264 exposed ports. Specified as a boolean value. 265 - **Privileged** - Gives the container full access to the host. Specified as 266 a boolean value. 267 - **ReadonlyRootfs** - Mount the container's root filesystem as read only. 268 Specified as a boolean value. 269 - **Dns** - A list of DNS servers for the container to use. 270 - **DnsSearch** - A list of DNS search domains 271 - **ExtraHosts** - A list of hostnames/IP mappings to add to the 272 container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`. 273 - **VolumesFrom** - A list of volumes to inherit from another container. 274 Specified in the form `<container name>[:<ro|rw>]` 275 - **CapAdd** - A list of kernel capabilities to add to the container. 276 - **Capdrop** - A list of kernel capabilities to drop from the container. 277 - **GroupAdd** - A list of additional groups that the container process will run as 278 - **RestartPolicy** – The behavior to apply when the container exits. The 279 value is an object with a `Name` property of either `"always"` to 280 always restart or `"on-failure"` to restart only when the container 281 exit code is non-zero. If `on-failure` is used, `MaximumRetryCount` 282 controls the number of times to retry before giving up. 283 The default is not to restart. (optional) 284 An ever increasing delay (double the previous delay, starting at 100mS) 285 is added before each restart to prevent flooding the server. 286 - **NetworkMode** - Sets the networking mode for the container. Supported 287 values are: `bridge`, `host`, `none`, and `container:<name|id>` 288 - **Devices** - A list of devices to add to the container specified as a JSON object in the 289 form 290 `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}` 291 - **Ulimits** - A list of ulimits to set in the container, specified as 292 `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example: 293 `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }` 294 - **SecurityOpt**: A list of string values to customize labels for MLS 295 systems, such as SELinux. 296 - **LogConfig** - Log configuration for the container, specified as a JSON object in the form 297 `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`. 298 Available types: `json-file`, `syslog`, `journald`, `gelf`, `none`. 299 `json-file` logging driver. 300 - **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. 301 302 Query Parameters: 303 304 - **name** – Assign the specified name to the container. Must 305 match `/?[a-zA-Z0-9_-]+`. 306 307 Status Codes: 308 309 - **201** – no error 310 - **400** – bad parameter 311 - **404** – no such container 312 - **406** – impossible to attach (container not running) 313 - **500** – server error 314 315 ### Inspect a container 316 317 `GET /containers/(id or name)/json` 318 319 Return low-level information on the container `id` 320 321 322 **Example request**: 323 324 GET /containers/4fa6e0f0c678/json HTTP/1.1 325 326 **Example response**: 327 328 HTTP/1.1 200 OK 329 Content-Type: application/json 330 331 { 332 "AppArmorProfile": "", 333 "Args": [ 334 "-c", 335 "exit 9" 336 ], 337 "Config": { 338 "AttachStderr": true, 339 "AttachStdin": false, 340 "AttachStdout": true, 341 "Cmd": [ 342 "/bin/sh", 343 "-c", 344 "exit 9" 345 ], 346 "Domainname": "", 347 "Entrypoint": null, 348 "Env": [ 349 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 350 ], 351 "ExposedPorts": null, 352 "Hostname": "ba033ac44011", 353 "Image": "ubuntu", 354 "Labels": { 355 "com.example.vendor": "Acme", 356 "com.example.license": "GPL", 357 "com.example.version": "1.0" 358 }, 359 "MacAddress": "", 360 "NetworkDisabled": false, 361 "OnBuild": null, 362 "OpenStdin": false, 363 "StdinOnce": false, 364 "Tty": false, 365 "User": "", 366 "Volumes": null, 367 "WorkingDir": "" 368 }, 369 "Created": "2015-01-06T15:47:31.485331387Z", 370 "Driver": "devicemapper", 371 "ExecDriver": "native-0.2", 372 "ExecIDs": null, 373 "HostConfig": { 374 "Binds": null, 375 "BlkioWeight": 0, 376 "CapAdd": null, 377 "CapDrop": null, 378 "ContainerIDFile": "", 379 "CpusetCpus": "", 380 "CpusetMems": "", 381 "CpuShares": 0, 382 "CpuPeriod": 100000, 383 "Devices": [], 384 "Dns": null, 385 "DnsSearch": null, 386 "ExtraHosts": null, 387 "IpcMode": "", 388 "Links": null, 389 "LxcConf": [], 390 "Memory": 0, 391 "MemorySwap": 0, 392 "OomKillDisable": false, 393 "NetworkMode": "bridge", 394 "PortBindings": {}, 395 "Privileged": false, 396 "ReadonlyRootfs": false, 397 "PublishAllPorts": false, 398 "RestartPolicy": { 399 "MaximumRetryCount": 2, 400 "Name": "on-failure" 401 }, 402 "LogConfig": { 403 "Config": null, 404 "Type": "json-file" 405 }, 406 "SecurityOpt": null, 407 "VolumesFrom": null, 408 "Ulimits": [{}] 409 }, 410 "HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname", 411 "HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts", 412 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log", 413 "Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39", 414 "Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2", 415 "MountLabel": "", 416 "Name": "/boring_euclid", 417 "NetworkSettings": { 418 "Bridge": "", 419 "Gateway": "", 420 "IPAddress": "", 421 "IPPrefixLen": 0, 422 "MacAddress": "", 423 "PortMapping": null, 424 "Ports": null 425 }, 426 "Path": "/bin/sh", 427 "ProcessLabel": "", 428 "ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf", 429 "RestartCount": 1, 430 "State": { 431 "Error": "", 432 "ExitCode": 9, 433 "FinishedAt": "2015-01-06T15:47:32.080254511Z", 434 "OOMKilled": false, 435 "Paused": false, 436 "Pid": 0, 437 "Restarting": false, 438 "Running": false, 439 "StartedAt": "2015-01-06T15:47:32.072697474Z" 440 }, 441 "Mounts": [ 442 { 443 "Source": "/data", 444 "Destination": "/data", 445 "Mode": "ro,Z", 446 "RW": false 447 } 448 ] 449 } 450 451 Status Codes: 452 453 - **200** – no error 454 - **404** – no such container 455 - **500** – server error 456 457 ### List processes running inside a container 458 459 `GET /containers/(id or name)/top` 460 461 List processes running inside the container `id`. On Unix systems this 462 is done by running the `ps` command. This endpoint is not 463 supported on Windows. 464 465 **Example request**: 466 467 GET /containers/4fa6e0f0c678/top HTTP/1.1 468 469 **Example response**: 470 471 HTTP/1.1 200 OK 472 Content-Type: application/json 473 474 { 475 "Titles" : [ 476 "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD" 477 ], 478 "Processes" : [ 479 [ 480 "root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash" 481 ], 482 [ 483 "root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10" 484 ] 485 ] 486 } 487 488 **Example request**: 489 490 GET /containers/4fa6e0f0c678/top?ps_args=aux HTTP/1.1 491 492 **Example response**: 493 494 HTTP/1.1 200 OK 495 Content-Type: application/json 496 497 { 498 "Titles" : [ 499 "USER","PID","%CPU","%MEM","VSZ","RSS","TTY","STAT","START","TIME","COMMAND" 500 ] 501 "Processes" : [ 502 [ 503 "root","13642","0.0","0.1","18172","3184","pts/0","Ss","17:03","0:00","/bin/bash" 504 ], 505 [ 506 "root","13895","0.0","0.0","4348","692","pts/0","S+","17:15","0:00","sleep 10" 507 ] 508 ], 509 } 510 511 Query Parameters: 512 513 - **ps_args** – `ps` arguments to use (e.g., `aux`), defaults to `-ef` 514 515 Status Codes: 516 517 - **200** – no error 518 - **404** – no such container 519 - **500** – server error 520 521 ### Get container logs 522 523 `GET /containers/(id or name)/logs` 524 525 Get `stdout` and `stderr` logs from the container ``id`` 526 527 > **Note**: 528 > This endpoint works only for containers with the `json-file` or `journald` logging drivers. 529 530 **Example request**: 531 532 GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1 533 534 **Example response**: 535 536 HTTP/1.1 101 UPGRADED 537 Content-Type: application/vnd.docker.raw-stream 538 Connection: Upgrade 539 Upgrade: tcp 540 541 {{ STREAM }} 542 543 Query Parameters: 544 545 - **follow** – 1/True/true or 0/False/false, return stream. Default `false`. 546 - **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`. 547 - **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`. 548 - **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp 549 will only output log-entries since that timestamp. Default: 0 (unfiltered) 550 - **timestamps** – 1/True/true or 0/False/false, print timestamps for 551 every log line. Default `false`. 552 - **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all. 553 554 Status Codes: 555 556 - **101** – no error, hints proxy about hijacking 557 - **200** – no error, no upgrade header found 558 - **404** – no such container 559 - **500** – server error 560 561 ### Inspect changes on a container's filesystem 562 563 `GET /containers/(id or name)/changes` 564 565 Inspect changes on container `id`'s filesystem 566 567 **Example request**: 568 569 GET /containers/4fa6e0f0c678/changes HTTP/1.1 570 571 **Example response**: 572 573 HTTP/1.1 200 OK 574 Content-Type: application/json 575 576 [ 577 { 578 "Path": "/dev", 579 "Kind": 0 580 }, 581 { 582 "Path": "/dev/kmsg", 583 "Kind": 1 584 }, 585 { 586 "Path": "/test", 587 "Kind": 1 588 } 589 ] 590 591 Values for `Kind`: 592 593 - `0`: Modify 594 - `1`: Add 595 - `2`: Delete 596 597 Status Codes: 598 599 - **200** – no error 600 - **404** – no such container 601 - **500** – server error 602 603 ### Export a container 604 605 `GET /containers/(id or name)/export` 606 607 Export the contents of container `id` 608 609 **Example request**: 610 611 GET /containers/4fa6e0f0c678/export HTTP/1.1 612 613 **Example response**: 614 615 HTTP/1.1 200 OK 616 Content-Type: application/octet-stream 617 618 {{ TAR STREAM }} 619 620 Status Codes: 621 622 - **200** – no error 623 - **404** – no such container 624 - **500** – server error 625 626 ### Get container stats based on resource usage 627 628 `GET /containers/(id or name)/stats` 629 630 This endpoint returns a live stream of a container's resource usage statistics. 631 632 **Example request**: 633 634 GET /containers/redis1/stats HTTP/1.1 635 636 **Example response**: 637 638 HTTP/1.1 200 OK 639 Content-Type: application/json 640 641 { 642 "read" : "2015-01-08T22:57:31.547920715Z", 643 "network" : { 644 "rx_dropped" : 0, 645 "rx_bytes" : 648, 646 "rx_errors" : 0, 647 "tx_packets" : 8, 648 "tx_dropped" : 0, 649 "rx_packets" : 8, 650 "tx_errors" : 0, 651 "tx_bytes" : 648 652 }, 653 "memory_stats" : { 654 "stats" : { 655 "total_pgmajfault" : 0, 656 "cache" : 0, 657 "mapped_file" : 0, 658 "total_inactive_file" : 0, 659 "pgpgout" : 414, 660 "rss" : 6537216, 661 "total_mapped_file" : 0, 662 "writeback" : 0, 663 "unevictable" : 0, 664 "pgpgin" : 477, 665 "total_unevictable" : 0, 666 "pgmajfault" : 0, 667 "total_rss" : 6537216, 668 "total_rss_huge" : 6291456, 669 "total_writeback" : 0, 670 "total_inactive_anon" : 0, 671 "rss_huge" : 6291456, 672 "hierarchical_memory_limit" : 67108864, 673 "total_pgfault" : 964, 674 "total_active_file" : 0, 675 "active_anon" : 6537216, 676 "total_active_anon" : 6537216, 677 "total_pgpgout" : 414, 678 "total_cache" : 0, 679 "inactive_anon" : 0, 680 "active_file" : 0, 681 "pgfault" : 964, 682 "inactive_file" : 0, 683 "total_pgpgin" : 477 684 }, 685 "max_usage" : 6651904, 686 "usage" : 6537216, 687 "failcnt" : 0, 688 "limit" : 67108864 689 }, 690 "blkio_stats" : {}, 691 "cpu_stats" : { 692 "cpu_usage" : { 693 "percpu_usage" : [ 694 8646879, 695 24472255, 696 36438778, 697 30657443 698 ], 699 "usage_in_usermode" : 50000000, 700 "total_usage" : 100215355, 701 "usage_in_kernelmode" : 30000000 702 }, 703 "system_cpu_usage" : 739306590000000, 704 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0} 705 }, 706 "precpu_stats" : { 707 "cpu_usage" : { 708 "percpu_usage" : [ 709 8646879, 710 24350896, 711 36438778, 712 30657443 713 ], 714 "usage_in_usermode" : 50000000, 715 "total_usage" : 100093996, 716 "usage_in_kernelmode" : 30000000 717 }, 718 "system_cpu_usage" : 9492140000000, 719 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0} 720 } 721 } 722 723 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. 724 725 Query Parameters: 726 727 - **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`. 728 729 Status Codes: 730 731 - **200** – no error 732 - **404** – no such container 733 - **500** – server error 734 735 ### Resize a container TTY 736 737 `POST /containers/(id or name)/resize?h=<height>&w=<width>` 738 739 Resize the TTY for container with `id`. You must restart the container for the resize to take effect. 740 741 **Example request**: 742 743 POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1 744 745 **Example response**: 746 747 HTTP/1.1 200 OK 748 Content-Length: 0 749 Content-Type: text/plain; charset=utf-8 750 751 Status Codes: 752 753 - **200** – no error 754 - **404** – No such container 755 - **500** – Cannot resize container 756 757 ### Start a container 758 759 `POST /containers/(id or name)/start` 760 761 Start the container `id` 762 763 > **Note**: 764 > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body. 765 > See [create a container](#create-a-container) for details. 766 767 **Example request**: 768 769 POST /containers/e90e34656806/start HTTP/1.1 770 771 **Example response**: 772 773 HTTP/1.1 204 No Content 774 775 Status Codes: 776 777 - **204** – no error 778 - **304** – container already started 779 - **404** – no such container 780 - **500** – server error 781 782 ### Stop a container 783 784 `POST /containers/(id or name)/stop` 785 786 Stop the container `id` 787 788 **Example request**: 789 790 POST /containers/e90e34656806/stop?t=5 HTTP/1.1 791 792 **Example response**: 793 794 HTTP/1.1 204 No Content 795 796 Query Parameters: 797 798 - **t** – number of seconds to wait before killing the container 799 800 Status Codes: 801 802 - **204** – no error 803 - **304** – container already stopped 804 - **404** – no such container 805 - **500** – server error 806 807 ### Restart a container 808 809 `POST /containers/(id or name)/restart` 810 811 Restart the container `id` 812 813 **Example request**: 814 815 POST /containers/e90e34656806/restart?t=5 HTTP/1.1 816 817 **Example response**: 818 819 HTTP/1.1 204 No Content 820 821 Query Parameters: 822 823 - **t** – number of seconds to wait before killing the container 824 825 Status Codes: 826 827 - **204** – no error 828 - **404** – no such container 829 - **500** – server error 830 831 ### Kill a container 832 833 `POST /containers/(id or name)/kill` 834 835 Kill the container `id` 836 837 **Example request**: 838 839 POST /containers/e90e34656806/kill HTTP/1.1 840 841 **Example response**: 842 843 HTTP/1.1 204 No Content 844 845 Query Parameters 846 847 - **signal** - Signal to send to the container: integer or string like `SIGINT`. 848 When not set, `SIGKILL` is assumed and the call waits for the container to exit. 849 850 Status Codes: 851 852 - **204** – no error 853 - **404** – no such container 854 - **500** – server error 855 856 ### Rename a container 857 858 `POST /containers/(id or name)/rename` 859 860 Rename the container `id` to a `new_name` 861 862 **Example request**: 863 864 POST /containers/e90e34656806/rename?name=new_name HTTP/1.1 865 866 **Example response**: 867 868 HTTP/1.1 204 No Content 869 870 Query Parameters: 871 872 - **name** – new name for the container 873 874 Status Codes: 875 876 - **204** – no error 877 - **404** – no such container 878 - **409** - conflict name already assigned 879 - **500** – server error 880 881 ### Pause a container 882 883 `POST /containers/(id or name)/pause` 884 885 Pause the container `id` 886 887 **Example request**: 888 889 POST /containers/e90e34656806/pause HTTP/1.1 890 891 **Example response**: 892 893 HTTP/1.1 204 No Content 894 895 Status Codes: 896 897 - **204** – no error 898 - **404** – no such container 899 - **500** – server error 900 901 ### Unpause a container 902 903 `POST /containers/(id or name)/unpause` 904 905 Unpause the container `id` 906 907 **Example request**: 908 909 POST /containers/e90e34656806/unpause HTTP/1.1 910 911 **Example response**: 912 913 HTTP/1.1 204 No Content 914 915 Status Codes: 916 917 - **204** – no error 918 - **404** – no such container 919 - **500** – server error 920 921 ### Attach to a container 922 923 `POST /containers/(id or name)/attach` 924 925 Attach to the container `id` 926 927 **Example request**: 928 929 POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1 930 931 **Example response**: 932 933 HTTP/1.1 101 UPGRADED 934 Content-Type: application/vnd.docker.raw-stream 935 Connection: Upgrade 936 Upgrade: tcp 937 938 {{ STREAM }} 939 940 Query Parameters: 941 942 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`. 943 - **stream** – 1/True/true or 0/False/false, return stream. 944 Default `false`. 945 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach 946 to `stdin`. Default `false`. 947 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return 948 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`. 949 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return 950 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`. 951 952 Status Codes: 953 954 - **101** – no error, hints proxy about hijacking 955 - **200** – no error, no upgrade header found 956 - **400** – bad parameter 957 - **404** – no such container 958 - **500** – server error 959 960 **Stream details**: 961 962 When using the TTY setting is enabled in 963 [`POST /containers/create` 964 ](#create-a-container), 965 the stream is the raw data from the process PTY and client's `stdin`. 966 When the TTY is disabled, then the stream is multiplexed to separate 967 `stdout` and `stderr`. 968 969 The format is a **Header** and a **Payload** (frame). 970 971 **HEADER** 972 973 The header contains the information which the stream writes (`stdout` or 974 `stderr`). It also contains the size of the associated frame encoded in the 975 last four bytes (`uint32`). 976 977 It is encoded on the first eight bytes like this: 978 979 header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} 980 981 `STREAM_TYPE` can be: 982 983 - 0: `stdin` (is written on `stdout`) 984 - 1: `stdout` 985 - 2: `stderr` 986 987 `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of 988 the `uint32` size encoded as big endian. 989 990 **PAYLOAD** 991 992 The payload is the raw stream. 993 994 **IMPLEMENTATION** 995 996 The simplest way to implement the Attach protocol is the following: 997 998 1. Read eight bytes. 999 2. Choose `stdout` or `stderr` depending on the first byte. 1000 3. Extract the frame size from the last four bytes. 1001 4. Read the extracted size and output it on the correct output. 1002 5. Goto 1. 1003 1004 ### Attach to a container (websocket) 1005 1006 `GET /containers/(id or name)/attach/ws` 1007 1008 Attach to the container `id` via websocket 1009 1010 Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455) 1011 1012 **Example request** 1013 1014 GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1 1015 1016 **Example response** 1017 1018 {{ STREAM }} 1019 1020 Query Parameters: 1021 1022 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`. 1023 - **stream** – 1/True/true or 0/False/false, return stream. 1024 Default `false`. 1025 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach 1026 to `stdin`. Default `false`. 1027 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return 1028 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`. 1029 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return 1030 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`. 1031 1032 Status Codes: 1033 1034 - **200** – no error 1035 - **400** – bad parameter 1036 - **404** – no such container 1037 - **500** – server error 1038 1039 ### Wait a container 1040 1041 `POST /containers/(id or name)/wait` 1042 1043 Block until container `id` stops, then returns the exit code 1044 1045 **Example request**: 1046 1047 POST /containers/16253994b7c4/wait HTTP/1.1 1048 1049 **Example response**: 1050 1051 HTTP/1.1 200 OK 1052 Content-Type: application/json 1053 1054 {"StatusCode": 0} 1055 1056 Status Codes: 1057 1058 - **200** – no error 1059 - **404** – no such container 1060 - **500** – server error 1061 1062 ### Remove a container 1063 1064 `DELETE /containers/(id or name)` 1065 1066 Remove the container `id` from the filesystem 1067 1068 **Example request**: 1069 1070 DELETE /containers/16253994b7c4?v=1 HTTP/1.1 1071 1072 **Example response**: 1073 1074 HTTP/1.1 204 No Content 1075 1076 Query Parameters: 1077 1078 - **v** – 1/True/true or 0/False/false, Remove the volumes 1079 associated to the container. Default `false`. 1080 - **force** - 1/True/true or 0/False/false, Kill then remove the container. 1081 Default `false`. 1082 1083 Status Codes: 1084 1085 - **204** – no error 1086 - **400** – bad parameter 1087 - **404** – no such container 1088 - **500** – server error 1089 1090 ### Copy files or folders from a container 1091 1092 `POST /containers/(id or name)/copy` 1093 1094 Copy files or folders of container `id` 1095 1096 **Deprecated** in favor of the `archive` endpoint below. 1097 1098 **Example request**: 1099 1100 POST /containers/4fa6e0f0c678/copy HTTP/1.1 1101 Content-Type: application/json 1102 1103 { 1104 "Resource": "test.txt" 1105 } 1106 1107 **Example response**: 1108 1109 HTTP/1.1 200 OK 1110 Content-Type: application/x-tar 1111 1112 {{ TAR STREAM }} 1113 1114 Status Codes: 1115 1116 - **200** – no error 1117 - **404** – no such container 1118 - **500** – server error 1119 1120 ### Retrieving information about files and folders in a container 1121 1122 `HEAD /containers/(id or name)/archive` 1123 1124 See the description of the `X-Docker-Container-Path-Stat` header in the 1125 following section. 1126 1127 ### Get an archive of a filesystem resource in a container 1128 1129 `GET /containers/(id or name)/archive` 1130 1131 Get a tar archive of a resource in the filesystem of container `id`. 1132 1133 Query Parameters: 1134 1135 - **path** - resource in the container's filesystem to archive. Required. 1136 1137 If not an absolute path, it is relative to the container's root directory. 1138 The resource specified by **path** must exist. To assert that the resource 1139 is expected to be a directory, **path** should end in `/` or `/.` 1140 (assuming a path separator of `/`). If **path** ends in `/.` then this 1141 indicates that only the contents of the **path** directory should be 1142 copied. A symlink is always resolved to its target. 1143 1144 **Note**: It is not possible to copy certain system files such as resources 1145 under `/proc`, `/sys`, `/dev`, and mounts created by the user in the 1146 container. 1147 1148 **Example request**: 1149 1150 GET /containers/8cce319429b2/archive?path=/root HTTP/1.1 1151 1152 **Example response**: 1153 1154 HTTP/1.1 200 OK 1155 Content-Type: application/x-tar 1156 X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= 1157 1158 {{ TAR STREAM }} 1159 1160 On success, a response header `X-Docker-Container-Path-Stat` will be set to a 1161 base64-encoded JSON object containing some filesystem header information about 1162 the archived resource. The above example value would decode to the following 1163 JSON object (whitespace added for readability): 1164 1165 { 1166 "name": "root", 1167 "size": 4096, 1168 "mode": 2147484096, 1169 "mtime": "2014-02-27T20:51:23Z", 1170 "linkTarget": "" 1171 } 1172 1173 A `HEAD` request can also be made to this endpoint if only this information is 1174 desired. 1175 1176 Status Codes: 1177 1178 - **200** - success, returns archive of copied resource 1179 - **400** - client error, bad parameter, details in JSON response body, one of: 1180 - must specify path parameter (**path** cannot be empty) 1181 - not a directory (**path** was asserted to be a directory but exists as a 1182 file) 1183 - **404** - client error, resource not found, one of: 1184 – no such container (container `id` does not exist) 1185 - no such file or directory (**path** does not exist) 1186 - **500** - server error 1187 1188 ### Extract an archive of files or folders to a directory in a container 1189 1190 `PUT /containers/(id or name)/archive` 1191 1192 Upload a tar archive to be extracted to a path in the filesystem of container 1193 `id`. 1194 1195 Query Parameters: 1196 1197 - **path** - path to a directory in the container 1198 to extract the archive's contents into. Required. 1199 1200 If not an absolute path, it is relative to the container's root directory. 1201 The **path** resource must exist. 1202 - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error 1203 if unpacking the given content would cause an existing directory to be 1204 replaced with a non-directory and vice versa. 1205 1206 **Example request**: 1207 1208 PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 1209 Content-Type: application/x-tar 1210 1211 {{ TAR STREAM }} 1212 1213 **Example response**: 1214 1215 HTTP/1.1 200 OK 1216 1217 Status Codes: 1218 1219 - **200** – the content was extracted successfully 1220 - **400** - client error, bad parameter, details in JSON response body, one of: 1221 - must specify path parameter (**path** cannot be empty) 1222 - not a directory (**path** should be a directory but exists as a file) 1223 - unable to overwrite existing directory with non-directory 1224 (if **noOverwriteDirNonDir**) 1225 - unable to overwrite existing non-directory with directory 1226 (if **noOverwriteDirNonDir**) 1227 - **403** - client error, permission denied, the volume 1228 or container rootfs is marked as read-only. 1229 - **404** - client error, resource not found, one of: 1230 – no such container (container `id` does not exist) 1231 - no such file or directory (**path** resource does not exist) 1232 - **500** – server error 1233 1234 ## 2.2 Images 1235 1236 ### List Images 1237 1238 `GET /images/json` 1239 1240 **Example request**: 1241 1242 GET /images/json?all=0 HTTP/1.1 1243 1244 **Example response**: 1245 1246 HTTP/1.1 200 OK 1247 Content-Type: application/json 1248 1249 [ 1250 { 1251 "RepoTags": [ 1252 "ubuntu:12.04", 1253 "ubuntu:precise", 1254 "ubuntu:latest" 1255 ], 1256 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 1257 "Created": 1365714795, 1258 "Size": 131506275, 1259 "VirtualSize": 131506275, 1260 "Labels": {} 1261 }, 1262 { 1263 "RepoTags": [ 1264 "ubuntu:12.10", 1265 "ubuntu:quantal" 1266 ], 1267 "ParentId": "27cf784147099545", 1268 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1269 "Created": 1364102658, 1270 "Size": 24653, 1271 "VirtualSize": 180116135, 1272 "Labels": { 1273 "com.example.version": "v1" 1274 } 1275 } 1276 ] 1277 1278 **Example request, with digest information**: 1279 1280 GET /images/json?digests=1 HTTP/1.1 1281 1282 **Example response, with digest information**: 1283 1284 HTTP/1.1 200 OK 1285 Content-Type: application/json 1286 1287 [ 1288 { 1289 "Created": 1420064636, 1290 "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125", 1291 "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2", 1292 "RepoDigests": [ 1293 "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" 1294 ], 1295 "RepoTags": [ 1296 "localhost:5000/test/busybox:latest", 1297 "playdate:latest" 1298 ], 1299 "Size": 0, 1300 "VirtualSize": 2429728, 1301 "Labels": {} 1302 } 1303 ] 1304 1305 The response shows a single image `Id` associated with two repositories 1306 (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use 1307 either of the `RepoTags` values `localhost:5000/test/busybox:latest` or 1308 `playdate:latest` to reference the image. 1309 1310 You can also use `RepoDigests` values to reference an image. In this response, 1311 the array has only one reference and that is to the 1312 `localhost:5000/test/busybox` repository; the `playdate` repository has no 1313 digest. You can reference this digest using the value: 1314 `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...` 1315 1316 See the `docker run` and `docker build` commands for examples of digest and tag 1317 references on the command line. 1318 1319 Query Parameters: 1320 1321 - **all** – 1/True/true or 0/False/false, default false 1322 - **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters: 1323 - `dangling=true` 1324 - `label=key` or `label="key=value"` of an image label 1325 - **filter** - only return images with the specified name 1326 1327 ### Build image from a Dockerfile 1328 1329 `POST /build` 1330 1331 Build an image from a Dockerfile 1332 1333 **Example request**: 1334 1335 POST /build HTTP/1.1 1336 1337 {{ TAR STREAM }} 1338 1339 **Example response**: 1340 1341 HTTP/1.1 200 OK 1342 Content-Type: application/json 1343 1344 {"stream": "Step 1..."} 1345 {"stream": "..."} 1346 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 1347 1348 The input stream must be a `tar` archive compressed with one of the 1349 following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`. 1350 1351 The archive must include a build instructions file, typically called 1352 `Dockerfile` at the archive's root. The `dockerfile` parameter may be 1353 used to specify a different build instructions file. To do this, its value must be 1354 the path to the alternate build instructions file to use. 1355 1356 The archive may include any number of other files, 1357 which are accessible in the build context (See the [*ADD build 1358 command*](../../reference/builder.md#dockerbuilder)). 1359 1360 The build is canceled if the client drops the connection by quitting 1361 or being killed. 1362 1363 Query Parameters: 1364 1365 - **dockerfile** - Path within the build context to the Dockerfile. This is 1366 ignored if `remote` is specified and points to an individual filename. 1367 - **t** – A repository name (and optionally a tag) to apply to 1368 the resulting image in case of success. 1369 - **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the 1370 URI specifies a filename, the file's contents are placed into a file 1371 called `Dockerfile`. 1372 - **q** – Suppress verbose build output. 1373 - **nocache** – Do not use the cache when building the image. 1374 - **pull** - Attempt to pull the image even if an older image exists locally. 1375 - **rm** - Remove intermediate containers after a successful build (default behavior). 1376 - **forcerm** - Always remove intermediate containers (includes `rm`). 1377 - **memory** - Set memory limit for build. 1378 - **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap. 1379 - **cpushares** - CPU shares (relative weight). 1380 - **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`). 1381 - **cpuperiod** - The length of a CPU period in microseconds. 1382 - **cpuquota** - Microseconds of CPU time that the container can get in a CPU period. 1383 1384 Request Headers: 1385 1386 - **Content-type** – Set to `"application/tar"`. 1387 - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON 1388 object with the following structure: 1389 1390 { 1391 "docker.example.com": { 1392 "username": "janedoe", 1393 "password": "hunter2" 1394 }, 1395 "https://index.docker.io/v1/": { 1396 "username": "mobydock", 1397 "password": "conta1n3rize14" 1398 } 1399 } 1400 1401 This object maps the hostname of a registry to an object containing the 1402 "username" and "password" for that registry. Multiple registries may 1403 be specified as the build may be based on an image requiring 1404 authentication to pull from any arbitrary registry. Only the registry 1405 domain name (and port if not the default "443") are required. However 1406 (for legacy reasons) the "official" Docker, Inc. hosted registry must 1407 be specified with both a "https://" prefix and a "/v1/" suffix even 1408 though Docker will prefer to use the v2 registry API. 1409 1410 Status Codes: 1411 1412 - **200** – no error 1413 - **500** – server error 1414 1415 ### Create an image 1416 1417 `POST /images/create` 1418 1419 Create an image either by pulling it from the registry or by importing it 1420 1421 **Example request**: 1422 1423 POST /images/create?fromImage=ubuntu HTTP/1.1 1424 1425 **Example response**: 1426 1427 HTTP/1.1 200 OK 1428 Content-Type: application/json 1429 1430 {"status": "Pulling..."} 1431 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 1432 {"error": "Invalid..."} 1433 ... 1434 1435 When using this endpoint to pull an image from the registry, the 1436 `X-Registry-Auth` header can be used to include 1437 a base64-encoded AuthConfig object. 1438 1439 Query Parameters: 1440 1441 - **fromImage** – Name of the image to pull. 1442 - **fromSrc** – Source to import. The value may be a URL from which the image 1443 can be retrieved or `-` to read the image from the request body. 1444 - **repo** – Repository name. 1445 - **tag** – Tag. 1446 1447 Request Headers: 1448 1449 - **X-Registry-Auth** – base64-encoded AuthConfig object 1450 1451 Status Codes: 1452 1453 - **200** – no error 1454 - **500** – server error 1455 1456 1457 1458 ### Inspect an image 1459 1460 `GET /images/(name)/json` 1461 1462 Return low-level information on the image `name` 1463 1464 **Example request**: 1465 1466 GET /images/ubuntu/json HTTP/1.1 1467 1468 **Example response**: 1469 1470 HTTP/1.1 200 OK 1471 Content-Type: application/json 1472 1473 { 1474 "Created": "2013-03-23T22:24:18.818426-07:00", 1475 "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0", 1476 "ContainerConfig": 1477 { 1478 "Hostname": "", 1479 "User": "", 1480 "AttachStdin": false, 1481 "AttachStdout": false, 1482 "AttachStderr": false, 1483 "Tty": true, 1484 "OpenStdin": true, 1485 "StdinOnce": false, 1486 "Env": null, 1487 "Cmd": ["/bin/bash"], 1488 "Dns": null, 1489 "Image": "ubuntu", 1490 "Labels": { 1491 "com.example.vendor": "Acme", 1492 "com.example.license": "GPL", 1493 "com.example.version": "1.0" 1494 }, 1495 "Volumes": null, 1496 "VolumesFrom": "", 1497 "WorkingDir": "" 1498 }, 1499 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1500 "Parent": "27cf784147099545", 1501 "Size": 6824592 1502 } 1503 1504 Status Codes: 1505 1506 - **200** – no error 1507 - **404** – no such image 1508 - **500** – server error 1509 1510 ### Get the history of an image 1511 1512 `GET /images/(name)/history` 1513 1514 Return the history of the image `name` 1515 1516 **Example request**: 1517 1518 GET /images/ubuntu/history HTTP/1.1 1519 1520 **Example response**: 1521 1522 HTTP/1.1 200 OK 1523 Content-Type: application/json 1524 1525 [ 1526 { 1527 "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710", 1528 "Created": 1398108230, 1529 "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /", 1530 "Tags": [ 1531 "ubuntu:lucid", 1532 "ubuntu:10.04" 1533 ], 1534 "Size": 182964289, 1535 "Comment": "" 1536 }, 1537 { 1538 "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8", 1539 "Created": 1398108222, 1540 "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/", 1541 "Tags": null, 1542 "Size": 0, 1543 "Comment": "" 1544 }, 1545 { 1546 "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158", 1547 "Created": 1371157430, 1548 "CreatedBy": "", 1549 "Tags": [ 1550 "scratch12:latest", 1551 "scratch:latest" 1552 ], 1553 "Size": 0, 1554 "Comment": "Imported from -" 1555 } 1556 ] 1557 1558 Status Codes: 1559 1560 - **200** – no error 1561 - **404** – no such image 1562 - **500** – server error 1563 1564 ### Push an image on the registry 1565 1566 `POST /images/(name)/push` 1567 1568 Push the image `name` on the registry 1569 1570 **Example request**: 1571 1572 POST /images/test/push HTTP/1.1 1573 1574 **Example response**: 1575 1576 HTTP/1.1 200 OK 1577 Content-Type: application/json 1578 1579 {"status": "Pushing..."} 1580 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 1581 {"error": "Invalid..."} 1582 ... 1583 1584 If you wish to push an image on to a private registry, that image must already have a tag 1585 into a repository which references that registry `hostname` and `port`. This repository name should 1586 then be used in the URL. This duplicates the command line's flow. 1587 1588 **Example request**: 1589 1590 POST /images/registry.acme.com:5000/test/push HTTP/1.1 1591 1592 1593 Query Parameters: 1594 1595 - **tag** – The tag to associate with the image on the registry. This is optional. 1596 1597 Request Headers: 1598 1599 - **X-Registry-Auth** – Include a base64-encoded AuthConfig. 1600 object. 1601 1602 Status Codes: 1603 1604 - **200** – no error 1605 - **404** – no such image 1606 - **500** – server error 1607 1608 ### Tag an image into a repository 1609 1610 `POST /images/(name)/tag` 1611 1612 Tag the image `name` into a repository 1613 1614 **Example request**: 1615 1616 POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1 1617 1618 **Example response**: 1619 1620 HTTP/1.1 201 Created 1621 1622 Query Parameters: 1623 1624 - **repo** – The repository to tag in 1625 - **force** – 1/True/true or 0/False/false, default false 1626 - **tag** - The new tag name 1627 1628 Status Codes: 1629 1630 - **201** – no error 1631 - **400** – bad parameter 1632 - **404** – no such image 1633 - **409** – conflict 1634 - **500** – server error 1635 1636 ### Remove an image 1637 1638 `DELETE /images/(name)` 1639 1640 Remove the image `name` from the filesystem 1641 1642 **Example request**: 1643 1644 DELETE /images/test HTTP/1.1 1645 1646 **Example response**: 1647 1648 HTTP/1.1 200 OK 1649 Content-type: application/json 1650 1651 [ 1652 {"Untagged": "3e2f21a89f"}, 1653 {"Deleted": "3e2f21a89f"}, 1654 {"Deleted": "53b4f83ac9"} 1655 ] 1656 1657 Query Parameters: 1658 1659 - **force** – 1/True/true or 0/False/false, default false 1660 - **noprune** – 1/True/true or 0/False/false, default false 1661 1662 Status Codes: 1663 1664 - **200** – no error 1665 - **404** – no such image 1666 - **409** – conflict 1667 - **500** – server error 1668 1669 ### Search images 1670 1671 `GET /images/search` 1672 1673 Search for an image on [Docker Hub](https://hub.docker.com). 1674 1675 > **Note**: 1676 > The response keys have changed from API v1.6 to reflect the JSON 1677 > sent by the registry server to the docker daemon's request. 1678 1679 **Example request**: 1680 1681 GET /images/search?term=sshd HTTP/1.1 1682 1683 **Example response**: 1684 1685 HTTP/1.1 200 OK 1686 Content-Type: application/json 1687 1688 [ 1689 { 1690 "description": "", 1691 "is_official": false, 1692 "is_automated": false, 1693 "name": "wma55/u1210sshd", 1694 "star_count": 0 1695 }, 1696 { 1697 "description": "", 1698 "is_official": false, 1699 "is_automated": false, 1700 "name": "jdswinbank/sshd", 1701 "star_count": 0 1702 }, 1703 { 1704 "description": "", 1705 "is_official": false, 1706 "is_automated": false, 1707 "name": "vgauthier/sshd", 1708 "star_count": 0 1709 } 1710 ... 1711 ] 1712 1713 Query Parameters: 1714 1715 - **term** – term to search 1716 1717 Status Codes: 1718 1719 - **200** – no error 1720 - **500** – server error 1721 1722 ## 2.3 Misc 1723 1724 ### Check auth configuration 1725 1726 `POST /auth` 1727 1728 Get the default username and email 1729 1730 **Example request**: 1731 1732 POST /auth HTTP/1.1 1733 Content-Type: application/json 1734 1735 { 1736 "username":" hannibal", 1737 "password: "xxxx", 1738 "email": "hannibal@a-team.com", 1739 "serveraddress": "https://index.docker.io/v1/" 1740 } 1741 1742 **Example response**: 1743 1744 HTTP/1.1 200 OK 1745 1746 Status Codes: 1747 1748 - **200** – no error 1749 - **204** – no error 1750 - **500** – server error 1751 1752 ### Display system-wide information 1753 1754 `GET /info` 1755 1756 Display system-wide information 1757 1758 **Example request**: 1759 1760 GET /info HTTP/1.1 1761 1762 **Example response**: 1763 1764 HTTP/1.1 200 OK 1765 Content-Type: application/json 1766 1767 { 1768 "Containers": 11, 1769 "CpuCfsPeriod": true, 1770 "CpuCfsQuota": true, 1771 "Debug": false, 1772 "DockerRootDir": "/var/lib/docker", 1773 "Driver": "btrfs", 1774 "DriverStatus": [[""]], 1775 "ExecutionDriver": "native-0.1", 1776 "ExperimentalBuild": false, 1777 "HttpProxy": "http://test:test@localhost:8080", 1778 "HttpsProxy": "https://test:test@localhost:8080", 1779 "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS", 1780 "IPv4Forwarding": true, 1781 "Images": 16, 1782 "IndexServerAddress": "https://index.docker.io/v1/", 1783 "InitPath": "/usr/bin/docker", 1784 "InitSha1": "", 1785 "KernelVersion": "3.12.0-1-amd64", 1786 "Labels": [ 1787 "storage=ssd" 1788 ], 1789 "MemTotal": 2099236864, 1790 "MemoryLimit": true, 1791 "NCPU": 1, 1792 "NEventsListener": 0, 1793 "NFd": 11, 1794 "NGoroutines": 21, 1795 "Name": "prod-server-42", 1796 "NoProxy": "9.81.1.160", 1797 "OomKillDisable": true, 1798 "OperatingSystem": "Boot2Docker", 1799 "RegistryConfig": { 1800 "IndexConfigs": { 1801 "docker.io": { 1802 "Mirrors": null, 1803 "Name": "docker.io", 1804 "Official": true, 1805 "Secure": true 1806 } 1807 }, 1808 "InsecureRegistryCIDRs": [ 1809 "127.0.0.0/8" 1810 ] 1811 }, 1812 "SwapLimit": false, 1813 "SystemTime": "2015-03-10T11:11:23.730591467-07:00" 1814 } 1815 1816 Status Codes: 1817 1818 - **200** – no error 1819 - **500** – server error 1820 1821 ### Show the docker version information 1822 1823 `GET /version` 1824 1825 Show the docker version information 1826 1827 **Example request**: 1828 1829 GET /version HTTP/1.1 1830 1831 **Example response**: 1832 1833 HTTP/1.1 200 OK 1834 Content-Type: application/json 1835 1836 { 1837 "Version": "1.5.0", 1838 "Os": "linux", 1839 "KernelVersion": "3.18.5-tinycore64", 1840 "GoVersion": "go1.4.1", 1841 "GitCommit": "a8a31ef", 1842 "Arch": "amd64", 1843 "ApiVersion": "1.20", 1844 "Experimental": false 1845 } 1846 1847 Status Codes: 1848 1849 - **200** – no error 1850 - **500** – server error 1851 1852 ### Ping the docker server 1853 1854 `GET /_ping` 1855 1856 Ping the docker server 1857 1858 **Example request**: 1859 1860 GET /_ping HTTP/1.1 1861 1862 **Example response**: 1863 1864 HTTP/1.1 200 OK 1865 Content-Type: text/plain 1866 1867 OK 1868 1869 Status Codes: 1870 1871 - **200** - no error 1872 - **500** - server error 1873 1874 ### Create a new image from a container's changes 1875 1876 `POST /commit` 1877 1878 Create a new image from a container's changes 1879 1880 **Example request**: 1881 1882 POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1 1883 Content-Type: application/json 1884 1885 { 1886 "Hostname": "", 1887 "Domainname": "", 1888 "User": "", 1889 "AttachStdin": false, 1890 "AttachStdout": true, 1891 "AttachStderr": true, 1892 "Tty": false, 1893 "OpenStdin": false, 1894 "StdinOnce": false, 1895 "Env": null, 1896 "Cmd": [ 1897 "date" 1898 ], 1899 "Mounts": [ 1900 { 1901 "Source": "/data", 1902 "Destination": "/data", 1903 "Mode": "ro,Z", 1904 "RW": false 1905 } 1906 ], 1907 "Labels": { 1908 "key1": "value1", 1909 "key2": "value2" 1910 }, 1911 "WorkingDir": "", 1912 "NetworkDisabled": false, 1913 "ExposedPorts": { 1914 "22/tcp": {} 1915 } 1916 } 1917 1918 **Example response**: 1919 1920 HTTP/1.1 201 Created 1921 Content-Type: application/json 1922 1923 {"Id": "596069db4bf5"} 1924 1925 Json Parameters: 1926 1927 - **config** - the container's configuration 1928 1929 Query Parameters: 1930 1931 - **container** – source container 1932 - **repo** – repository 1933 - **tag** – tag 1934 - **comment** – commit message 1935 - **author** – author (e.g., "John Hannibal Smith 1936 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 1937 - **pause** – 1/True/true or 0/False/false, whether to pause the container before committing 1938 - **changes** – Dockerfile instructions to apply while committing 1939 1940 Status Codes: 1941 1942 - **201** – no error 1943 - **404** – no such container 1944 - **500** – server error 1945 1946 ### Monitor Docker's events 1947 1948 `GET /events` 1949 1950 Get container events from docker, either in real time via streaming, or via 1951 polling (using since). 1952 1953 Docker containers report the following events: 1954 1955 attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause 1956 1957 and Docker images report: 1958 1959 delete, import, pull, push, tag, untag 1960 1961 **Example request**: 1962 1963 GET /events?since=1374067924 1964 1965 **Example response**: 1966 1967 HTTP/1.1 200 OK 1968 Content-Type: application/json 1969 1970 {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 1971 {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 1972 {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966} 1973 {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970} 1974 1975 Query Parameters: 1976 1977 - **since** – Timestamp used for polling 1978 - **until** – Timestamp used for polling 1979 - **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters: 1980 - `event=<string>`; -- event to filter 1981 - `image=<string>`; -- image to filter 1982 - `container=<string>`; -- container to filter 1983 1984 Status Codes: 1985 1986 - **200** – no error 1987 - **500** – server error 1988 1989 ### Get a tarball containing all images in a repository 1990 1991 `GET /images/(name)/get` 1992 1993 Get a tarball containing all images and metadata for the repository specified 1994 by `name`. 1995 1996 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image 1997 (and its parents) are returned. If `name` is an image ID, similarly only that 1998 image (and its parents) are returned, but with the exclusion of the 1999 'repositories' file in the tarball, as there were no image names referenced. 2000 2001 See the [image tarball format](#image-tarball-format) for more details. 2002 2003 **Example request** 2004 2005 GET /images/ubuntu/get 2006 2007 **Example response**: 2008 2009 HTTP/1.1 200 OK 2010 Content-Type: application/x-tar 2011 2012 Binary data stream 2013 2014 Status Codes: 2015 2016 - **200** – no error 2017 - **500** – server error 2018 2019 ### Get a tarball containing all images. 2020 2021 `GET /images/get` 2022 2023 Get a tarball containing all images and metadata for one or more repositories. 2024 2025 For each value of the `names` parameter: if it is a specific name and tag (e.g. 2026 `ubuntu:latest`), then only that image (and its parents) are returned; if it is 2027 an image ID, similarly only that image (and its parents) are returned and there 2028 would be no names referenced in the 'repositories' file for this image ID. 2029 2030 See the [image tarball format](#image-tarball-format) for more details. 2031 2032 **Example request** 2033 2034 GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox 2035 2036 **Example response**: 2037 2038 HTTP/1.1 200 OK 2039 Content-Type: application/x-tar 2040 2041 Binary data stream 2042 2043 Status Codes: 2044 2045 - **200** – no error 2046 - **500** – server error 2047 2048 ### Load a tarball with a set of images and tags into docker 2049 2050 `POST /images/load` 2051 2052 Load a set of images and tags into a Docker repository. 2053 See the [image tarball format](#image-tarball-format) for more details. 2054 2055 **Example request** 2056 2057 POST /images/load 2058 2059 Tarball in body 2060 2061 **Example response**: 2062 2063 HTTP/1.1 200 OK 2064 2065 Status Codes: 2066 2067 - **200** – no error 2068 - **500** – server error 2069 2070 ### Image tarball format 2071 2072 An image tarball contains one directory per image layer (named using its long ID), 2073 each containing these files: 2074 2075 - `VERSION`: currently `1.0` - the file format version 2076 - `json`: detailed layer information, similar to `docker inspect layer_id` 2077 - `layer.tar`: A tarfile containing the filesystem changes in this layer 2078 2079 The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories 2080 for storing attribute changes and deletions. 2081 2082 If the tarball defines a repository, the tarball should also include a `repositories` file at 2083 the root that contains a list of repository and tag names mapped to layer IDs. 2084 2085 ``` 2086 {"hello-world": 2087 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 2088 } 2089 ``` 2090 2091 ### Exec Create 2092 2093 `POST /containers/(id or name)/exec` 2094 2095 Sets up an exec instance in a running container `id` 2096 2097 **Example request**: 2098 2099 POST /containers/e90e34656806/exec HTTP/1.1 2100 Content-Type: application/json 2101 2102 { 2103 "AttachStdin": false, 2104 "AttachStdout": true, 2105 "AttachStderr": true, 2106 "Tty": false, 2107 "Cmd": [ 2108 "date" 2109 ] 2110 } 2111 2112 **Example response**: 2113 2114 HTTP/1.1 201 Created 2115 Content-Type: application/json 2116 2117 { 2118 "Id": "f90e34656806", 2119 "Warnings":[] 2120 } 2121 2122 Json Parameters: 2123 2124 - **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command. 2125 - **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command. 2126 - **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command. 2127 - **Tty** - Boolean value to allocate a pseudo-TTY. 2128 - **Cmd** - Command to run specified as a string or an array of strings. 2129 2130 2131 Status Codes: 2132 2133 - **201** – no error 2134 - **404** – no such container 2135 2136 ### Exec Start 2137 2138 `POST /exec/(id)/start` 2139 2140 Starts a previously set up `exec` instance `id`. If `detach` is true, this API 2141 returns after starting the `exec` command. Otherwise, this API sets up an 2142 interactive session with the `exec` command. 2143 2144 **Example request**: 2145 2146 POST /exec/e90e34656806/start HTTP/1.1 2147 Content-Type: application/json 2148 2149 { 2150 "Detach": false, 2151 "Tty": false 2152 } 2153 2154 **Example response**: 2155 2156 HTTP/1.1 200 OK 2157 Content-Type: application/vnd.docker.raw-stream 2158 2159 {{ STREAM }} 2160 2161 Json Parameters: 2162 2163 - **Detach** - Detach from the `exec` command. 2164 - **Tty** - Boolean value to allocate a pseudo-TTY. 2165 2166 Status Codes: 2167 2168 - **200** – no error 2169 - **404** – no such exec instance 2170 2171 **Stream details**: 2172 Similar to the stream behavior of `POST /containers/(id or name)/attach` API 2173 2174 ### Exec Resize 2175 2176 `POST /exec/(id)/resize` 2177 2178 Resizes the `tty` session used by the `exec` command `id`. The unit is number of characters. 2179 This API is valid only if `tty` was specified as part of creating and starting the `exec` command. 2180 2181 **Example request**: 2182 2183 POST /exec/e90e34656806/resize?h=40&w=80 HTTP/1.1 2184 Content-Type: text/plain 2185 2186 **Example response**: 2187 2188 HTTP/1.1 201 Created 2189 Content-Type: text/plain 2190 2191 Query Parameters: 2192 2193 - **h** – height of `tty` session 2194 - **w** – width 2195 2196 Status Codes: 2197 2198 - **201** – no error 2199 - **404** – no such exec instance 2200 2201 ### Exec Inspect 2202 2203 `GET /exec/(id)/json` 2204 2205 Return low-level information about the `exec` command `id`. 2206 2207 **Example request**: 2208 2209 GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1 2210 2211 **Example response**: 2212 2213 HTTP/1.1 200 OK 2214 Content-Type: plain/text 2215 2216 { 2217 "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39", 2218 "Running" : false, 2219 "ExitCode" : 2, 2220 "ProcessConfig" : { 2221 "privileged" : false, 2222 "user" : "", 2223 "tty" : false, 2224 "entrypoint" : "sh", 2225 "arguments" : [ 2226 "-c", 2227 "exit 2" 2228 ] 2229 }, 2230 "OpenStdin" : false, 2231 "OpenStderr" : false, 2232 "OpenStdout" : false, 2233 "Container" : { 2234 "State" : { 2235 "Running" : true, 2236 "Paused" : false, 2237 "Restarting" : false, 2238 "OOMKilled" : false, 2239 "Pid" : 3650, 2240 "ExitCode" : 0, 2241 "Error" : "", 2242 "StartedAt" : "2014-11-17T22:26:03.717657531Z", 2243 "FinishedAt" : "0001-01-01T00:00:00Z" 2244 }, 2245 "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c", 2246 "Created" : "2014-11-17T22:26:03.626304998Z", 2247 "Path" : "date", 2248 "Args" : [], 2249 "Config" : { 2250 "Hostname" : "8f177a186b97", 2251 "Domainname" : "", 2252 "User" : "", 2253 "AttachStdin" : false, 2254 "AttachStdout" : false, 2255 "AttachStderr" : false, 2256 "ExposedPorts" : null, 2257 "Tty" : false, 2258 "OpenStdin" : false, 2259 "StdinOnce" : false, 2260 "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], 2261 "Cmd" : [ 2262 "date" 2263 ], 2264 "Image" : "ubuntu", 2265 "Volumes" : null, 2266 "WorkingDir" : "", 2267 "Entrypoint" : null, 2268 "NetworkDisabled" : false, 2269 "MacAddress" : "", 2270 "OnBuild" : null, 2271 "SecurityOpt" : null 2272 }, 2273 "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5", 2274 "NetworkSettings" : { 2275 "IPAddress" : "172.17.0.2", 2276 "IPPrefixLen" : 16, 2277 "MacAddress" : "02:42:ac:11:00:02", 2278 "Gateway" : "172.17.42.1", 2279 "Bridge" : "docker0", 2280 "PortMapping" : null, 2281 "Ports" : {} 2282 }, 2283 "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf", 2284 "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname", 2285 "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts", 2286 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log", 2287 "Name" : "/test", 2288 "Driver" : "aufs", 2289 "ExecDriver" : "native-0.2", 2290 "MountLabel" : "", 2291 "ProcessLabel" : "", 2292 "AppArmorProfile" : "", 2293 "RestartCount" : 0, 2294 "Mounts" : [] 2295 } 2296 } 2297 2298 Status Codes: 2299 2300 - **200** – no error 2301 - **404** – no such exec instance 2302 - **500** - server error 2303 2304 # 3. Going further 2305 2306 ## 3.1 Inside `docker run` 2307 2308 As an example, the `docker run` command line makes the following API calls: 2309 2310 - Create the container 2311 2312 - If the status code is 404, it means the image doesn't exist: 2313 - Try to pull it. 2314 - Then, retry to create the container. 2315 2316 - Start the container. 2317 2318 - If you are not in detached mode: 2319 - Attach to the container, using `logs=1` (to have `stdout` and 2320 `stderr` from the container's start) and `stream=1` 2321 2322 - If in detached mode or only `stdin` is attached, display the container's id. 2323 2324 ## 3.2 Hijacking 2325 2326 In this version of the API, `/attach`, uses hijacking to transport `stdin`, 2327 `stdout`, and `stderr` on the same socket. 2328 2329 To hint potential proxies about connection hijacking, Docker client sends 2330 connection upgrade headers similarly to websocket. 2331 2332 Upgrade: tcp 2333 Connection: Upgrade 2334 2335 When Docker daemon detects the `Upgrade` header, it switches its status code 2336 from **200 OK** to **101 UPGRADED** and resends the same headers. 2337 2338 2339 ## 3.3 CORS Requests 2340 2341 To set cross origin requests to the remote api please give values to 2342 `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, 2343 default or blank means CORS disabled 2344 2345 $ docker daemon -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"