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