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