github.com/pritambaral/docker@v1.4.2-0.20150120174542-b2fe1b3dd952/docs/sources/reference/api/docker_remote_api_v1.11.md (about) 1 page_title: Remote API v1.11 2 page_description: API Documentation for Docker 3 page_keywords: API, Docker, rcli, REST, documentation 4 5 # Docker Remote API v1.11 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 bind 11 Docker to another host/port or a Unix socket. 12 - The API tends to be REST, but for some complex commands, like `attach` 13 or `pull`, the HTTP connection is hijacked to transport `STDOUT`, `STDIN` 14 and `STDERR`. 15 16 # 2. Endpoints 17 18 ## 2.1 Containers 19 20 ### List containers 21 22 `GET /containers/json` 23 24 List containers 25 26 **Example request**: 27 28 GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1 29 30 **Example response**: 31 32 HTTP/1.1 200 OK 33 Content-Type: application/json 34 35 [ 36 { 37 "Id": "8dfafdbc3a40", 38 "Image": "base:latest", 39 "Command": "echo 1", 40 "Created": 1367854155, 41 "Status": "Exit 0", 42 "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}], 43 "SizeRw": 12288, 44 "SizeRootFs": 0 45 }, 46 { 47 "Id": "9cd87474be90", 48 "Image": "base:latest", 49 "Command": "echo 222222", 50 "Created": 1367854155, 51 "Status": "Exit 0", 52 "Ports": [], 53 "SizeRw": 12288, 54 "SizeRootFs": 0 55 }, 56 { 57 "Id": "3176a2479c92", 58 "Image": "base:latest", 59 "Command": "echo 3333333333333333", 60 "Created": 1367854154, 61 "Status": "Exit 0", 62 "Ports":[], 63 "SizeRw":12288, 64 "SizeRootFs":0 65 }, 66 { 67 "Id": "4cb07b47f9fb", 68 "Image": "base:latest", 69 "Command": "echo 444444444444444444444444444444444", 70 "Created": 1367854152, 71 "Status": "Exit 0", 72 "Ports": [], 73 "SizeRw": 12288, 74 "SizeRootFs": 0 75 } 76 ] 77 78 Query Parameters: 79 80 81 82 - **all** – 1/True/true or 0/False/false, Show all containers. 83 Only running containers are shown by default (i.e., this defaults to false) 84 - **limit** – Show `limit` last created containers, include non-running ones. 85 - **since** – Show only containers created since Id, include non-running ones. 86 - **before** – Show only containers created before Id, include non-running ones. 87 - **size** – 1/True/true or 0/False/false, Show the containers sizes 88 89 Status Codes: 90 91 - **200** – no error 92 - **400** – bad parameter 93 - **500** – server error 94 95 ### Create a container 96 97 `POST /containers/create` 98 99 Create a container 100 101 **Example request**: 102 103 POST /containers/create HTTP/1.1 104 Content-Type: application/json 105 106 { 107 "Hostname":"", 108 "User":"", 109 "Memory":0, 110 "MemorySwap":0, 111 "AttachStdin":false, 112 "AttachStdout":true, 113 "AttachStderr":true, 114 "PortSpecs":null, 115 "Tty":false, 116 "OpenStdin":false, 117 "StdinOnce":false, 118 "Env":null, 119 "Cmd":[ 120 "date" 121 ], 122 "Image":"base", 123 "Volumes":{ 124 "/tmp": {} 125 }, 126 "VolumesFrom":"", 127 "WorkingDir":"", 128 "DisableNetwork": false, 129 "ExposedPorts":{ 130 "22/tcp": {} 131 } 132 } 133 134 **Example response**: 135 136 HTTP/1.1 201 Created 137 Content-Type: application/json 138 139 { 140 "Id":"e90e34656806" 141 "Warnings":[] 142 } 143 144 Json Parameters: 145 146 - **config** – the container's configuration 147 148 Query Parameters: 149 150 - **name** – Assign the specified name to the container. Mus 151 match `/?[a-zA-Z0-9_-]+`. 152 153 Status Codes: 154 155 - **201** – no error 156 - **404** – no such container 157 - **406** – impossible to attach (container not running) 158 - **500** – server error 159 160 ### Inspect a container 161 162 `GET /containers/(id)/json` 163 164 Return low-level information on the container `id` 165 166 167 **Example request**: 168 169 GET /containers/4fa6e0f0c678/json HTTP/1.1 170 171 **Example response**: 172 173 HTTP/1.1 200 OK 174 Content-Type: application/json 175 176 { 177 "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2", 178 "Created": "2013-05-07T14:51:42.041847+02:00", 179 "Path": "date", 180 "Args": [], 181 "Config": { 182 "Hostname": "4fa6e0f0c678", 183 "User": "", 184 "Memory": 0, 185 "MemorySwap": 0, 186 "AttachStdin": false, 187 "AttachStdout": true, 188 "AttachStderr": true, 189 "PortSpecs": null, 190 "Tty": false, 191 "OpenStdin": false, 192 "StdinOnce": false, 193 "Env": null, 194 "Cmd": [ 195 "date" 196 ], 197 "Dns": null, 198 "Image": "base", 199 "Volumes": {}, 200 "VolumesFrom": "", 201 "WorkingDir": "" 202 }, 203 "State": { 204 "Running": false, 205 "Pid": 0, 206 "ExitCode": 0, 207 "StartedAt": "2013-05-07T14:51:42.087658+02:01360", 208 "Ghost": false 209 }, 210 "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 211 "NetworkSettings": { 212 "IpAddress": "", 213 "IpPrefixLen": 0, 214 "Gateway": "", 215 "Bridge": "", 216 "PortMapping": null 217 }, 218 "SysInitPath": "/home/kitty/go/src/github.com/docker/docker/bin/docker", 219 "ResolvConfPath": "/etc/resolv.conf", 220 "Volumes": {}, 221 "HostConfig": { 222 "Binds": null, 223 "ContainerIDFile": "", 224 "LxcConf": [], 225 "Privileged": false, 226 "PortBindings": { 227 "80/tcp": [ 228 { 229 "HostIp": "0.0.0.0", 230 "HostPort": "49153" 231 } 232 ] 233 }, 234 "Links": null, 235 "PublishAllPorts": false 236 } 237 } 238 239 Status Codes: 240 241 - **200** – no error 242 - **404** – no such container 243 - **500** – server error 244 245 ### List processes running inside a container 246 247 `GET /containers/(id)/top` 248 249 List processes running inside the container `id` 250 251 **Example request**: 252 253 GET /containers/4fa6e0f0c678/top HTTP/1.1 254 255 **Example response**: 256 257 HTTP/1.1 200 OK 258 Content-Type: application/json 259 260 { 261 "Titles": [ 262 "USER", 263 "PID", 264 "%CPU", 265 "%MEM", 266 "VSZ", 267 "RSS", 268 "TTY", 269 "STAT", 270 "START", 271 "TIME", 272 "COMMAND" 273 ], 274 "Processes": [ 275 ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"], 276 ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"] 277 ] 278 } 279 280 Query Parameters: 281 282 - **ps_args** – ps arguments to use (e.g., aux) 283 284 Status Codes: 285 286 - **200** – no error 287 - **404** – no such container 288 - **500** – server error 289 290 ### Get container logs 291 292 `GET /containers/(id)/logs` 293 294 Get stdout and stderr logs from the container ``id`` 295 296 **Example request**: 297 298 GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1 HTTP/1.1 299 300 **Example response**: 301 302 HTTP/1.1 200 OK 303 Content-Type: application/vnd.docker.raw-stream 304 305 {{ STREAM }} 306 307 Query Parameters: 308 309 310 311 - **follow** – 1/True/true or 0/False/false, return stream. 312 Default false 313 - **stdout** – 1/True/true or 0/False/false, if logs=true, return 314 stdout log. Default false 315 - **stderr** – 1/True/true or 0/False/false, if logs=true, return 316 stderr log. Default false 317 - **timestamps** – 1/True/true or 0/False/false, if logs=true, prin 318 timestamps for every log line. Default false 319 320 Status Codes: 321 322 - **200** – no error 323 - **404** – no such container 324 - **500** – server error 325 326 ### Inspect changes on a container's filesystem 327 328 `GET /containers/(id)/changes` 329 330 Inspect changes on container `id`'s filesystem 331 332 **Example request**: 333 334 GET /containers/4fa6e0f0c678/changes HTTP/1.1 335 336 **Example response**: 337 338 HTTP/1.1 200 OK 339 Content-Type: application/json 340 341 [ 342 { 343 "Path": "/dev", 344 "Kind": 0 345 }, 346 { 347 "Path": "/dev/kmsg", 348 "Kind": 1 349 }, 350 { 351 "Path": "/test", 352 "Kind": 1 353 } 354 ] 355 356 Status Codes: 357 358 - **200** – no error 359 - **404** – no such container 360 - **500** – server error 361 362 ### Export a container 363 364 `GET /containers/(id)/export` 365 366 Export the contents of container `id` 367 368 **Example request**: 369 370 GET /containers/4fa6e0f0c678/export HTTP/1.1 371 372 **Example response**: 373 374 HTTP/1.1 200 OK 375 Content-Type: application/octet-stream 376 377 {{ TAR STREAM }} 378 379 Status Codes: 380 381 - **200** – no error 382 - **404** – no such container 383 - **500** – server error 384 385 ### Start a container 386 387 `POST /containers/(id)/start` 388 389 Start the container `id` 390 391 **Example request**: 392 393 POST /containers/(id)/start HTTP/1.1 394 Content-Type: application/json 395 396 { 397 "Binds":["/tmp:/tmp"], 398 "LxcConf":[{"Key":"lxc.utsname","Value":"docker"}], 399 "PortBindings":{ "22/tcp": [{ "HostPort": "11022" }] }, 400 "PublishAllPorts":false, 401 "Privileged":false, 402 "Dns": ["8.8.8.8"], 403 "VolumesFrom": ["parent", "other:ro"] 404 } 405 406 **Example response**: 407 408 HTTP/1.1 204 No Content 409 Content-Type: text/plain 410 411 Json Parameters: 412 413 414 415 - **hostConfig** – the container's host configuration (optional) 416 417 Status Codes: 418 419 - **204** – no error 420 - **404** – no such container 421 - **500** – server error 422 423 ### Stop a container 424 425 `POST /containers/(id)/stop` 426 427 Stop the container `id` 428 429 **Example request**: 430 431 POST /containers/e90e34656806/stop?t=5 HTTP/1.1 432 433 **Example response**: 434 435 HTTP/1.1 204 No Content 436 437 Query Parameters: 438 439 - **t** – number of seconds to wait before killing the container 440 441 Status Codes: 442 443 - **204** – no error 444 - **404** – no such container 445 - **500** – server error 446 447 ### Restart a container 448 449 `POST /containers/(id)/restart` 450 451 Restart the container `id` 452 453 **Example request**: 454 455 POST /containers/e90e34656806/restart?t=5 HTTP/1.1 456 457 **Example response**: 458 459 HTTP/1.1 204 No Content 460 461 Query Parameters: 462 463 - **t** – number of seconds to wait before killing the container 464 465 Status Codes: 466 467 - **204** – no error 468 - **404** – no such container 469 - **500** – server error 470 471 ### Kill a container 472 473 `POST /containers/(id)/kill` 474 475 Kill the container `id` 476 477 **Example request**: 478 479 POST /containers/e90e34656806/kill HTTP/1.1 480 481 **Example response**: 482 483 HTTP/1.1 204 No Content 484 485 Query Parameters 486 487 - **signal** - Signal to send to the container: integer or string like "SIGINT". 488 When not set, SIGKILL is assumed and the call will wait for the container to exit. 489 490 Status Codes: 491 492 - **204** – no error 493 - **404** – no such container 494 - **500** – server error 495 496 ### Attach to a container 497 498 `POST /containers/(id)/attach` 499 500 Attach to the container `id` 501 502 **Example request**: 503 504 POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1 505 506 **Example response**: 507 508 HTTP/1.1 200 OK 509 Content-Type: application/vnd.docker.raw-stream 510 511 {{ STREAM }} 512 513 Query Parameters: 514 515 - **logs** – 1/True/true or 0/False/false, return logs. Defaul 516 false 517 - **stream** – 1/True/true or 0/False/false, return stream. 518 Default false 519 - **stdin** – 1/True/true or 0/False/false, if stream=true, attach 520 to stdin. Default false 521 - **stdout** – 1/True/true or 0/False/false, if logs=true, return 522 stdout log, if stream=true, attach to stdout. Default false 523 - **stderr** – 1/True/true or 0/False/false, if logs=true, return 524 stderr log, if stream=true, attach to stderr. Default false 525 526 Status Codes: 527 528 - **200** – no error 529 - **400** – bad parameter 530 - **404** – no such container 531 - **500** – server error 532 533 **Stream details**: 534 535 When using the TTY setting is enabled in 536 [`POST /containers/create` 537 ](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"), 538 the stream is the raw data from the process PTY and client's stdin. 539 When the TTY is disabled, then the stream is multiplexed to separate 540 stdout and stderr. 541 542 The format is a **Header** and a **Payload** (frame). 543 544 **HEADER** 545 546 The header will contain the information on which stream write the 547 stream (stdout or stderr). It also contain the size of the 548 associated frame encoded on the last 4 bytes (uint32). 549 550 It is encoded on the first 8 bytes like this: 551 552 header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} 553 554 `STREAM_TYPE` can be: 555 556 - 0: stdin (will be written on stdout) 557 - 1: stdout 558 - 2: stderr 559 560 `SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of 561 the uint32 size encoded as big endian. 562 563 **PAYLOAD** 564 565 The payload is the raw stream. 566 567 **IMPLEMENTATION** 568 569 The simplest way to implement the Attach protocol is the following: 570 571 1. Read 8 bytes 572 2. chose stdout or stderr depending on the first byte 573 3. Extract the frame size from the last 4 byets 574 4. Read the extracted size and output it on the correct output 575 5. Goto 1) 576 577 ### Wait a container 578 579 `POST /containers/(id)/wait` 580 581 Block until container `id` stops, then returns the exit code 582 583 **Example request**: 584 585 POST /containers/16253994b7c4/wait HTTP/1.1 586 587 **Example response**: 588 589 HTTP/1.1 200 OK 590 Content-Type: application/json 591 592 {"StatusCode": 0} 593 594 Status Codes: 595 596 - **200** – no error 597 - **404** – no such container 598 - **500** – server error 599 600 ### Remove a container 601 602 `DELETE /containers/(id)` 603 604 Remove the container `id` from the filesystem 605 606 **Example request**: 607 608 DELETE /containers/16253994b7c4?v=1 HTTP/1.1 609 610 **Example response**: 611 612 HTTP/1.1 204 No Content 613 614 Query Parameters: 615 616 - **v** – 1/True/true or 0/False/false, Remove the volumes 617 associated to the container. Default false 618 - **force** – 1/True/true or 0/False/false, Removes the container 619 even if it was running. Default false 620 621 Status Codes: 622 623 - **204** – no error 624 - **400** – bad parameter 625 - **404** – no such container 626 - **500** – server error 627 628 ### Copy files or folders from a container 629 630 `POST /containers/(id)/copy` 631 632 Copy files or folders of container `id` 633 634 **Example request**: 635 636 POST /containers/4fa6e0f0c678/copy HTTP/1.1 637 Content-Type: application/json 638 639 { 640 "Resource": "test.txt" 641 } 642 643 **Example response**: 644 645 HTTP/1.1 200 OK 646 Content-Type: application/octet-stream 647 648 {{ TAR STREAM }} 649 650 Status Codes: 651 652 - **200** – no error 653 - **404** – no such container 654 - **500** – server error 655 656 ## 2.2 Images 657 658 ### List Images 659 660 `GET /images/json` 661 662 **Example request**: 663 664 GET /images/json?all=0 HTTP/1.1 665 666 **Example response**: 667 668 HTTP/1.1 200 OK 669 Content-Type: application/json 670 671 [ 672 { 673 "RepoTags": [ 674 "ubuntu:12.04", 675 "ubuntu:precise", 676 "ubuntu:latest" 677 ], 678 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 679 "Created": 1365714795, 680 "Size": 131506275, 681 "VirtualSize": 131506275 682 }, 683 { 684 "RepoTags": [ 685 "ubuntu:12.10", 686 "ubuntu:quantal" 687 ], 688 "ParentId": "27cf784147099545", 689 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 690 "Created": 1364102658, 691 "Size": 24653, 692 "VirtualSize": 180116135 693 } 694 ] 695 696 ### Create an image 697 698 `POST /images/create` 699 700 Create an image, either by pull it from the registry or by importing i 701 702 **Example request**: 703 704 POST /images/create?fromImage=base HTTP/1.1 705 706 **Example response**: 707 708 HTTP/1.1 200 OK 709 Content-Type: application/json 710 711 {"status": "Pulling..."} 712 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 713 {"error": "Invalid..."} 714 ... 715 716 When using this endpoint to pull an image from the registry, the 717 `X-Registry-Auth` header can be used to include 718 a base64-encoded AuthConfig object. 719 720 Query Parameters: 721 722 - **fromImage** – name of the image to pull 723 - **fromSrc** – source to import, - means stdin 724 - **repo** – repository 725 - **tag** – tag 726 - **registry** – the registry to pull from 727 728 Request Headers: 729 730 - **X-Registry-Auth** – base64-encoded AuthConfig object 731 732 Status Codes: 733 734 - **200** – no error 735 - **500** – server error 736 737 ### Inspect an image 738 739 `GET /images/(name)/json` 740 741 Return low-level information on the image `name` 742 743 **Example request**: 744 745 GET /images/base/json HTTP/1.1 746 747 **Example response**: 748 749 HTTP/1.1 200 OK 750 Content-Type: application/json 751 752 { 753 "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 754 "parent":"27cf784147099545", 755 "created":"2013-03-23T22:24:18.818426-07:00", 756 "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0", 757 "container_config": 758 { 759 "Hostname":"", 760 "User":"", 761 "Memory":0, 762 "MemorySwap":0, 763 "AttachStdin":false, 764 "AttachStdout":false, 765 "AttachStderr":false, 766 "PortSpecs":null, 767 "Tty":true, 768 "OpenStdin":true, 769 "StdinOnce":false, 770 "Env":null, 771 "Cmd": ["/bin/bash"], 772 "Dns":null, 773 "Image":"base", 774 "Volumes":null, 775 "VolumesFrom":"", 776 "WorkingDir":"" 777 }, 778 "Size": 6824592 779 } 780 781 Status Codes: 782 783 - **200** – no error 784 - **404** – no such image 785 - **500** – server error 786 787 ### Get the history of an image 788 789 `GET /images/(name)/history` 790 791 Return the history of the image `name` 792 793 **Example request**: 794 795 GET /images/base/history HTTP/1.1 796 797 **Example response**: 798 799 HTTP/1.1 200 OK 800 Content-Type: application/json 801 802 [ 803 { 804 "Id": "b750fe79269d", 805 "Created": 1364102658, 806 "CreatedBy": "/bin/bash" 807 }, 808 { 809 "Id": "27cf78414709", 810 "Created": 1364068391, 811 "CreatedBy": "" 812 } 813 ] 814 815 Status Codes: 816 817 - **200** – no error 818 - **404** – no such image 819 - **500** – server error 820 821 ### Push an image on the registry 822 823 `POST /images/(name)/push` 824 825 Push the image `name` on the registry 826 827 **Example request**: 828 829 POST /images/test/push HTTP/1.1 830 831 **Example response**: 832 833 HTTP/1.1 200 OK 834 Content-Type: application/json 835 836 {"status": "Pushing..."} 837 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 838 {"error": "Invalid..."} 839 ... 840 841 If you wish to push an image on to a private registry, that image must already have been tagged 842 into a repository which references that registry host name and port. This repository name should 843 then be used in the URL. This mirrors the flow of the CLI. 844 845 **Example request**: 846 847 POST /images/registry.acme.com:5000/test/push HTTP/1.1 848 849 850 Query Parameters: 851 852 - **tag** – the tag to associate with the image on the registry, optional 853 854 Request Headers: 855 856 - **X-Registry-Auth** – include a base64-encoded AuthConfig object. 857 858 Status Codes: 859 860 - **200** – no error 861 - **404** – no such image 862 - **500** – server error 863 864 ### Tag an image into a repository 865 866 `POST /images/(name)/tag` 867 868 Tag the image `name` into a repository 869 870 **Example request**: 871 872 POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1 873 874 **Example response**: 875 876 HTTP/1.1 201 OK 877 878 Query Parameters: 879 880 - **repo** – The repository to tag in 881 - **force** – 1/True/true or 0/False/false, default false 882 - **tag** - The new tag name 883 884 Status Codes: 885 886 - **201** – no error 887 - **400** – bad parameter 888 - **404** – no such image 889 - **409** – conflict 890 - **500** – server error 891 892 ### Remove an image 893 894 `DELETE /images/(name)` 895 896 Remove the image `name` from the filesystem 897 898 **Example request**: 899 900 DELETE /images/test HTTP/1.1 901 902 **Example response**: 903 904 HTTP/1.1 200 OK 905 Content-type: application/json 906 907 [ 908 {"Untagged": "3e2f21a89f"}, 909 {"Deleted": "3e2f21a89f"}, 910 {"Deleted": "53b4f83ac9"} 911 ] 912 913 Query Parameters: 914 915 - **force** – 1/True/true or 0/False/false, default false 916 - **noprune** – 1/True/true or 0/False/false, default false 917 918 Status Codes: 919 920 - **200** – no error 921 - **404** – no such image 922 - **409** – conflict 923 - **500** – server error 924 925 ### Search images 926 927 `GET /images/search` 928 929 Search for an image on [Docker Hub](https://hub.docker.com). 930 931 > **Note**: 932 > The response keys have changed from API v1.6 to reflect the JSON 933 > sent by the registry server to the docker daemon's request. 934 935 **Example request**: 936 937 GET /images/search?term=sshd HTTP/1.1 938 939 **Example response**: 940 941 HTTP/1.1 200 OK 942 Content-Type: application/json 943 944 [ 945 { 946 "description": "", 947 "is_official": false, 948 "is_trusted": false, 949 "name": "wma55/u1210sshd", 950 "star_count": 0 951 }, 952 { 953 "description": "", 954 "is_official": false, 955 "is_trusted": false, 956 "name": "jdswinbank/sshd", 957 "star_count": 0 958 }, 959 { 960 "description": "", 961 "is_official": false, 962 "is_trusted": false, 963 "name": "vgauthier/sshd", 964 "star_count": 0 965 } 966 ... 967 ] 968 969 Query Parameters: 970 971 - **term** – term to search 972 973 Status Codes: 974 975 - **200** – no error 976 - **500** – server error 977 978 ## 2.3 Misc 979 980 ### Build an image from Dockerfile via stdin 981 982 `POST /build` 983 984 Build an image from Dockerfile via stdin 985 986 **Example request**: 987 988 POST /build HTTP/1.1 989 990 {{ TAR STREAM }} 991 992 **Example response**: 993 994 HTTP/1.1 200 OK 995 Content-Type: application/json 996 997 {"stream": "Step 1..."} 998 {"stream": "..."} 999 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 1000 1001 The stream must be a tar archive compressed with one of the 1002 following algorithms: identity (no compression), gzip, bzip2, xz. 1003 1004 The archive must include a file called `Dockerfile` 1005 at its root. It may include any number of other files, 1006 which will be accessible in the build context (See the [*ADD build 1007 command*](/reference/builder/#dockerbuilder)). 1008 1009 Query Parameters: 1010 1011 - **t** – repository name (and optionally a tag) to be applied to 1012 the resulting image in case of success 1013 - **q** – suppress verbose build output 1014 - **nocache** – do not use the cache when building the image 1015 - **rm** - remove intermediate containers after a successful build 1016 1017 Request Headers: 1018 1019 - **Content-type** – should be set to `"application/tar"`. 1020 - **X-Registry-Config** – base64-encoded ConfigFile objec 1021 1022 Status Codes: 1023 1024 - **200** – no error 1025 - **500** – server error 1026 1027 ### Check auth configuration 1028 1029 `POST /auth` 1030 1031 Get the default username and email 1032 1033 **Example request**: 1034 1035 POST /auth HTTP/1.1 1036 Content-Type: application/json 1037 1038 { 1039 "username":" hannibal", 1040 "password: "xxxx", 1041 "email": "hannibal@a-team.com", 1042 "serveraddress": "https://index.docker.io/v1/" 1043 } 1044 1045 **Example response**: 1046 1047 HTTP/1.1 200 OK 1048 1049 Status Codes: 1050 1051 - **200** – no error 1052 - **204** – no error 1053 - **500** – server error 1054 1055 ### Display system-wide information 1056 1057 `GET /info` 1058 1059 Display system-wide information 1060 1061 **Example request**: 1062 1063 GET /info HTTP/1.1 1064 1065 **Example response**: 1066 1067 HTTP/1.1 200 OK 1068 Content-Type: application/json 1069 1070 { 1071 "Containers": 11, 1072 "Images": 16, 1073 "Driver": "btrfs", 1074 "ExecutionDriver": "native-0.1", 1075 "KernelVersion": "3.12.0-1-amd64" 1076 "Debug": false, 1077 "NFd": 11, 1078 "NGoroutines": 21, 1079 "NEventsListener": 0, 1080 "InitPath": "/usr/bin/docker", 1081 "IndexServerAddress": ["https://index.docker.io/v1/"], 1082 "MemoryLimit": true, 1083 "SwapLimit": false, 1084 "IPv4Forwarding": true 1085 } 1086 1087 Status Codes: 1088 1089 - **200** – no error 1090 - **500** – server error 1091 1092 ### Show the docker version information 1093 1094 `GET /version` 1095 1096 Show the docker version information 1097 1098 **Example request**: 1099 1100 GET /version HTTP/1.1 1101 1102 **Example response**: 1103 1104 HTTP/1.1 200 OK 1105 Content-Type: application/json 1106 1107 { 1108 "Version":"0.2.2", 1109 "GitCommit":"5a2a5cc+CHANGES", 1110 "GoVersion":"go1.0.3" 1111 } 1112 1113 Status Codes: 1114 1115 - **200** – no error 1116 - **500** – server error 1117 1118 ### Ping the docker server 1119 1120 `GET /_ping` 1121 1122 Ping the docker server 1123 1124 **Example request**: 1125 1126 GET /_ping HTTP/1.1 1127 1128 **Example response**: 1129 1130 HTTP/1.1 200 OK 1131 Content-Type: text/plain 1132 1133 OK 1134 1135 Status Codes: 1136 1137 - **200** - no error 1138 - **500** - server error 1139 1140 ### Create a new image from a container's changes 1141 1142 `POST /commit` 1143 1144 Create a new image from a container's changes 1145 1146 **Example request**: 1147 1148 POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1 1149 Content-Type: application/json 1150 1151 { 1152 "Hostname":"", 1153 "User":"", 1154 "Memory":0, 1155 "MemorySwap":0, 1156 "AttachStdin":false, 1157 "AttachStdout":true, 1158 "AttachStderr":true, 1159 "PortSpecs":null, 1160 "Tty":false, 1161 "OpenStdin":false, 1162 "StdinOnce":false, 1163 "Env":null, 1164 "Cmd":[ 1165 "date" 1166 ], 1167 "Volumes":{ 1168 "/tmp": {} 1169 }, 1170 "WorkingDir":"", 1171 "DisableNetwork": false, 1172 "ExposedPorts":{ 1173 "22/tcp": {} 1174 } 1175 } 1176 1177 **Example response**: 1178 1179 HTTP/1.1 201 Created 1180 Content-Type: application/vnd.docker.raw-stream 1181 1182 {"Id": "596069db4bf5"} 1183 1184 Json Parameters: 1185 1186 - **config** - the container's configuration 1187 1188 Query Parameters: 1189 1190 - **container** – source container 1191 - **repo** – repository 1192 - **tag** – tag 1193 - **m** – commit message 1194 - **author** – author (e.g., "John Hannibal Smith 1195 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 1196 1197 Status Codes: 1198 1199 - **201** – no error 1200 - **404** – no such container 1201 - **500** – server error 1202 1203 ### Monitor Docker's events 1204 1205 `GET /events` 1206 1207 Get container events from docker, either in real time via streaming, or via 1208 polling (using since). 1209 1210 Docker containers will report the following events: 1211 1212 create, destroy, die, export, kill, pause, restart, start, stop, unpause 1213 1214 and Docker images will report: 1215 1216 untag, delete 1217 1218 **Example request**: 1219 1220 GET /events?since=1374067924 1221 1222 **Example response**: 1223 1224 HTTP/1.1 200 OK 1225 Content-Type: application/json 1226 1227 {"status": "create", "id": "dfdf82bd3881","from": "base:latest", "time":1374067924} 1228 {"status": "start", "id": "dfdf82bd3881","from": "base:latest", "time":1374067924} 1229 {"status": "stop", "id": "dfdf82bd3881","from": "base:latest", "time":1374067966} 1230 {"status": "destroy", "id": "dfdf82bd3881","from": "base:latest", "time":1374067970} 1231 1232 Query Parameters: 1233 1234 - **since** – timestamp used for polling 1235 - **until** – timestamp used for polling 1236 1237 Status Codes: 1238 1239 - **200** – no error 1240 - **500** – server error 1241 1242 ### Get a tarball containing all images and tags in a repository 1243 1244 `GET /images/(name)/get` 1245 1246 Get a tarball containing all images and metadata for the repository 1247 specified by `name`. 1248 1249 See the [image tarball format](#image-tarball-format) for more details. 1250 1251 **Example request** 1252 1253 GET /images/ubuntu/get 1254 1255 **Example response**: 1256 1257 HTTP/1.1 200 OK 1258 Content-Type: application/x-tar 1259 1260 Binary data stream 1261 1262 Status Codes: 1263 1264 - **200** – no error 1265 - **500** – server error 1266 1267 ### Load a tarball with a set of images and tags into docker 1268 1269 `POST /images/load` 1270 1271 Load a set of images and tags into the docker repository. 1272 1273 See the [image tarball format](#image-tarball-format) for more details. 1274 1275 **Example request** 1276 1277 POST /images/load 1278 1279 Tarball in body 1280 1281 **Example response**: 1282 1283 HTTP/1.1 200 OK 1284 1285 Status Codes: 1286 1287 - **200** – no error 1288 - **500** – server error 1289 1290 ### Image tarball format 1291 1292 An image tarball contains one directory per image layer (named using its long ID), 1293 each containing three files: 1294 1295 1. `VERSION`: currently `1.0` - the file format version 1296 2. `json`: detailed layer information, similar to `docker inspect layer_id` 1297 3. `layer.tar`: A tarfile containing the filesystem changes in this layer 1298 1299 The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories 1300 for storing attribute changes and deletions. 1301 1302 If the tarball defines a repository, there will also be a `repositories` file at 1303 the root that contains a list of repository and tag names mapped to layer IDs. 1304 1305 ``` 1306 {"hello-world": 1307 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 1308 } 1309 ``` 1310 1311 # 3. Going further 1312 1313 ## 3.1 Inside `docker run` 1314 1315 As an example, the `docker run` command line makes the following API calls: 1316 1317 - Create the container 1318 1319 - If the status code is 404, it means the image doesn't exist: 1320 - Try to pull it 1321 - Then retry to create the container 1322 1323 - Start the container 1324 1325 - If you are not in detached mode: 1326 - Attach to the container, using logs=1 (to have stdout and 1327 stderr from the container's start) and stream=1 1328 1329 - If in detached mode or only stdin is attached: 1330 - Display the container's id 1331 1332 ## 3.2 Hijacking 1333 1334 In this version of the API, /attach, uses hijacking to transport stdin, 1335 stdout and stderr on the same socket. This might change in the future. 1336 1337 ## 3.3 CORS Requests 1338 1339 To enable cross origin requests to the remote api add the flag 1340 "--api-enable-cors" when running docker in daemon mode. 1341 1342 $ docker -d -H="192.168.1.9:2375" --api-enable-cors