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