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