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