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