github.com/sbward/docker@v1.4.2-0.20150114010528-c9dab702bed3/docs/sources/reference/api/docker_remote_api_v1.17.md (about) 1 page_title: Remote API v1.17 2 page_description: API Documentation for Docker 3 page_keywords: API, Docker, rcli, REST, documentation 4 5 # Docker Remote API v1.17 6 7 ## 1. Brief introduction 8 9 - The Remote API has replaced `rcli`. 10 - The daemon listens on `unix:///var/run/docker.sock` but you can 11 [Bind Docker to another host/port or a Unix socket]( 12 /articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket). 13 - The API tends to be REST, but for some complex commands, like `attach` 14 or `pull`, the HTTP connection is hijacked to transport `STDOUT`, 15 `STDIN` and `STDERR`. 16 17 # 2. Endpoints 18 19 ## 2.1 Containers 20 21 ### List containers 22 23 `GET /containers/json` 24 25 List containers 26 27 **Example request**: 28 29 GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1 30 31 **Example response**: 32 33 HTTP/1.1 200 OK 34 Content-Type: application/json 35 36 [ 37 { 38 "Id": "8dfafdbc3a40", 39 "Image": "base:latest", 40 "Command": "echo 1", 41 "Created": 1367854155, 42 "Status": "Exit 0", 43 "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}], 44 "SizeRw": 12288, 45 "SizeRootFs": 0 46 }, 47 { 48 "Id": "9cd87474be90", 49 "Image": "base:latest", 50 "Command": "echo 222222", 51 "Created": 1367854155, 52 "Status": "Exit 0", 53 "Ports": [], 54 "SizeRw": 12288, 55 "SizeRootFs": 0 56 }, 57 { 58 "Id": "3176a2479c92", 59 "Image": "base:latest", 60 "Command": "echo 3333333333333333", 61 "Created": 1367854154, 62 "Status": "Exit 0", 63 "Ports":[], 64 "SizeRw":12288, 65 "SizeRootFs":0 66 }, 67 { 68 "Id": "4cb07b47f9fb", 69 "Image": "base:latest", 70 "Command": "echo 444444444444444444444444444444444", 71 "Created": 1367854152, 72 "Status": "Exit 0", 73 "Ports": [], 74 "SizeRw": 12288, 75 "SizeRootFs": 0 76 } 77 ] 78 79 Query Parameters: 80 81 - **all** – 1/True/true or 0/False/false, Show all containers. 82 Only running containers are shown by default (i.e., this defaults to false) 83 - **limit** – Show `limit` last created 84 containers, include non-running ones. 85 - **since** – Show only containers created since Id, include 86 non-running ones. 87 - **before** – Show only containers created before Id, include 88 non-running ones. 89 - **size** – 1/True/true or 0/False/false, Show the containers 90 sizes 91 - **filters** - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters: 92 - exited=<int> -- containers with exit code of <int> 93 - status=(restarting|running|paused|exited) 94 95 Status Codes: 96 97 - **200** – no error 98 - **400** – bad parameter 99 - **500** – server error 100 101 ### Create a container 102 103 `POST /containers/create` 104 105 Create a container 106 107 **Example request**: 108 109 POST /containers/create HTTP/1.1 110 Content-Type: application/json 111 112 { 113 "Hostname": "", 114 "Domainname": "", 115 "User": "", 116 "Memory": 0, 117 "MemorySwap": 0, 118 "CpuShares": 512, 119 "Cpuset": "0,1", 120 "AttachStdin": false, 121 "AttachStdout": true, 122 "AttachStderr": true, 123 "Tty": false, 124 "OpenStdin": false, 125 "StdinOnce": false, 126 "Env": null, 127 "Cmd": [ 128 "date" 129 ], 130 "Entrypoint": "", 131 "Image": "base", 132 "Volumes": { 133 "/tmp": {} 134 }, 135 "WorkingDir": "", 136 "NetworkDisabled": false, 137 "MacAddress": "12:34:56:78:9a:bc", 138 "ExposedPorts": { 139 "22/tcp": {} 140 }, 141 "SecurityOpts": [""], 142 "HostConfig": { 143 "Binds": ["/tmp:/tmp"], 144 "Links": ["redis3:redis"], 145 "LxcConf": {"lxc.utsname":"docker"}, 146 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] }, 147 "PublishAllPorts": false, 148 "Privileged": false, 149 "Dns": ["8.8.8.8"], 150 "DnsSearch": [""], 151 "VolumesFrom": ["parent", "other:ro"], 152 "CapAdd": ["NET_ADMIN"], 153 "CapDrop": ["MKNOD"], 154 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 }, 155 "NetworkMode": "bridge", 156 "Devices": [] 157 } 158 } 159 160 **Example response**: 161 162 HTTP/1.1 201 Created 163 Content-Type: application/json 164 165 { 166 "Id":"e90e34656806" 167 "Warnings":[] 168 } 169 170 Json Parameters: 171 172 - **Hostname** - A string value containing the desired hostname to use for the 173 container. 174 - **Domainname** - A string value containing the desired domain name to use 175 for the container. 176 - **User** - A string value containg the user to use inside the container. 177 - **Memory** - Memory limit in bytes. 178 - **MemorySwap**- Total memory usage (memory + swap); set `-1` to disable swap. 179 - **CpuShares** - An integer value containing the CPU Shares for container 180 (ie. the relative weight vs othercontainers). 181 **CpuSet** - String value containg the cgroups Cpuset to use. 182 - **AttachStdin** - Boolean value, attaches to stdin. 183 - **AttachStdout** - Boolean value, attaches to stdout. 184 - **AttachStderr** - Boolean value, attaches to stderr. 185 - **Tty** - Boolean value, Attach standard streams to a tty, including stdin if it is not closed. 186 - **OpenStdin** - Boolean value, opens stdin, 187 - **StdinOnce** - Boolean value, close stdin after the 1 attached client disconnects. 188 - **Env** - A list of environment variables in the form of `VAR=value` 189 - **Cmd** - Command to run specified as a string or an array of strings. 190 - **Entrypoint** - Set the entrypoint for the container a a string or an array 191 of strings 192 - **Image** - String value containing the image name to use for the container 193 - **Volumes** – An object mapping mountpoint paths (strings) inside the 194 container to empty objects. 195 - **WorkingDir** - A string value containing the working dir for commands to 196 run in. 197 - **NetworkDisabled** - Boolean value, when true disables neworking for the 198 container 199 - **ExposedPorts** - An object mapping ports to an empty object in the form of: 200 `"ExposedPorts": { "<port>/<tcp|udp>: {}" }` 201 - **SecurityOpts**: A list of string values to customize labels for MLS 202 systems, such as SELinux. 203 - **HostConfig** 204 - **Binds** – A list of volume bindings for this container. Each volume 205 binding is a string of the form `container_path` (to create a new 206 volume for the container), `host_path:container_path` (to bind-mount 207 a host path into the container), or `host_path:container_path:ro` 208 (to make the bind-mount read-only inside the container). 209 - **Links** - A list of links for the container. Each link entry should be of 210 of the form "container_name:alias". 211 - **LxcConf** - LXC specific configurations. These configurations will only 212 work when using the `lxc` execution driver. 213 - **PortBindings** - A map of exposed container ports and the host port they 214 should map to. It should be specified in the form 215 `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }` 216 Take note that `port` is specified as a string and not an integer value. 217 - **PublishAllPorts** - Allocates a random host port for all of a container's 218 exposed ports. Specified as a boolean value. 219 - **Privileged** - Gives the container full access to the host. Specified as 220 a boolean value. 221 - **Dns** - A list of dns servers for the container to use. 222 - **DnsSearch** - A list of DNS search domains 223 - **VolumesFrom** - A list of volumes to inherit from another container. 224 Specified in the form `<container name>[:<ro|rw>]` 225 - **CapAdd** - A list of kernel capabilties to add to the container. 226 - **Capdrop** - A list of kernel capabilties to drop from the container. 227 - **RestartPolicy** – The behavior to apply when the container exits. The 228 value is an object with a `Name` property of either `"always"` to 229 always restart or `"on-failure"` to restart only when the container 230 exit code is non-zero. If `on-failure` is used, `MaximumRetryCount` 231 controls the number of times to retry before giving up. 232 The default is not to restart. (optional) 233 An ever increasing delay (double the previous delay, starting at 100mS) 234 is added before each restart to prevent flooding the server. 235 - **NetworkMode** - Sets the networking mode for the container. Supported 236 values are: `bridge`, `host`, and `container:<name|id>` 237 - **Devices** - A list of devices to add to the container specified in the 238 form 239 `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}` 240 241 Query Parameters: 242 243 - **name** – Assign the specified name to the container. Must 244 match `/?[a-zA-Z0-9_-]+`. 245 246 Status Codes: 247 248 - **201** – no error 249 - **404** – no such container 250 - **406** – impossible to attach (container not running) 251 - **500** – server error 252 253 ### Inspect a container 254 255 `GET /containers/(id)/json` 256 257 Return low-level information on the container `id` 258 259 260 **Example request**: 261 262 GET /containers/4fa6e0f0c678/json HTTP/1.1 263 264 **Example response**: 265 266 HTTP/1.1 200 OK 267 Content-Type: application/json 268 269 { 270 "AppArmorProfile": "", 271 "Args": [ 272 "-c", 273 "exit 9" 274 ], 275 "Config": { 276 "AttachStderr": true, 277 "AttachStdin": false, 278 "AttachStdout": true, 279 "Cmd": [ 280 "/bin/sh", 281 "-c", 282 "exit 9" 283 ], 284 "CpuShares": 0, 285 "Cpuset": "", 286 "Domainname": "", 287 "Entrypoint": null, 288 "Env": [ 289 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 290 ], 291 "ExposedPorts": null, 292 "Hostname": "ba033ac44011", 293 "Image": "ubuntu", 294 "MacAddress": "", 295 "Memory": 0, 296 "MemorySwap": 0, 297 "NetworkDisabled": false, 298 "OnBuild": null, 299 "OpenStdin": false, 300 "PortSpecs": null, 301 "StdinOnce": false, 302 "Tty": false, 303 "User": "", 304 "Volumes": null, 305 "WorkingDir": "" 306 }, 307 "Created": "2015-01-06T15:47:31.485331387Z", 308 "Driver": "devicemapper", 309 "ExecDriver": "native-0.2", 310 "ExecIDs": null, 311 "HostConfig": { 312 "Binds": null, 313 "CapAdd": null, 314 "CapDrop": null, 315 "ContainerIDFile": "", 316 "Devices": [], 317 "Dns": null, 318 "DnsSearch": null, 319 "ExtraHosts": null, 320 "IpcMode": "", 321 "Links": null, 322 "LxcConf": [], 323 "NetworkMode": "bridge", 324 "PortBindings": {}, 325 "Privileged": false, 326 "PublishAllPorts": false, 327 "RestartPolicy": { 328 "MaximumRetryCount": 2, 329 "Name": "on-failure" 330 }, 331 "SecurityOpt": null, 332 "VolumesFrom": null 333 }, 334 "HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname", 335 "HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts", 336 "Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39", 337 "Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2", 338 "MountLabel": "", 339 "Name": "/boring_euclid", 340 "NetworkSettings": { 341 "Bridge": "", 342 "Gateway": "", 343 "IPAddress": "", 344 "IPPrefixLen": 0, 345 "MacAddress": "", 346 "PortMapping": null, 347 "Ports": null 348 }, 349 "Path": "/bin/sh", 350 "ProcessLabel": "", 351 "ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf", 352 "RestartCount": 1, 353 "State": { 354 "Error": "", 355 "ExitCode": 9, 356 "FinishedAt": "2015-01-06T15:47:32.080254511Z", 357 "OOMKilled": false, 358 "Paused": false, 359 "Pid": 0, 360 "Restarting": false, 361 "Running": false, 362 "StartedAt": "2015-01-06T15:47:32.072697474Z" 363 }, 364 "Volumes": {}, 365 "VolumesRW": {} 366 } 367 368 Status Codes: 369 370 - **200** – no error 371 - **404** – no such container 372 - **500** – server error 373 374 ### List processes running inside a container 375 376 `GET /containers/(id)/top` 377 378 List processes running inside the container `id` 379 380 **Example request**: 381 382 GET /containers/4fa6e0f0c678/top HTTP/1.1 383 384 **Example response**: 385 386 HTTP/1.1 200 OK 387 Content-Type: application/json 388 389 { 390 "Titles": [ 391 "USER", 392 "PID", 393 "%CPU", 394 "%MEM", 395 "VSZ", 396 "RSS", 397 "TTY", 398 "STAT", 399 "START", 400 "TIME", 401 "COMMAND" 402 ], 403 "Processes": [ 404 ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"], 405 ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"] 406 ] 407 } 408 409 Query Parameters: 410 411 - **ps_args** – ps arguments to use (e.g., aux) 412 413 Status Codes: 414 415 - **200** – no error 416 - **404** – no such container 417 - **500** – server error 418 419 ### Get container logs 420 421 `GET /containers/(id)/logs` 422 423 Get stdout and stderr logs from the container ``id`` 424 425 **Example request**: 426 427 GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1&tail=10 HTTP/1.1 428 429 **Example response**: 430 431 HTTP/1.1 101 UPGRADED 432 Content-Type: application/vnd.docker.raw-stream 433 Connection: Upgrade 434 Upgrade: tcp 435 436 {{ STREAM }} 437 438 Query Parameters: 439 440 - **follow** – 1/True/true or 0/False/false, return stream. Default false 441 - **stdout** – 1/True/true or 0/False/false, show stdout log. Default false 442 - **stderr** – 1/True/true or 0/False/false, show stderr log. Default false 443 - **timestamps** – 1/True/true or 0/False/false, print timestamps for 444 every log line. Default false 445 - **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all 446 447 Status Codes: 448 449 - **101** – no error, hints proxy about hijacking 450 - **200** – no error, no upgrade header found 451 - **404** – no such container 452 - **500** – server error 453 454 ### Inspect changes on a container's filesystem 455 456 `GET /containers/(id)/changes` 457 458 Inspect changes on container `id`'s filesystem 459 460 **Example request**: 461 462 GET /containers/4fa6e0f0c678/changes HTTP/1.1 463 464 **Example response**: 465 466 HTTP/1.1 200 OK 467 Content-Type: application/json 468 469 [ 470 { 471 "Path": "/dev", 472 "Kind": 0 473 }, 474 { 475 "Path": "/dev/kmsg", 476 "Kind": 1 477 }, 478 { 479 "Path": "/test", 480 "Kind": 1 481 } 482 ] 483 484 Status Codes: 485 486 - **200** – no error 487 - **404** – no such container 488 - **500** – server error 489 490 ### Export a container 491 492 `GET /containers/(id)/export` 493 494 Export the contents of container `id` 495 496 **Example request**: 497 498 GET /containers/4fa6e0f0c678/export HTTP/1.1 499 500 **Example response**: 501 502 HTTP/1.1 200 OK 503 Content-Type: application/octet-stream 504 505 {{ TAR STREAM }} 506 507 Status Codes: 508 509 - **200** – no error 510 - **404** – no such container 511 - **500** – server error 512 513 ### Resize a container TTY 514 515 `POST /containers/(id)/resize?h=<height>&w=<width>` 516 517 Resize the TTY for container with `id`. The container must be restarted for the resize to take effect. 518 519 **Example request**: 520 521 POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1 522 523 **Example response**: 524 525 HTTP/1.1 200 OK 526 Content-Length: 0 527 Content-Type: text/plain; charset=utf-8 528 529 Status Codes: 530 531 - **200** – no error 532 - **404** – No such container 533 - **500** – Cannot resize container 534 535 ### Start a container 536 537 `POST /containers/(id)/start` 538 539 Start the container `id` 540 541 **Example request**: 542 543 POST /containers/(id)/start HTTP/1.1 544 Content-Type: application/json 545 546 **Example response**: 547 548 HTTP/1.1 204 No Content 549 550 Json Parameters: 551 552 Status Codes: 553 554 - **204** – no error 555 - **304** – container already started 556 - **404** – no such container 557 - **500** – server error 558 559 ### Stop a container 560 561 `POST /containers/(id)/stop` 562 563 Stop the container `id` 564 565 **Example request**: 566 567 POST /containers/e90e34656806/stop?t=5 HTTP/1.1 568 569 **Example response**: 570 571 HTTP/1.1 204 No Content 572 573 Query Parameters: 574 575 - **t** – number of seconds to wait before killing the container 576 577 Status Codes: 578 579 - **204** – no error 580 - **304** – container already stopped 581 - **404** – no such container 582 - **500** – server error 583 584 ### Restart a container 585 586 `POST /containers/(id)/restart` 587 588 Restart the container `id` 589 590 **Example request**: 591 592 POST /containers/e90e34656806/restart?t=5 HTTP/1.1 593 594 **Example response**: 595 596 HTTP/1.1 204 No Content 597 598 Query Parameters: 599 600 - **t** – number of seconds to wait before killing the container 601 602 Status Codes: 603 604 - **204** – no error 605 - **404** – no such container 606 - **500** – server error 607 608 ### Kill a container 609 610 `POST /containers/(id)/kill` 611 612 Kill the container `id` 613 614 **Example request**: 615 616 POST /containers/e90e34656806/kill HTTP/1.1 617 618 **Example response**: 619 620 HTTP/1.1 204 No Content 621 622 Query Parameters 623 624 - **signal** - Signal to send to the container: integer or string like "SIGINT". 625 When not set, SIGKILL is assumed and the call will waits for the container to exit. 626 627 Status Codes: 628 629 - **204** – no error 630 - **404** – no such container 631 - **500** – server error 632 633 ### Rename a container 634 635 `POST /containers/(id)/rename` 636 637 Rename the container `id` to a `new_name` 638 639 **Example request**: 640 641 POST /containers/e90e34656806/rename?name=new_name HTTP/1.1 642 643 **Example response**: 644 645 HTTP/1.1 204 No Content 646 647 Query Parameters: 648 649 - **name** – new name for the container 650 651 Status Codes: 652 653 - **204** – no error 654 - **404** – no such container 655 - **409** - conflict name already assigned 656 - **500** – server error 657 658 ### Pause a container 659 660 `POST /containers/(id)/pause` 661 662 Pause the container `id` 663 664 **Example request**: 665 666 POST /containers/e90e34656806/pause HTTP/1.1 667 668 **Example response**: 669 670 HTTP/1.1 204 No Content 671 672 Status Codes: 673 674 - **204** – no error 675 - **404** – no such container 676 - **500** – server error 677 678 ### Unpause a container 679 680 `POST /containers/(id)/unpause` 681 682 Unpause the container `id` 683 684 **Example request**: 685 686 POST /containers/e90e34656806/unpause HTTP/1.1 687 688 **Example response**: 689 690 HTTP/1.1 204 No Content 691 692 Status Codes: 693 694 - **204** – no error 695 - **404** – no such container 696 - **500** – server error 697 698 ### Attach to a container 699 700 `POST /containers/(id)/attach` 701 702 Attach to the container `id` 703 704 **Example request**: 705 706 POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1 707 708 **Example response**: 709 710 HTTP/1.1 101 UPGRADED 711 Content-Type: application/vnd.docker.raw-stream 712 Connection: Upgrade 713 Upgrade: tcp 714 715 {{ STREAM }} 716 717 Query Parameters: 718 719 - **logs** – 1/True/true or 0/False/false, return logs. Default false 720 - **stream** – 1/True/true or 0/False/false, return stream. 721 Default false 722 - **stdin** – 1/True/true or 0/False/false, if stream=true, attach 723 to stdin. Default false 724 - **stdout** – 1/True/true or 0/False/false, if logs=true, return 725 stdout log, if stream=true, attach to stdout. Default false 726 - **stderr** – 1/True/true or 0/False/false, if logs=true, return 727 stderr log, if stream=true, attach to stderr. Default false 728 729 Status Codes: 730 731 - **101** – no error, hints proxy about hijacking 732 - **200** – no error, no upgrade header found 733 - **400** – bad parameter 734 - **404** – no such container 735 - **500** – server error 736 737 **Stream details**: 738 739 When using the TTY setting is enabled in 740 [`POST /containers/create` 741 ](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"), 742 the stream is the raw data from the process PTY and client's stdin. 743 When the TTY is disabled, then the stream is multiplexed to separate 744 stdout and stderr. 745 746 The format is a **Header** and a **Payload** (frame). 747 748 **HEADER** 749 750 The header will contain the information on which stream write the 751 stream (stdout or stderr). It also contain the size of the 752 associated frame encoded on the last 4 bytes (uint32). 753 754 It is encoded on the first 8 bytes like this: 755 756 header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} 757 758 `STREAM_TYPE` can be: 759 760 - 0: stdin (will be written on stdout) 761 - 1: stdout 762 - 2: stderr 763 764 `SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of 765 the uint32 size encoded as big endian. 766 767 **PAYLOAD** 768 769 The payload is the raw stream. 770 771 **IMPLEMENTATION** 772 773 The simplest way to implement the Attach protocol is the following: 774 775 1. Read 8 bytes 776 2. chose stdout or stderr depending on the first byte 777 3. Extract the frame size from the last 4 byets 778 4. Read the extracted size and output it on the correct output 779 5. Goto 1 780 781 ### Wait a container 782 783 `POST /containers/(id)/wait` 784 785 Block until container `id` stops, then returns the exit code 786 787 **Example request**: 788 789 POST /containers/16253994b7c4/wait HTTP/1.1 790 791 **Example response**: 792 793 HTTP/1.1 200 OK 794 Content-Type: application/json 795 796 {"StatusCode": 0} 797 798 Status Codes: 799 800 - **200** – no error 801 - **404** – no such container 802 - **500** – server error 803 804 ### Remove a container 805 806 `DELETE /containers/(id)` 807 808 Remove the container `id` from the filesystem 809 810 **Example request**: 811 812 DELETE /containers/16253994b7c4?v=1 HTTP/1.1 813 814 **Example response**: 815 816 HTTP/1.1 204 No Content 817 818 Query Parameters: 819 820 - **v** – 1/True/true or 0/False/false, Remove the volumes 821 associated to the container. Default false 822 - **force** - 1/True/true or 0/False/false, Kill then remove the container. 823 Default false 824 825 Status Codes: 826 827 - **204** – no error 828 - **400** – bad parameter 829 - **404** – no such container 830 - **500** – server error 831 832 ### Copy files or folders from a container 833 834 `POST /containers/(id)/copy` 835 836 Copy files or folders of container `id` 837 838 **Example request**: 839 840 POST /containers/4fa6e0f0c678/copy HTTP/1.1 841 Content-Type: application/json 842 843 { 844 "Resource": "test.txt" 845 } 846 847 **Example response**: 848 849 HTTP/1.1 200 OK 850 Content-Type: application/x-tar 851 852 {{ TAR STREAM }} 853 854 Status Codes: 855 856 - **200** – no error 857 - **404** – no such container 858 - **500** – server error 859 860 ## 2.2 Images 861 862 ### List Images 863 864 `GET /images/json` 865 866 **Example request**: 867 868 GET /images/json?all=0 HTTP/1.1 869 870 **Example response**: 871 872 HTTP/1.1 200 OK 873 Content-Type: application/json 874 875 [ 876 { 877 "RepoTags": [ 878 "ubuntu:12.04", 879 "ubuntu:precise", 880 "ubuntu:latest" 881 ], 882 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 883 "Created": 1365714795, 884 "Size": 131506275, 885 "VirtualSize": 131506275 886 }, 887 { 888 "RepoTags": [ 889 "ubuntu:12.10", 890 "ubuntu:quantal" 891 ], 892 "ParentId": "27cf784147099545", 893 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 894 "Created": 1364102658, 895 "Size": 24653, 896 "VirtualSize": 180116135 897 } 898 ] 899 900 901 Query Parameters: 902 903 - **all** – 1/True/true or 0/False/false, default false 904 - **filters** – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters: 905 - dangling=true 906 907 ### Build image from a Dockerfile 908 909 `POST /build` 910 911 Build an image from a Dockerfile 912 913 **Example request**: 914 915 POST /build HTTP/1.1 916 917 {{ TAR STREAM }} 918 919 **Example response**: 920 921 HTTP/1.1 200 OK 922 Content-Type: application/json 923 924 {"stream": "Step 1..."} 925 {"stream": "..."} 926 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 927 928 The input stream must be a tar archive compressed with one of the 929 following algorithms: identity (no compression), gzip, bzip2, xz. 930 931 The archive must include a build instructions file, typically called 932 `Dockerfile` at the root of the archive. The `dockerfile` parameter may be 933 used to specify a different build instructions file by having its value be 934 the path to the alternate build instructions file to use. 935 936 The archive may include any number of other files, 937 which will be accessible in the build context (See the [*ADD build 938 command*](/reference/builder/#dockerbuilder)). 939 940 Query Parameters: 941 942 - **dockerfile** - path within the build context to the Dockerfile 943 - **t** – repository name (and optionally a tag) to be applied to 944 the resulting image in case of success 945 - **q** – suppress verbose build output 946 - **nocache** – do not use the cache when building the image 947 - **pull** - attempt to pull the image even if an older image exists locally 948 - **rm** - remove intermediate containers after a successful build (default behavior) 949 - **forcerm** - always remove intermediate containers (includes rm) 950 951 Request Headers: 952 953 - **Content-type** – should be set to `"application/tar"`. 954 - **X-Registry-Config** – base64-encoded ConfigFile objec 955 956 Status Codes: 957 958 - **200** – no error 959 - **500** – server error 960 961 ### Create an image 962 963 `POST /images/create` 964 965 Create an image, either by pulling it from the registry or by importing it 966 967 **Example request**: 968 969 POST /images/create?fromImage=base HTTP/1.1 970 971 **Example response**: 972 973 HTTP/1.1 200 OK 974 Content-Type: application/json 975 976 {"status": "Pulling..."} 977 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 978 {"error": "Invalid..."} 979 ... 980 981 When using this endpoint to pull an image from the registry, the 982 `X-Registry-Auth` header can be used to include 983 a base64-encoded AuthConfig object. 984 985 Query Parameters: 986 987 - **fromImage** – name of the image to pull 988 - **fromSrc** – source to import. The value may be a URL from which the image 989 can be retrieved or `-` to read the image from the request body. 990 - **repo** – repository 991 - **tag** – tag 992 - **registry** – the registry to pull from 993 994 Request Headers: 995 996 - **X-Registry-Auth** – base64-encoded AuthConfig object 997 998 Status Codes: 999 1000 - **200** – no error 1001 - **500** – server error 1002 1003 1004 1005 ### Inspect an image 1006 1007 `GET /images/(name)/json` 1008 1009 Return low-level information on the image `name` 1010 1011 **Example request**: 1012 1013 GET /images/base/json HTTP/1.1 1014 1015 **Example response**: 1016 1017 HTTP/1.1 200 OK 1018 Content-Type: application/json 1019 1020 { 1021 "Created": "2013-03-23T22:24:18.818426-07:00", 1022 "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0", 1023 "ContainerConfig": 1024 { 1025 "Hostname": "", 1026 "User": "", 1027 "Memory": 0, 1028 "MemorySwap": 0, 1029 "AttachStdin": false, 1030 "AttachStdout": false, 1031 "AttachStderr": false, 1032 "PortSpecs": null, 1033 "Tty": true, 1034 "OpenStdin": true, 1035 "StdinOnce": false, 1036 "Env": null, 1037 "Cmd": ["/bin/bash"], 1038 "Dns": null, 1039 "Image": "base", 1040 "Volumes": null, 1041 "VolumesFrom": "", 1042 "WorkingDir": "" 1043 }, 1044 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1045 "Parent": "27cf784147099545", 1046 "Size": 6824592 1047 } 1048 1049 Status Codes: 1050 1051 - **200** – no error 1052 - **404** – no such image 1053 - **500** – server error 1054 1055 ### Get the history of an image 1056 1057 `GET /images/(name)/history` 1058 1059 Return the history of the image `name` 1060 1061 **Example request**: 1062 1063 GET /images/base/history HTTP/1.1 1064 1065 **Example response**: 1066 1067 HTTP/1.1 200 OK 1068 Content-Type: application/json 1069 1070 [ 1071 { 1072 "Id": "b750fe79269d", 1073 "Created": 1364102658, 1074 "CreatedBy": "/bin/bash" 1075 }, 1076 { 1077 "Id": "27cf78414709", 1078 "Created": 1364068391, 1079 "CreatedBy": "" 1080 } 1081 ] 1082 1083 Status Codes: 1084 1085 - **200** – no error 1086 - **404** – no such image 1087 - **500** – server error 1088 1089 ### Push an image on the registry 1090 1091 `POST /images/(name)/push` 1092 1093 Push the image `name` on the registry 1094 1095 **Example request**: 1096 1097 POST /images/test/push HTTP/1.1 1098 1099 **Example response**: 1100 1101 HTTP/1.1 200 OK 1102 Content-Type: application/json 1103 1104 {"status": "Pushing..."} 1105 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 1106 {"error": "Invalid..."} 1107 ... 1108 1109 If you wish to push an image on to a private registry, that image must already have been tagged 1110 into a repository which references that registry host name and port. This repository name should 1111 then be used in the URL. This mirrors the flow of the CLI. 1112 1113 **Example request**: 1114 1115 POST /images/registry.acme.com:5000/test/push HTTP/1.1 1116 1117 1118 Query Parameters: 1119 1120 - **tag** – the tag to associate with the image on the registry, optional 1121 1122 Request Headers: 1123 1124 - **X-Registry-Auth** – include a base64-encoded AuthConfig 1125 object. 1126 1127 Status Codes: 1128 1129 - **200** – no error 1130 - **404** – no such image 1131 - **500** – server error 1132 1133 ### Tag an image into a repository 1134 1135 `POST /images/(name)/tag` 1136 1137 Tag the image `name` into a repository 1138 1139 **Example request**: 1140 1141 POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1 1142 1143 **Example response**: 1144 1145 HTTP/1.1 201 OK 1146 1147 Query Parameters: 1148 1149 - **repo** – The repository to tag in 1150 - **force** – 1/True/true or 0/False/false, default false 1151 - **tag** - The new tag name 1152 1153 Status Codes: 1154 1155 - **201** – no error 1156 - **400** – bad parameter 1157 - **404** – no such image 1158 - **409** – conflict 1159 - **500** – server error 1160 1161 ### Remove an image 1162 1163 `DELETE /images/(name)` 1164 1165 Remove the image `name` from the filesystem 1166 1167 **Example request**: 1168 1169 DELETE /images/test HTTP/1.1 1170 1171 **Example response**: 1172 1173 HTTP/1.1 200 OK 1174 Content-type: application/json 1175 1176 [ 1177 {"Untagged": "3e2f21a89f"}, 1178 {"Deleted": "3e2f21a89f"}, 1179 {"Deleted": "53b4f83ac9"} 1180 ] 1181 1182 Query Parameters: 1183 1184 - **force** – 1/True/true or 0/False/false, default false 1185 - **noprune** – 1/True/true or 0/False/false, default false 1186 1187 Status Codes: 1188 1189 - **200** – no error 1190 - **404** – no such image 1191 - **409** – conflict 1192 - **500** – server error 1193 1194 ### Search images 1195 1196 `GET /images/search` 1197 1198 Search for an image on [Docker Hub](https://hub.docker.com). 1199 1200 > **Note**: 1201 > The response keys have changed from API v1.6 to reflect the JSON 1202 > sent by the registry server to the docker daemon's request. 1203 1204 **Example request**: 1205 1206 GET /images/search?term=sshd HTTP/1.1 1207 1208 **Example response**: 1209 1210 HTTP/1.1 200 OK 1211 Content-Type: application/json 1212 1213 [ 1214 { 1215 "description": "", 1216 "is_official": false, 1217 "is_automated": false, 1218 "name": "wma55/u1210sshd", 1219 "star_count": 0 1220 }, 1221 { 1222 "description": "", 1223 "is_official": false, 1224 "is_automated": false, 1225 "name": "jdswinbank/sshd", 1226 "star_count": 0 1227 }, 1228 { 1229 "description": "", 1230 "is_official": false, 1231 "is_automated": false, 1232 "name": "vgauthier/sshd", 1233 "star_count": 0 1234 } 1235 ... 1236 ] 1237 1238 Query Parameters: 1239 1240 - **term** – term to search 1241 1242 Status Codes: 1243 1244 - **200** – no error 1245 - **500** – server error 1246 1247 ## 2.3 Misc 1248 1249 ### Check auth configuration 1250 1251 `POST /auth` 1252 1253 Get the default username and email 1254 1255 **Example request**: 1256 1257 POST /auth HTTP/1.1 1258 Content-Type: application/json 1259 1260 { 1261 "username":" hannibal", 1262 "password: "xxxx", 1263 "email": "hannibal@a-team.com", 1264 "serveraddress": "https://index.docker.io/v1/" 1265 } 1266 1267 **Example response**: 1268 1269 HTTP/1.1 200 OK 1270 1271 Status Codes: 1272 1273 - **200** – no error 1274 - **204** – no error 1275 - **500** – server error 1276 1277 ### Display system-wide information 1278 1279 `GET /info` 1280 1281 Display system-wide information 1282 1283 **Example request**: 1284 1285 GET /info HTTP/1.1 1286 1287 **Example response**: 1288 1289 HTTP/1.1 200 OK 1290 Content-Type: application/json 1291 1292 { 1293 "Containers":11, 1294 "Images":16, 1295 "Driver":"btrfs", 1296 "DriverStatus": [[""]], 1297 "ExecutionDriver":"native-0.1", 1298 "KernelVersion":"3.12.0-1-amd64" 1299 "NCPU":1, 1300 "MemTotal":2099236864, 1301 "Name":"prod-server-42", 1302 "ID":"7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS", 1303 "Debug":false, 1304 "NFd": 11, 1305 "NGoroutines":21, 1306 "NEventsListener":0, 1307 "InitPath":"/usr/bin/docker", 1308 "InitSha1":"", 1309 "IndexServerAddress":["https://index.docker.io/v1/"], 1310 "MemoryLimit":true, 1311 "SwapLimit":false, 1312 "IPv4Forwarding":true, 1313 "Labels":["storage=ssd"], 1314 "DockerRootDir": "/var/lib/docker", 1315 "OperatingSystem": "Boot2Docker", 1316 } 1317 1318 Status Codes: 1319 1320 - **200** – no error 1321 - **500** – server error 1322 1323 ### Show the docker version information 1324 1325 `GET /version` 1326 1327 Show the docker version information 1328 1329 **Example request**: 1330 1331 GET /version HTTP/1.1 1332 1333 **Example response**: 1334 1335 HTTP/1.1 200 OK 1336 Content-Type: application/json 1337 1338 { 1339 "ApiVersion": "1.12", 1340 "Version": "0.2.2", 1341 "GitCommit": "5a2a5cc+CHANGES", 1342 "GoVersion": "go1.0.3" 1343 } 1344 1345 Status Codes: 1346 1347 - **200** – no error 1348 - **500** – server error 1349 1350 ### Ping the docker server 1351 1352 `GET /_ping` 1353 1354 Ping the docker server 1355 1356 **Example request**: 1357 1358 GET /_ping HTTP/1.1 1359 1360 **Example response**: 1361 1362 HTTP/1.1 200 OK 1363 Content-Type: text/plain 1364 1365 OK 1366 1367 Status Codes: 1368 1369 - **200** - no error 1370 - **500** - server error 1371 1372 ### Create a new image from a container's changes 1373 1374 `POST /commit` 1375 1376 Create a new image from a container's changes 1377 1378 **Example request**: 1379 1380 POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1 1381 Content-Type: application/json 1382 1383 { 1384 "Hostname": "", 1385 "Domainname": "", 1386 "User": "", 1387 "Memory": 0, 1388 "MemorySwap": 0, 1389 "CpuShares": 512, 1390 "Cpuset": "0,1", 1391 "AttachStdin": false, 1392 "AttachStdout": true, 1393 "AttachStderr": true, 1394 "PortSpecs": null, 1395 "Tty": false, 1396 "OpenStdin": false, 1397 "StdinOnce": false, 1398 "Env": null, 1399 "Cmd": [ 1400 "date" 1401 ], 1402 "Volumes": { 1403 "/tmp": {} 1404 }, 1405 "WorkingDir": "", 1406 "NetworkDisabled": false, 1407 "ExposedPorts": { 1408 "22/tcp": {} 1409 } 1410 } 1411 1412 **Example response**: 1413 1414 HTTP/1.1 201 Created 1415 Content-Type: application/vnd.docker.raw-stream 1416 1417 {"Id": "596069db4bf5"} 1418 1419 Json Parameters: 1420 1421 - **config** - the container's configuration 1422 1423 Query Parameters: 1424 1425 - **container** – source container 1426 - **repo** – repository 1427 - **tag** – tag 1428 - **comment** – commit message 1429 - **author** – author (e.g., "John Hannibal Smith 1430 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 1431 1432 Status Codes: 1433 1434 - **201** – no error 1435 - **404** – no such container 1436 - **500** – server error 1437 1438 ### Monitor Docker's events 1439 1440 `GET /events` 1441 1442 Get container events from docker, either in real time via streaming, or via 1443 polling (using since). 1444 1445 Docker containers will report the following events: 1446 1447 create, destroy, die, exec_create, exec_start, export, kill, oom, pause, restart, start, stop, unpause 1448 1449 and Docker images will report: 1450 1451 untag, delete 1452 1453 **Example request**: 1454 1455 GET /events?since=1374067924 1456 1457 **Example response**: 1458 1459 HTTP/1.1 200 OK 1460 Content-Type: application/json 1461 1462 {"status": "create", "id": "dfdf82bd3881","from": "base:latest", "time":1374067924} 1463 {"status": "start", "id": "dfdf82bd3881","from": "base:latest", "time":1374067924} 1464 {"status": "stop", "id": "dfdf82bd3881","from": "base:latest", "time":1374067966} 1465 {"status": "destroy", "id": "dfdf82bd3881","from": "base:latest", "time":1374067970} 1466 1467 Query Parameters: 1468 1469 - **since** – timestamp used for polling 1470 - **until** – timestamp used for polling 1471 - **filters** – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters: 1472 - event=<string> -- event to filter 1473 - image=<string> -- image to filter 1474 - container=<string> -- container to filter 1475 1476 Status Codes: 1477 1478 - **200** – no error 1479 - **500** – server error 1480 1481 ### Get a tarball containing all images in a repository 1482 1483 `GET /images/(name)/get` 1484 1485 Get a tarball containing all images and metadata for the repository specified 1486 by `name`. 1487 1488 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image 1489 (and its parents) are returned. If `name` is an image ID, similarly only tha 1490 image (and its parents) are returned, but with the exclusion of the 1491 'repositories' file in the tarball, as there were no image names referenced. 1492 1493 See the [image tarball format](#image-tarball-format) for more details. 1494 1495 **Example request** 1496 1497 GET /images/ubuntu/get 1498 1499 **Example response**: 1500 1501 HTTP/1.1 200 OK 1502 Content-Type: application/x-tar 1503 1504 Binary data stream 1505 1506 Status Codes: 1507 1508 - **200** – no error 1509 - **500** – server error 1510 1511 ### Get a tarball containing all images. 1512 1513 `GET /images/get` 1514 1515 Get a tarball containing all images and metadata for one or more repositories. 1516 1517 For each value of the `names` parameter: if it is a specific name and tag (e.g. 1518 ubuntu:latest), then only that image (and its parents) are returned; if it is 1519 an image ID, similarly only that image (and its parents) are returned and there 1520 would be no names referenced in the 'repositories' file for this image ID. 1521 1522 See the [image tarball format](#image-tarball-format) for more details. 1523 1524 **Example request** 1525 1526 GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox 1527 1528 **Example response**: 1529 1530 HTTP/1.1 200 OK 1531 Content-Type: application/x-tar 1532 1533 Binary data stream 1534 1535 Status Codes: 1536 1537 - **200** – no error 1538 - **500** – server error 1539 1540 ### Load a tarball with a set of images and tags into docker 1541 1542 `POST /images/load` 1543 1544 Load a set of images and tags into the docker repository. 1545 See the [image tarball format](#image-tarball-format) for more details. 1546 1547 **Example request** 1548 1549 POST /images/load 1550 1551 Tarball in body 1552 1553 **Example response**: 1554 1555 HTTP/1.1 200 OK 1556 1557 Status Codes: 1558 1559 - **200** – no error 1560 - **500** – server error 1561 1562 ### Image tarball format 1563 1564 An image tarball contains one directory per image layer (named using its long ID), 1565 each containing three files: 1566 1567 1. `VERSION`: currently `1.0` - the file format version 1568 2. `json`: detailed layer information, similar to `docker inspect layer_id` 1569 3. `layer.tar`: A tarfile containing the filesystem changes in this layer 1570 1571 The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories 1572 for storing attribute changes and deletions. 1573 1574 If the tarball defines a repository, there will also be a `repositories` file at 1575 the root that contains a list of repository and tag names mapped to layer IDs. 1576 1577 ``` 1578 {"hello-world": 1579 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 1580 } 1581 ``` 1582 1583 ### Exec Create 1584 1585 `POST /containers/(id)/exec` 1586 1587 Sets up an exec instance in a running container `id` 1588 1589 **Example request**: 1590 1591 POST /containers/e90e34656806/exec HTTP/1.1 1592 Content-Type: application/json 1593 1594 { 1595 "AttachStdin": false, 1596 "AttachStdout": true, 1597 "AttachStderr": true, 1598 "Tty": false, 1599 "Cmd": [ 1600 "date" 1601 ], 1602 } 1603 1604 **Example response**: 1605 1606 HTTP/1.1 201 OK 1607 Content-Type: application/json 1608 1609 { 1610 "Id": "f90e34656806" 1611 } 1612 1613 Json Parameters: 1614 1615 - **AttachStdin** - Boolean value, attaches to stdin of the exec command. 1616 - **AttachStdout** - Boolean value, attaches to stdout of the exec command. 1617 - **AttachStderr** - Boolean value, attaches to stderr of the exec command. 1618 - **Tty** - Boolean value to allocate a pseudo-TTY 1619 - **Cmd** - Command to run specified as a string or an array of strings. 1620 1621 1622 Status Codes: 1623 1624 - **201** – no error 1625 - **404** – no such container 1626 1627 ### Exec Start 1628 1629 `POST /exec/(id)/start` 1630 1631 Starts a previously set up exec instance `id`. If `detach` is true, this API 1632 returns after starting the `exec` command. Otherwise, this API sets up an 1633 interactive session with the `exec` command. 1634 1635 **Example request**: 1636 1637 POST /exec/e90e34656806/start HTTP/1.1 1638 Content-Type: application/json 1639 1640 { 1641 "Detach": false, 1642 "Tty": false, 1643 } 1644 1645 **Example response**: 1646 1647 HTTP/1.1 201 OK 1648 Content-Type: application/json 1649 1650 {{ STREAM }} 1651 1652 Json Parameters: 1653 1654 - **Detach** - Detach from the exec command 1655 - **Tty** - Boolean value to allocate a pseudo-TTY 1656 1657 Status Codes: 1658 1659 - **201** – no error 1660 - **404** – no such exec instance 1661 1662 **Stream details**: 1663 Similar to the stream behavior of `POST /container/(id)/attach` API 1664 1665 ### Exec Resize 1666 1667 `POST /exec/(id)/resize` 1668 1669 Resizes the tty session used by the exec command `id`. 1670 This API is valid only if `tty` was specified as part of creating and starting the exec command. 1671 1672 **Example request**: 1673 1674 POST /exec/e90e34656806/resize HTTP/1.1 1675 Content-Type: text/plain 1676 1677 **Example response**: 1678 1679 HTTP/1.1 201 OK 1680 Content-Type: text/plain 1681 1682 Query Parameters: 1683 1684 - **h** – height of tty session 1685 - **w** – width 1686 1687 Status Codes: 1688 1689 - **201** – no error 1690 - **404** – no such exec instance 1691 1692 ### Exec Inspect 1693 1694 `GET /exec/(id)/json` 1695 1696 Return low-level information about the exec command `id`. 1697 1698 **Example request**: 1699 1700 GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1 1701 1702 **Example response**: 1703 1704 HTTP/1.1 200 OK 1705 Content-Type: plain/text 1706 1707 { 1708 "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39", 1709 "Running" : false, 1710 "ExitCode" : 2, 1711 "ProcessConfig" : { 1712 "privileged" : false, 1713 "user" : "", 1714 "tty" : false, 1715 "entrypoint" : "sh", 1716 "arguments" : [ 1717 "-c", 1718 "exit 2" 1719 ] 1720 }, 1721 "OpenStdin" : false, 1722 "OpenStderr" : false, 1723 "OpenStdout" : false, 1724 "Container" : { 1725 "State" : { 1726 "Running" : true, 1727 "Paused" : false, 1728 "Restarting" : false, 1729 "OOMKilled" : false, 1730 "Pid" : 3650, 1731 "ExitCode" : 0, 1732 "Error" : "", 1733 "StartedAt" : "2014-11-17T22:26:03.717657531Z", 1734 "FinishedAt" : "0001-01-01T00:00:00Z" 1735 }, 1736 "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c", 1737 "Created" : "2014-11-17T22:26:03.626304998Z", 1738 "Path" : "date", 1739 "Args" : [], 1740 "Config" : { 1741 "Hostname" : "8f177a186b97", 1742 "Domainname" : "", 1743 "User" : "", 1744 "Memory" : 0, 1745 "MemorySwap" : 0, 1746 "CpuShares" : 0, 1747 "Cpuset" : "", 1748 "AttachStdin" : false, 1749 "AttachStdout" : false, 1750 "AttachStderr" : false, 1751 "PortSpecs" : null, 1752 "ExposedPorts" : null, 1753 "Tty" : false, 1754 "OpenStdin" : false, 1755 "StdinOnce" : false, 1756 "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], 1757 "Cmd" : [ 1758 "date" 1759 ], 1760 "Image" : "ubuntu", 1761 "Volumes" : null, 1762 "WorkingDir" : "", 1763 "Entrypoint" : null, 1764 "NetworkDisabled" : false, 1765 "MacAddress" : "", 1766 "OnBuild" : null, 1767 "SecurityOpt" : null 1768 }, 1769 "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5", 1770 "NetworkSettings" : { 1771 "IPAddress" : "172.17.0.2", 1772 "IPPrefixLen" : 16, 1773 "MacAddress" : "02:42:ac:11:00:02", 1774 "Gateway" : "172.17.42.1", 1775 "Bridge" : "docker0", 1776 "PortMapping" : null, 1777 "Ports" : {} 1778 }, 1779 "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf", 1780 "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname", 1781 "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts", 1782 "Name" : "/test", 1783 "Driver" : "aufs", 1784 "ExecDriver" : "native-0.2", 1785 "MountLabel" : "", 1786 "ProcessLabel" : "", 1787 "AppArmorProfile" : "", 1788 "RestartCount" : 0, 1789 "Volumes" : {}, 1790 "VolumesRW" : {} 1791 } 1792 } 1793 1794 Status Codes: 1795 1796 - **200** – no error 1797 - **404** – no such exec instance 1798 - **500** - server error 1799 1800 # 3. Going further 1801 1802 ## 3.1 Inside `docker run` 1803 1804 As an example, the `docker run` command line makes the following API calls: 1805 1806 - Create the container 1807 1808 - If the status code is 404, it means the image doesn't exist: 1809 - Try to pull it 1810 - Then retry to create the container 1811 1812 - Start the container 1813 1814 - If you are not in detached mode: 1815 - Attach to the container, using logs=1 (to have stdout and 1816 stderr from the container's start) and stream=1 1817 1818 - If in detached mode or only stdin is attached: 1819 - Display the container's id 1820 1821 ## 3.2 Hijacking 1822 1823 In this version of the API, /attach, uses hijacking to transport stdin, 1824 stdout and stderr on the same socket. 1825 1826 To hint potential proxies about connection hijacking, Docker client sends 1827 connection upgrade headers similarly to websocket. 1828 1829 Upgrade: tcp 1830 Connection: Upgrade 1831 1832 When Docker daemon detects the `Upgrade` header, it will switch its status code 1833 from **200 OK** to **101 UPGRADED** and resend the same headers. 1834 1835 This might change in the future. 1836 1837 ## 3.3 CORS Requests 1838 1839 To enable cross origin requests to the remote api add the flag 1840 "--api-enable-cors" when running docker in daemon mode. 1841 1842 $ docker -d -H="192.168.1.9:2375" --api-enable-cors