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