github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/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](../../quickstart.md#bind-docker-to-another-host-port-or-a-unix-socket). 19 - The API tends to be REST. However, for some complex commands, like `attach` 20 or `pull`, the HTTP connection is hijacked to transport `stdout`, 21 `stdin` and `stderr`. 22 - When the client API version is newer than the daemon's, these calls return an HTTP 23 `400 Bad Request` error message. 24 25 # 2. Endpoints 26 27 ## 2.1 Containers 28 29 ### List containers 30 31 `GET /containers/json` 32 33 List containers 34 35 **Example request**: 36 37 GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1 38 39 **Example response**: 40 41 HTTP/1.1 200 OK 42 Content-Type: application/json 43 44 [ 45 { 46 "Id": "8dfafdbc3a40", 47 "Names":["/boring_feynman"], 48 "Image": "ubuntu:latest", 49 "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 - **Memory** - Memory limit in bytes. 219 - **MemorySwap** - Total memory limit (memory + swap); set `-1` to enable unlimited swap. 220 You must use this with `memory` and make the swap value larger than `memory`. 221 - **CpuShares** - An integer value containing the container's CPU Shares 222 (ie. the relative weight vs other containers). 223 - **CpuPeriod** - The length of a CPU period in microseconds. 224 - **CpuQuota** - Microseconds of CPU time that the container can get in a CPU period. 225 - **Cpuset** - Deprecated please don't use. Use `CpusetCpus` instead. 226 - **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use. 227 - **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. 228 - **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000. 229 - **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100. 230 - **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not. 231 - **AttachStdin** - Boolean value, attaches to `stdin`. 232 - **AttachStdout** - Boolean value, attaches to `stdout`. 233 - **AttachStderr** - Boolean value, attaches to `stderr`. 234 - **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed. 235 - **OpenStdin** - Boolean value, opens stdin, 236 - **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects. 237 - **Env** - A list of environment variables in the form of `["VAR=value"[,"VAR2=value2"]]` 238 - **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}` 239 - **Cmd** - Command to run specified as a string or an array of strings. 240 - **Entrypoint** - Set the entry point for the container as a string or an array 241 of strings. 242 - **Image** - A string specifying the image name to use for the container. 243 - **Volumes** - An object mapping mount point paths (strings) inside the 244 container to empty objects. 245 - **WorkingDir** - A string specifying the working directory for commands to 246 run in. 247 - **NetworkDisabled** - Boolean value, when true disables networking for the 248 container 249 - **ExposedPorts** - An object mapping ports to an empty object in the form of: 250 `"ExposedPorts": { "<port>/<tcp|udp>: {}" }` 251 - **HostConfig** 252 - **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms: 253 + `container_path` to create a new volume for the container 254 + `host_path:container_path` to bind-mount a host path into the container 255 + `host_path:container_path:ro` to make the bind-mount read-only inside the container. 256 - **Links** - A list of links for the container. Each link entry should be 257 in the form of `container_name:alias`. 258 - **LxcConf** - LXC specific configurations. These configurations only 259 work when using the `lxc` execution driver. 260 - **PortBindings** - A map of exposed container ports and the host port they 261 should map to. A JSON object in the form 262 `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }` 263 Take note that `port` is specified as a string and not an integer value. 264 - **PublishAllPorts** - Allocates a random host port for all of a container's 265 exposed ports. Specified as a boolean value. 266 - **Privileged** - Gives the container full access to the host. Specified as 267 a boolean value. 268 - **ReadonlyRootfs** - Mount the container's root filesystem as read only. 269 Specified as a boolean value. 270 - **Dns** - A list of DNS servers for the container to use. 271 - **DnsSearch** - A list of DNS search domains 272 - **ExtraHosts** - A list of hostnames/IP mappings to add to the 273 container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`. 274 - **VolumesFrom** - A list of volumes to inherit from another container. 275 Specified in the form `<container name>[:<ro|rw>]` 276 - **CapAdd** - A list of kernel capabilities to add to the container. 277 - **Capdrop** - A list of kernel capabilities to drop from the container. 278 - **GroupAdd** - A list of additional groups that the container process will run as 279 - **RestartPolicy** – The behavior to apply when the container exits. The 280 value is an object with a `Name` property of either `"always"` to 281 always restart or `"on-failure"` to restart only when the container 282 exit code is non-zero. If `on-failure` is used, `MaximumRetryCount` 283 controls the number of times to retry before giving up. 284 The default is not to restart. (optional) 285 An ever increasing delay (double the previous delay, starting at 100mS) 286 is added before each restart to prevent flooding the server. 287 - **NetworkMode** - Sets the networking mode for the container. Supported 288 values are: `bridge`, `host`, `none`, and `container:<name|id>` 289 - **Devices** - A list of devices to add to the container specified as a JSON object in the 290 form 291 `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}` 292 - **Ulimits** - A list of ulimits to set in the container, specified as 293 `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example: 294 `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }` 295 - **SecurityOpt**: A list of string values to customize labels for MLS 296 systems, such as SELinux. 297 - **LogConfig** - Log configuration for the container, specified as a JSON object in the form 298 `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`. 299 Available types: `json-file`, `syslog`, `journald`, `gelf`, `none`. 300 `json-file` logging driver. 301 - **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. 302 303 Query Parameters: 304 305 - **name** – Assign the specified name to the container. Must 306 match `/?[a-zA-Z0-9_-]+`. 307 308 Status Codes: 309 310 - **201** – no error 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 an 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 - **registry** – The registry to pull from. 1447 1448 Request Headers: 1449 1450 - **X-Registry-Auth** – base64-encoded AuthConfig object 1451 1452 Status Codes: 1453 1454 - **200** – no error 1455 - **500** – server error 1456 1457 1458 1459 ### Inspect an image 1460 1461 `GET /images/(name)/json` 1462 1463 Return low-level information on the image `name` 1464 1465 **Example request**: 1466 1467 GET /images/ubuntu/json HTTP/1.1 1468 1469 **Example response**: 1470 1471 HTTP/1.1 200 OK 1472 Content-Type: application/json 1473 1474 { 1475 "Created": "2013-03-23T22:24:18.818426-07:00", 1476 "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0", 1477 "ContainerConfig": 1478 { 1479 "Hostname": "", 1480 "User": "", 1481 "AttachStdin": false, 1482 "AttachStdout": false, 1483 "AttachStderr": false, 1484 "Tty": true, 1485 "OpenStdin": true, 1486 "StdinOnce": false, 1487 "Env": null, 1488 "Cmd": ["/bin/bash"], 1489 "Dns": null, 1490 "Image": "ubuntu", 1491 "Labels": { 1492 "com.example.vendor": "Acme", 1493 "com.example.license": "GPL", 1494 "com.example.version": "1.0" 1495 }, 1496 "Volumes": null, 1497 "VolumesFrom": "", 1498 "WorkingDir": "" 1499 }, 1500 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1501 "Parent": "27cf784147099545", 1502 "Size": 6824592 1503 } 1504 1505 Status Codes: 1506 1507 - **200** – no error 1508 - **404** – no such image 1509 - **500** – server error 1510 1511 ### Get the history of an image 1512 1513 `GET /images/(name)/history` 1514 1515 Return the history of the image `name` 1516 1517 **Example request**: 1518 1519 GET /images/ubuntu/history HTTP/1.1 1520 1521 **Example response**: 1522 1523 HTTP/1.1 200 OK 1524 Content-Type: application/json 1525 1526 [ 1527 { 1528 "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710", 1529 "Created": 1398108230, 1530 "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /", 1531 "Tags": [ 1532 "ubuntu:lucid", 1533 "ubuntu:10.04" 1534 ], 1535 "Size": 182964289, 1536 "Comment": "" 1537 }, 1538 { 1539 "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8", 1540 "Created": 1398108222, 1541 "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/", 1542 "Tags": null, 1543 "Size": 0, 1544 "Comment": "" 1545 }, 1546 { 1547 "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158", 1548 "Created": 1371157430, 1549 "CreatedBy": "", 1550 "Tags": [ 1551 "scratch12:latest", 1552 "scratch:latest" 1553 ], 1554 "Size": 0, 1555 "Comment": "Imported from -" 1556 } 1557 ] 1558 1559 Status Codes: 1560 1561 - **200** – no error 1562 - **404** – no such image 1563 - **500** – server error 1564 1565 ### Push an image on the registry 1566 1567 `POST /images/(name)/push` 1568 1569 Push the image `name` on the registry 1570 1571 **Example request**: 1572 1573 POST /images/test/push HTTP/1.1 1574 1575 **Example response**: 1576 1577 HTTP/1.1 200 OK 1578 Content-Type: application/json 1579 1580 {"status": "Pushing..."} 1581 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 1582 {"error": "Invalid..."} 1583 ... 1584 1585 If you wish to push an image on to a private registry, that image must already have a tag 1586 into a repository which references that registry `hostname` and `port`. This repository name should 1587 then be used in the URL. This duplicates the command line's flow. 1588 1589 **Example request**: 1590 1591 POST /images/registry.acme.com:5000/test/push HTTP/1.1 1592 1593 1594 Query Parameters: 1595 1596 - **tag** – The tag to associate with the image on the registry. This is optional. 1597 1598 Request Headers: 1599 1600 - **X-Registry-Auth** – Include a base64-encoded AuthConfig. 1601 object. 1602 1603 Status Codes: 1604 1605 - **200** – no error 1606 - **404** – no such image 1607 - **500** – server error 1608 1609 ### Tag an image into a repository 1610 1611 `POST /images/(name)/tag` 1612 1613 Tag the image `name` into a repository 1614 1615 **Example request**: 1616 1617 POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1 1618 1619 **Example response**: 1620 1621 HTTP/1.1 201 Created 1622 1623 Query Parameters: 1624 1625 - **repo** – The repository to tag in 1626 - **force** – 1/True/true or 0/False/false, default false 1627 - **tag** - The new tag name 1628 1629 Status Codes: 1630 1631 - **201** – no error 1632 - **400** – bad parameter 1633 - **404** – no such image 1634 - **409** – conflict 1635 - **500** – server error 1636 1637 ### Remove an image 1638 1639 `DELETE /images/(name)` 1640 1641 Remove the image `name` from the filesystem 1642 1643 **Example request**: 1644 1645 DELETE /images/test HTTP/1.1 1646 1647 **Example response**: 1648 1649 HTTP/1.1 200 OK 1650 Content-type: application/json 1651 1652 [ 1653 {"Untagged": "3e2f21a89f"}, 1654 {"Deleted": "3e2f21a89f"}, 1655 {"Deleted": "53b4f83ac9"} 1656 ] 1657 1658 Query Parameters: 1659 1660 - **force** – 1/True/true or 0/False/false, default false 1661 - **noprune** – 1/True/true or 0/False/false, default false 1662 1663 Status Codes: 1664 1665 - **200** – no error 1666 - **404** – no such image 1667 - **409** – conflict 1668 - **500** – server error 1669 1670 ### Search images 1671 1672 `GET /images/search` 1673 1674 Search for an image on [Docker Hub](https://hub.docker.com). 1675 1676 > **Note**: 1677 > The response keys have changed from API v1.6 to reflect the JSON 1678 > sent by the registry server to the docker daemon's request. 1679 1680 **Example request**: 1681 1682 GET /images/search?term=sshd HTTP/1.1 1683 1684 **Example response**: 1685 1686 HTTP/1.1 200 OK 1687 Content-Type: application/json 1688 1689 [ 1690 { 1691 "description": "", 1692 "is_official": false, 1693 "is_automated": false, 1694 "name": "wma55/u1210sshd", 1695 "star_count": 0 1696 }, 1697 { 1698 "description": "", 1699 "is_official": false, 1700 "is_automated": false, 1701 "name": "jdswinbank/sshd", 1702 "star_count": 0 1703 }, 1704 { 1705 "description": "", 1706 "is_official": false, 1707 "is_automated": false, 1708 "name": "vgauthier/sshd", 1709 "star_count": 0 1710 } 1711 ... 1712 ] 1713 1714 Query Parameters: 1715 1716 - **term** – term to search 1717 1718 Status Codes: 1719 1720 - **200** – no error 1721 - **500** – server error 1722 1723 ## 2.3 Misc 1724 1725 ### Check auth configuration 1726 1727 `POST /auth` 1728 1729 Get the default username and email 1730 1731 **Example request**: 1732 1733 POST /auth HTTP/1.1 1734 Content-Type: application/json 1735 1736 { 1737 "username":" hannibal", 1738 "password: "xxxx", 1739 "email": "hannibal@a-team.com", 1740 "serveraddress": "https://index.docker.io/v1/" 1741 } 1742 1743 **Example response**: 1744 1745 HTTP/1.1 200 OK 1746 1747 Status Codes: 1748 1749 - **200** – no error 1750 - **204** – no error 1751 - **500** – server error 1752 1753 ### Display system-wide information 1754 1755 `GET /info` 1756 1757 Display system-wide information 1758 1759 **Example request**: 1760 1761 GET /info HTTP/1.1 1762 1763 **Example response**: 1764 1765 HTTP/1.1 200 OK 1766 Content-Type: application/json 1767 1768 { 1769 "Containers": 11, 1770 "CpuCfsPeriod": true, 1771 "CpuCfsQuota": true, 1772 "Debug": false, 1773 "DockerRootDir": "/var/lib/docker", 1774 "Driver": "btrfs", 1775 "DriverStatus": [[""]], 1776 "ExecutionDriver": "native-0.1", 1777 "ExperimentalBuild": false, 1778 "HttpProxy": "http://test:test@localhost:8080", 1779 "HttpsProxy": "https://test:test@localhost:8080", 1780 "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS", 1781 "IPv4Forwarding": true, 1782 "Images": 16, 1783 "IndexServerAddress": "https://index.docker.io/v1/", 1784 "InitPath": "/usr/bin/docker", 1785 "InitSha1": "", 1786 "KernelVersion": "3.12.0-1-amd64", 1787 "Labels": [ 1788 "storage=ssd" 1789 ], 1790 "MemTotal": 2099236864, 1791 "MemoryLimit": true, 1792 "NCPU": 1, 1793 "NEventsListener": 0, 1794 "NFd": 11, 1795 "NGoroutines": 21, 1796 "Name": "prod-server-42", 1797 "NoProxy": "9.81.1.160", 1798 "OomKillDisable": true, 1799 "OperatingSystem": "Boot2Docker", 1800 "RegistryConfig": { 1801 "IndexConfigs": { 1802 "docker.io": { 1803 "Mirrors": null, 1804 "Name": "docker.io", 1805 "Official": true, 1806 "Secure": true 1807 } 1808 }, 1809 "InsecureRegistryCIDRs": [ 1810 "127.0.0.0/8" 1811 ] 1812 }, 1813 "SwapLimit": false, 1814 "SystemTime": "2015-03-10T11:11:23.730591467-07:00" 1815 } 1816 1817 Status Codes: 1818 1819 - **200** – no error 1820 - **500** – server error 1821 1822 ### Show the docker version information 1823 1824 `GET /version` 1825 1826 Show the docker version information 1827 1828 **Example request**: 1829 1830 GET /version HTTP/1.1 1831 1832 **Example response**: 1833 1834 HTTP/1.1 200 OK 1835 Content-Type: application/json 1836 1837 { 1838 "Version": "1.5.0", 1839 "Os": "linux", 1840 "KernelVersion": "3.18.5-tinycore64", 1841 "GoVersion": "go1.4.1", 1842 "GitCommit": "a8a31ef", 1843 "Arch": "amd64", 1844 "ApiVersion": "1.20", 1845 "Experimental": false 1846 } 1847 1848 Status Codes: 1849 1850 - **200** – no error 1851 - **500** – server error 1852 1853 ### Ping the docker server 1854 1855 `GET /_ping` 1856 1857 Ping the docker server 1858 1859 **Example request**: 1860 1861 GET /_ping HTTP/1.1 1862 1863 **Example response**: 1864 1865 HTTP/1.1 200 OK 1866 Content-Type: text/plain 1867 1868 OK 1869 1870 Status Codes: 1871 1872 - **200** - no error 1873 - **500** - server error 1874 1875 ### Create a new image from a container's changes 1876 1877 `POST /commit` 1878 1879 Create a new image from a container's changes 1880 1881 **Example request**: 1882 1883 POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1 1884 Content-Type: application/json 1885 1886 { 1887 "Hostname": "", 1888 "Domainname": "", 1889 "User": "", 1890 "AttachStdin": false, 1891 "AttachStdout": true, 1892 "AttachStderr": true, 1893 "Tty": false, 1894 "OpenStdin": false, 1895 "StdinOnce": false, 1896 "Env": null, 1897 "Cmd": [ 1898 "date" 1899 ], 1900 "Mounts": [ 1901 { 1902 "Source": "/data", 1903 "Destination": "/data", 1904 "Mode": "ro,Z", 1905 "RW": false 1906 } 1907 ], 1908 "Labels": { 1909 "key1": "value1", 1910 "key2": "value2" 1911 }, 1912 "WorkingDir": "", 1913 "NetworkDisabled": false, 1914 "ExposedPorts": { 1915 "22/tcp": {} 1916 } 1917 } 1918 1919 **Example response**: 1920 1921 HTTP/1.1 201 Created 1922 Content-Type: application/json 1923 1924 {"Id": "596069db4bf5"} 1925 1926 Json Parameters: 1927 1928 - **config** - the container's configuration 1929 1930 Query Parameters: 1931 1932 - **container** – source container 1933 - **repo** – repository 1934 - **tag** – tag 1935 - **comment** – commit message 1936 - **author** – author (e.g., "John Hannibal Smith 1937 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 1938 - **pause** – 1/True/true or 0/False/false, whether to pause the container before committing 1939 - **changes** – Dockerfile instructions to apply while committing 1940 1941 Status Codes: 1942 1943 - **201** – no error 1944 - **404** – no such container 1945 - **500** – server error 1946 1947 ### Monitor Docker's events 1948 1949 `GET /events` 1950 1951 Get container events from docker, either in real time via streaming, or via 1952 polling (using since). 1953 1954 Docker containers report the following events: 1955 1956 attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause 1957 1958 and Docker images report: 1959 1960 delete, import, pull, push, tag, untag 1961 1962 **Example request**: 1963 1964 GET /events?since=1374067924 1965 1966 **Example response**: 1967 1968 HTTP/1.1 200 OK 1969 Content-Type: application/json 1970 1971 {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 1972 {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 1973 {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966} 1974 {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970} 1975 1976 Query Parameters: 1977 1978 - **since** – Timestamp used for polling 1979 - **until** – Timestamp used for polling 1980 - **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters: 1981 - `event=<string>`; -- event to filter 1982 - `image=<string>`; -- image to filter 1983 - `container=<string>`; -- container to filter 1984 1985 Status Codes: 1986 1987 - **200** – no error 1988 - **500** – server error 1989 1990 ### Get a tarball containing all images in a repository 1991 1992 `GET /images/(name)/get` 1993 1994 Get a tarball containing all images and metadata for the repository specified 1995 by `name`. 1996 1997 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image 1998 (and its parents) are returned. If `name` is an image ID, similarly only that 1999 image (and its parents) are returned, but with the exclusion of the 2000 'repositories' file in the tarball, as there were no image names referenced. 2001 2002 See the [image tarball format](#image-tarball-format) for more details. 2003 2004 **Example request** 2005 2006 GET /images/ubuntu/get 2007 2008 **Example response**: 2009 2010 HTTP/1.1 200 OK 2011 Content-Type: application/x-tar 2012 2013 Binary data stream 2014 2015 Status Codes: 2016 2017 - **200** – no error 2018 - **500** – server error 2019 2020 ### Get a tarball containing all images. 2021 2022 `GET /images/get` 2023 2024 Get a tarball containing all images and metadata for one or more repositories. 2025 2026 For each value of the `names` parameter: if it is a specific name and tag (e.g. 2027 `ubuntu:latest`), then only that image (and its parents) are returned; if it is 2028 an image ID, similarly only that image (and its parents) are returned and there 2029 would be no names referenced in the 'repositories' file for this image ID. 2030 2031 See the [image tarball format](#image-tarball-format) for more details. 2032 2033 **Example request** 2034 2035 GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox 2036 2037 **Example response**: 2038 2039 HTTP/1.1 200 OK 2040 Content-Type: application/x-tar 2041 2042 Binary data stream 2043 2044 Status Codes: 2045 2046 - **200** – no error 2047 - **500** – server error 2048 2049 ### Load a tarball with a set of images and tags into docker 2050 2051 `POST /images/load` 2052 2053 Load a set of images and tags into a Docker repository. 2054 See the [image tarball format](#image-tarball-format) for more details. 2055 2056 **Example request** 2057 2058 POST /images/load 2059 2060 Tarball in body 2061 2062 **Example response**: 2063 2064 HTTP/1.1 200 OK 2065 2066 Status Codes: 2067 2068 - **200** – no error 2069 - **500** – server error 2070 2071 ### Image tarball format 2072 2073 An image tarball contains one directory per image layer (named using its long ID), 2074 each containing these files: 2075 2076 - `VERSION`: currently `1.0` - the file format version 2077 - `json`: detailed layer information, similar to `docker inspect layer_id` 2078 - `layer.tar`: A tarfile containing the filesystem changes in this layer 2079 2080 The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories 2081 for storing attribute changes and deletions. 2082 2083 If the tarball defines a repository, the tarball should also include a `repositories` file at 2084 the root that contains a list of repository and tag names mapped to layer IDs. 2085 2086 ``` 2087 {"hello-world": 2088 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 2089 } 2090 ``` 2091 2092 ### Exec Create 2093 2094 `POST /containers/(id or name)/exec` 2095 2096 Sets up an exec instance in a running container `id` 2097 2098 **Example request**: 2099 2100 POST /containers/e90e34656806/exec HTTP/1.1 2101 Content-Type: application/json 2102 2103 { 2104 "AttachStdin": false, 2105 "AttachStdout": true, 2106 "AttachStderr": true, 2107 "Tty": false, 2108 "Cmd": [ 2109 "date" 2110 ] 2111 } 2112 2113 **Example response**: 2114 2115 HTTP/1.1 201 Created 2116 Content-Type: application/json 2117 2118 { 2119 "Id": "f90e34656806", 2120 "Warnings":[] 2121 } 2122 2123 Json Parameters: 2124 2125 - **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command. 2126 - **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command. 2127 - **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command. 2128 - **Tty** - Boolean value to allocate a pseudo-TTY. 2129 - **Cmd** - Command to run specified as a string or an array of strings. 2130 2131 2132 Status Codes: 2133 2134 - **201** – no error 2135 - **404** – no such container 2136 2137 ### Exec Start 2138 2139 `POST /exec/(id)/start` 2140 2141 Starts a previously set up `exec` instance `id`. If `detach` is true, this API 2142 returns after starting the `exec` command. Otherwise, this API sets up an 2143 interactive session with the `exec` command. 2144 2145 **Example request**: 2146 2147 POST /exec/e90e34656806/start HTTP/1.1 2148 Content-Type: application/json 2149 2150 { 2151 "Detach": false, 2152 "Tty": false 2153 } 2154 2155 **Example response**: 2156 2157 HTTP/1.1 200 OK 2158 Content-Type: application/vnd.docker.raw-stream 2159 2160 {{ STREAM }} 2161 2162 Json Parameters: 2163 2164 - **Detach** - Detach from the `exec` command. 2165 - **Tty** - Boolean value to allocate a pseudo-TTY. 2166 2167 Status Codes: 2168 2169 - **200** – no error 2170 - **404** – no such exec instance 2171 2172 **Stream details**: 2173 Similar to the stream behavior of `POST /containers/(id or name)/attach` API 2174 2175 ### Exec Resize 2176 2177 `POST /exec/(id)/resize` 2178 2179 Resizes the `tty` session used by the `exec` command `id`. The unit is number of characters. 2180 This API is valid only if `tty` was specified as part of creating and starting the `exec` command. 2181 2182 **Example request**: 2183 2184 POST /exec/e90e34656806/resize?h=40&w=80 HTTP/1.1 2185 Content-Type: text/plain 2186 2187 **Example response**: 2188 2189 HTTP/1.1 201 Created 2190 Content-Type: text/plain 2191 2192 Query Parameters: 2193 2194 - **h** – height of `tty` session 2195 - **w** – width 2196 2197 Status Codes: 2198 2199 - **201** – no error 2200 - **404** – no such exec instance 2201 2202 ### Exec Inspect 2203 2204 `GET /exec/(id)/json` 2205 2206 Return low-level information about the `exec` command `id`. 2207 2208 **Example request**: 2209 2210 GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1 2211 2212 **Example response**: 2213 2214 HTTP/1.1 200 OK 2215 Content-Type: plain/text 2216 2217 { 2218 "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39", 2219 "Running" : false, 2220 "ExitCode" : 2, 2221 "ProcessConfig" : { 2222 "privileged" : false, 2223 "user" : "", 2224 "tty" : false, 2225 "entrypoint" : "sh", 2226 "arguments" : [ 2227 "-c", 2228 "exit 2" 2229 ] 2230 }, 2231 "OpenStdin" : false, 2232 "OpenStderr" : false, 2233 "OpenStdout" : false, 2234 "Container" : { 2235 "State" : { 2236 "Running" : true, 2237 "Paused" : false, 2238 "Restarting" : false, 2239 "OOMKilled" : false, 2240 "Pid" : 3650, 2241 "ExitCode" : 0, 2242 "Error" : "", 2243 "StartedAt" : "2014-11-17T22:26:03.717657531Z", 2244 "FinishedAt" : "0001-01-01T00:00:00Z" 2245 }, 2246 "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c", 2247 "Created" : "2014-11-17T22:26:03.626304998Z", 2248 "Path" : "date", 2249 "Args" : [], 2250 "Config" : { 2251 "Hostname" : "8f177a186b97", 2252 "Domainname" : "", 2253 "User" : "", 2254 "AttachStdin" : false, 2255 "AttachStdout" : false, 2256 "AttachStderr" : false, 2257 "ExposedPorts" : null, 2258 "Tty" : false, 2259 "OpenStdin" : false, 2260 "StdinOnce" : false, 2261 "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], 2262 "Cmd" : [ 2263 "date" 2264 ], 2265 "Image" : "ubuntu", 2266 "Volumes" : null, 2267 "WorkingDir" : "", 2268 "Entrypoint" : null, 2269 "NetworkDisabled" : false, 2270 "MacAddress" : "", 2271 "OnBuild" : null, 2272 "SecurityOpt" : null 2273 }, 2274 "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5", 2275 "NetworkSettings" : { 2276 "IPAddress" : "172.17.0.2", 2277 "IPPrefixLen" : 16, 2278 "MacAddress" : "02:42:ac:11:00:02", 2279 "Gateway" : "172.17.42.1", 2280 "Bridge" : "docker0", 2281 "PortMapping" : null, 2282 "Ports" : {} 2283 }, 2284 "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf", 2285 "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname", 2286 "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts", 2287 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log", 2288 "Name" : "/test", 2289 "Driver" : "aufs", 2290 "ExecDriver" : "native-0.2", 2291 "MountLabel" : "", 2292 "ProcessLabel" : "", 2293 "AppArmorProfile" : "", 2294 "RestartCount" : 0, 2295 "Mounts" : [] 2296 } 2297 } 2298 2299 Status Codes: 2300 2301 - **200** – no error 2302 - **404** – no such exec instance 2303 - **500** - server error 2304 2305 # 3. Going further 2306 2307 ## 3.1 Inside `docker run` 2308 2309 As an example, the `docker run` command line makes the following API calls: 2310 2311 - Create the container 2312 2313 - If the status code is 404, it means the image doesn't exist: 2314 - Try to pull it. 2315 - Then, retry to create the container. 2316 2317 - Start the container. 2318 2319 - If you are not in detached mode: 2320 - Attach to the container, using `logs=1` (to have `stdout` and 2321 `stderr` from the container's start) and `stream=1` 2322 2323 - If in detached mode or only `stdin` is attached, display the container's id. 2324 2325 ## 3.2 Hijacking 2326 2327 In this version of the API, `/attach`, uses hijacking to transport `stdin`, 2328 `stdout`, and `stderr` on the same socket. 2329 2330 To hint potential proxies about connection hijacking, Docker client sends 2331 connection upgrade headers similarly to websocket. 2332 2333 Upgrade: tcp 2334 Connection: Upgrade 2335 2336 When Docker daemon detects the `Upgrade` header, it switches its status code 2337 from **200 OK** to **101 UPGRADED** and resends the same headers. 2338 2339 2340 ## 3.3 CORS Requests 2341 2342 To set cross origin requests to the remote api please give values to 2343 `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, 2344 default or blank means CORS disabled 2345 2346 $ docker daemon -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"