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