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