github.com/slene/docker@v1.8.0-rc1/docs/reference/api/docker_remote_api.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Remote API" 4 description = "API Documentation for Docker" 5 keywords = ["API, Docker, rcli, REST, documentation"] 6 [menu.main] 7 parent = "smn_remoteapi" 8 +++ 9 <![end-metadata]--> 10 11 # Docker Remote API 12 13 - By default the Docker daemon listens on `unix:///var/run/docker.sock` 14 and the client must have `root` access to interact with the daemon. 15 - If the Docker daemon is set to use an encrypted TCP socket (`--tls`, 16 or `--tlsverify`) as with Boot2Docker 1.3.0, then you need to add extra 17 parameters to `curl` or `wget` when making test API requests: 18 `curl --insecure --cert ~/.docker/cert.pem --key ~/.docker/key.pem https://boot2docker:2376/images/json` 19 or 20 `wget --no-check-certificate --certificate=$DOCKER_CERT_PATH/cert.pem --private-key=$DOCKER_CERT_PATH/key.pem https://boot2docker:2376/images/json -O - -q` 21 - If a group named `docker` exists on your system, docker will apply 22 ownership of the socket to the group. 23 - The API tends to be REST, but for some complex commands, like attach 24 or pull, the HTTP connection is hijacked to transport STDOUT, STDIN, 25 and STDERR. 26 - Since API version 1.2, the auth configuration is now handled client 27 side, so the client has to send the `authConfig` as a `POST` in `/images/(name)/push`. 28 - authConfig, set as the `X-Registry-Auth` header, is currently a Base64 29 encoded (JSON) string with the following structure: 30 `{"username": "string", "password": "string", "email": "string", 31 "serveraddress" : "string", "auth": ""}`. Notice that `auth` is to be left 32 empty, `serveraddress` is a domain/ip without protocol, and that double 33 quotes (instead of single ones) are required. 34 - The Remote API uses an open schema model. In this model, unknown 35 properties in incoming messages will be ignored. 36 Client applications need to take this into account to ensure 37 they will not break when talking to newer Docker daemons. 38 39 The current version of the API is v1.20 40 41 Calling `/info` is the same as calling 42 `/v1.20/info`. 43 44 You can still call an old version of the API using 45 `/v1.19/info`. 46 47 ## Docker Events 48 49 The following diagram depicts the container states accessible through the API. 50 51 ![States](../images/event_state.png) 52 53 Some container-related events are not affected by container state, so they are not included in this diagram. These events are: 54 55 * **export** emitted by `docker export` 56 * **exec_create** emitted by `docker exec` 57 * **exec_start** emitted by `docker exec` after **exec_create** 58 59 Running `docker rmi` emits an **untag** event when removing an image name. The `rmi` command may also emit **delete** events when images are deleted by ID directly or by deleting the last tag referring to the image. 60 61 > **Acknowledgement**: This diagram and the accompanying text were used with the permission of Matt Good and Gilder Labs. See Matt's original blog post [Docker Events Explained](http://gliderlabs.com/blog/2015/04/14/docker-events-explained/). 62 63 ## v1.20 64 65 ### Full documentation 66 67 [*Docker Remote API v1.20*](/reference/api/docker_remote_api_v1.20/) 68 69 ### What's new 70 71 `GET /containers/(id)/archive` 72 73 **New!** 74 Get an archive of filesystem content from a container. 75 76 `PUT /containers/(id)/archive` 77 78 **New!** 79 Upload an archive of content to be extracted to an 80 existing directory inside a container's filesystem. 81 82 `POST /containers/(id)/copy` 83 84 **Deprecated!** 85 This copy endpoint has been deprecated in favor of the above `archive` endpoint 86 which can be used to download files and directories from a container. 87 88 **New!** 89 The `hostConfig` option now accepts the field `GroupAdd`, which specifies a list of additional 90 groups that the container process will run as. 91 92 ## v1.19 93 94 ### Full documentation 95 96 [*Docker Remote API v1.19*](/reference/api/docker_remote_api_v1.19/) 97 98 ### What's new 99 100 **New!** 101 When the daemon detects a version mismatch with the client, usually when 102 the client is newer than the daemon, an HTTP 400 is now returned instead 103 of a 404. 104 105 `GET /containers/(id)/stats` 106 107 **New!** 108 You can now supply a `stream` bool to get only one set of stats and 109 disconnect 110 111 `GET /containers(id)/logs` 112 113 **New!** 114 115 This endpoint now accepts a `since` timestamp parameter. 116 117 `GET /info` 118 119 **New!** 120 121 The fields `Debug`, `IPv4Forwarding`, `MemoryLimit`, and `SwapLimit` 122 are now returned as boolean instead of as an int. 123 124 In addition, the end point now returns the new boolean fields 125 `CpuCfsPeriod`, `CpuCfsQuota`, and `OomKillDisable`. 126 127 ## v1.18 128 129 ### Full documentation 130 131 [*Docker Remote API v1.18*](/reference/api/docker_remote_api_v1.18/) 132 133 ### What's new 134 135 `GET /version` 136 137 **New!** 138 This endpoint now returns `Os`, `Arch` and `KernelVersion`. 139 140 `POST /containers/create` 141 `POST /containers/(id)/start` 142 143 **New!** 144 You can set ulimit settings to be used within the container. 145 146 `GET /info` 147 148 **New!** 149 This endpoint now returns `SystemTime`, `HttpProxy`,`HttpsProxy` and `NoProxy`. 150 151 `GET /images/json` 152 153 **New!** 154 Added a `RepoDigests` field to include image digest information. 155 156 `POST /build` 157 158 **New!** 159 Builds can now set resource constraints for all containers created for the build. 160 161 **New!** 162 (`CgroupParent`) can be passed in the host config to setup container cgroups under a specific cgroup. 163 164 `POST /build` 165 166 **New!** 167 Closing the HTTP request will now cause the build to be canceled. 168 169 `POST /containers/(id)/exec` 170 171 **New!** 172 Add `Warnings` field to response. 173 174 ## v1.17 175 176 ### Full documentation 177 178 [*Docker Remote API v1.17*](/reference/api/docker_remote_api_v1.17/) 179 180 ### What's new 181 182 The build supports `LABEL` command. Use this to add metadata 183 to an image. For example you could add data describing the content of an image. 184 185 `LABEL "com.example.vendor"="ACME Incorporated"` 186 187 **New!** 188 `POST /containers/(id)/attach` and `POST /exec/(id)/start` 189 190 **New!** 191 Docker client now hints potential proxies about connection hijacking using HTTP Upgrade headers. 192 193 `POST /containers/create` 194 195 **New!** 196 You can set labels on container create describing the container. 197 198 `GET /containers/json` 199 200 **New!** 201 The endpoint returns the labels associated with the containers (`Labels`). 202 203 `GET /containers/(id)/json` 204 205 **New!** 206 This endpoint now returns the list current execs associated with the container (`ExecIDs`). 207 This endpoint now returns the container labels (`Config.Labels`). 208 209 `POST /containers/(id)/rename` 210 211 **New!** 212 New endpoint to rename a container `id` to a new name. 213 214 `POST /containers/create` 215 `POST /containers/(id)/start` 216 217 **New!** 218 (`ReadonlyRootfs`) can be passed in the host config to mount the container's 219 root filesystem as read only. 220 221 `GET /containers/(id)/stats` 222 223 **New!** 224 This endpoint returns a live stream of a container's resource usage statistics. 225 226 `GET /images/json` 227 228 **New!** 229 This endpoint now returns the labels associated with each image (`Labels`). 230 231 232 ## v1.16 233 234 ### Full documentation 235 236 [*Docker Remote API v1.16*](/reference/api/docker_remote_api_v1.16/) 237 238 ### What's new 239 240 `GET /info` 241 242 **New!** 243 `info` now returns the number of CPUs available on the machine (`NCPU`), 244 total memory available (`MemTotal`), a user-friendly name describing the running Docker daemon (`Name`), a unique ID identifying the daemon (`ID`), and 245 a list of daemon labels (`Labels`). 246 247 `POST /containers/create` 248 249 **New!** 250 You can set the new container's MAC address explicitly. 251 252 **New!** 253 Volumes are now initialized when the container is created. 254 255 `POST /containers/(id)/copy` 256 257 **New!** 258 You can now copy data which is contained in a volume. 259 260 ## v1.15 261 262 ### Full documentation 263 264 [*Docker Remote API v1.15*](/reference/api/docker_remote_api_v1.15/) 265 266 ### What's new 267 268 `POST /containers/create` 269 270 **New!** 271 It is now possible to set a container's HostConfig when creating a container. 272 Previously this was only available when starting a container. 273 274 ## v1.14 275 276 ### Full documentation 277 278 [*Docker Remote API v1.14*](/reference/api/docker_remote_api_v1.14/) 279 280 ### What's new 281 282 `DELETE /containers/(id)` 283 284 **New!** 285 When using `force`, the container will be immediately killed with SIGKILL. 286 287 `POST /containers/(id)/start` 288 289 **New!** 290 The `hostConfig` option now accepts the field `CapAdd`, which specifies a list of capabilities 291 to add, and the field `CapDrop`, which specifies a list of capabilities to drop. 292 293 `POST /images/create` 294 295 **New!** 296 The `fromImage` and `repo` parameters now supports the `repo:tag` format. 297 Consequently, the `tag` parameter is now obsolete. Using the new format and 298 the `tag` parameter at the same time will return an error. 299 300 ## v1.13 301 302 ### Full documentation 303 304 [*Docker Remote API v1.13*](/reference/api/docker_remote_api_v1.13/) 305 306 ### What's new 307 308 `GET /containers/(name)/json` 309 310 **New!** 311 The `HostConfig.Links` field is now filled correctly 312 313 **New!** 314 `Sockets` parameter added to the `/info` endpoint listing all the sockets the 315 daemon is configured to listen on. 316 317 `POST /containers/(name)/start` 318 `POST /containers/(name)/stop` 319 320 **New!** 321 `start` and `stop` will now return 304 if the container's status is not modified 322 323 `POST /commit` 324 325 **New!** 326 Added a `pause` parameter (default `true`) to pause the container during commit 327 328 ## v1.12 329 330 ### Full documentation 331 332 [*Docker Remote API v1.12*](/reference/api/docker_remote_api_v1.12/) 333 334 ### What's new 335 336 `POST /build` 337 338 **New!** 339 Build now has support for the `forcerm` parameter to always remove containers 340 341 `GET /containers/(name)/json` 342 `GET /images/(name)/json` 343 344 **New!** 345 All the JSON keys are now in CamelCase 346 347 **New!** 348 Trusted builds are now Automated Builds - `is_trusted` is now `is_automated`. 349 350 **Removed Insert Endpoint** 351 The `insert` endpoint has been removed. 352 353 ## v1.11 354 355 ### Full documentation 356 357 [*Docker Remote API v1.11*](/reference/api/docker_remote_api_v1.11/) 358 359 ### What's new 360 361 `GET /_ping` 362 363 **New!** 364 You can now ping the server via the `_ping` endpoint. 365 366 `GET /events` 367 368 **New!** 369 You can now use the `-until` parameter to close connection 370 after timestamp. 371 372 `GET /containers/(id)/logs` 373 374 This url is preferred method for getting container logs now. 375 376 ## v1.10 377 378 ### Full documentation 379 380 [*Docker Remote API v1.10*](/reference/api/docker_remote_api_v1.10/) 381 382 ### What's new 383 384 `DELETE /images/(name)` 385 386 **New!** 387 You can now use the force parameter to force delete of an 388 image, even if it's tagged in multiple repositories. **New!** 389 You 390 can now use the noprune parameter to prevent the deletion of parent 391 images 392 393 `DELETE /containers/(id)` 394 395 **New!** 396 You can now use the force parameter to force delete a 397 container, even if it is currently running 398 399 ## v1.9 400 401 ### Full documentation 402 403 [*Docker Remote API v1.9*](/reference/api/docker_remote_api_v1.9/) 404 405 ### What's new 406 407 `POST /build` 408 409 **New!** 410 This endpoint now takes a serialized ConfigFile which it 411 uses to resolve the proper registry auth credentials for pulling the 412 base image. Clients which previously implemented the version 413 accepting an AuthConfig object must be updated. 414 415 ## v1.8 416 417 ### Full documentation 418 419 [*Docker Remote API v1.8*](/reference/api/docker_remote_api_v1.8/) 420 421 ### What's new 422 423 `POST /build` 424 425 **New!** 426 This endpoint now returns build status as json stream. In 427 case of a build error, it returns the exit status of the failed 428 command. 429 430 `GET /containers/(id)/json` 431 432 **New!** 433 This endpoint now returns the host config for the 434 container. 435 436 `POST /images/create` 437 438 `POST /images/(name)/insert` 439 440 `POST /images/(name)/push` 441 442 **New!** 443 progressDetail object was added in the JSON. It's now 444 possible to get the current value and the total of the progress 445 without having to parse the string. 446 447 ## v1.7 448 449 ### Full documentation 450 451 [*Docker Remote API v1.7*](/reference/api/docker_remote_api_v1.7/) 452 453 ### What's new 454 455 `GET /images/json` 456 457 The format of the json returned from this uri changed. Instead of an 458 entry for each repo/tag on an image, each image is only represented 459 once, with a nested attribute indicating the repo/tags that apply to 460 that image. 461 462 Instead of: 463 464 HTTP/1.1 200 OK 465 Content-Type: application/json 466 467 [ 468 { 469 "VirtualSize": 131506275, 470 "Size": 131506275, 471 "Created": 1365714795, 472 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 473 "Tag": "12.04", 474 "Repository": "ubuntu" 475 }, 476 { 477 "VirtualSize": 131506275, 478 "Size": 131506275, 479 "Created": 1365714795, 480 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 481 "Tag": "latest", 482 "Repository": "ubuntu" 483 }, 484 { 485 "VirtualSize": 131506275, 486 "Size": 131506275, 487 "Created": 1365714795, 488 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 489 "Tag": "precise", 490 "Repository": "ubuntu" 491 }, 492 { 493 "VirtualSize": 180116135, 494 "Size": 24653, 495 "Created": 1364102658, 496 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 497 "Tag": "12.10", 498 "Repository": "ubuntu" 499 }, 500 { 501 "VirtualSize": 180116135, 502 "Size": 24653, 503 "Created": 1364102658, 504 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 505 "Tag": "quantal", 506 "Repository": "ubuntu" 507 } 508 ] 509 510 The returned json looks like this: 511 512 HTTP/1.1 200 OK 513 Content-Type: application/json 514 515 [ 516 { 517 "RepoTags": [ 518 "ubuntu:12.04", 519 "ubuntu:precise", 520 "ubuntu:latest" 521 ], 522 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 523 "Created": 1365714795, 524 "Size": 131506275, 525 "VirtualSize": 131506275 526 }, 527 { 528 "RepoTags": [ 529 "ubuntu:12.10", 530 "ubuntu:quantal" 531 ], 532 "ParentId": "27cf784147099545", 533 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 534 "Created": 1364102658, 535 "Size": 24653, 536 "VirtualSize": 180116135 537 } 538 ] 539 540 `GET /images/viz` 541 542 This URI no longer exists. The `images --viz` 543 output is now generated in the client, using the 544 `/images/json` data. 545 546 ## v1.6 547 548 ### Full documentation 549 550 [*Docker Remote API v1.6*](/reference/api/docker_remote_api_v1.6/) 551 552 ### What's new 553 554 `POST /containers/(id)/attach` 555 556 **New!** 557 You can now split stderr from stdout. This is done by 558 prefixing a header to each transmission. See 559 [`POST /containers/(id)/attach`]( 560 /reference/api/docker_remote_api_v1.9/#attach-to-a-container "POST /containers/(id)/attach"). 561 The WebSocket attach is unchanged. Note that attach calls on the 562 previous API version didn't change. Stdout and stderr are merged. 563 564 ## v1.5 565 566 ### Full documentation 567 568 [*Docker Remote API v1.5*](/reference/api/docker_remote_api_v1.5/) 569 570 ### What's new 571 572 `POST /images/create` 573 574 **New!** 575 You can now pass registry credentials (via an AuthConfig 576 object) through the X-Registry-Auth header 577 578 `POST /images/(name)/push` 579 580 **New!** 581 The AuthConfig object now needs to be passed through the 582 X-Registry-Auth header 583 584 `GET /containers/json` 585 586 **New!** 587 The format of the Ports entry has been changed to a list of 588 dicts each containing PublicPort, PrivatePort and Type describing a 589 port mapping. 590 591 ## v1.4 592 593 ### Full documentation 594 595 [*Docker Remote API v1.4*](/reference/api/docker_remote_api_v1.4/) 596 597 ### What's new 598 599 `POST /images/create` 600 601 **New!** 602 When pulling a repo, all images are now downloaded in parallel. 603 604 `GET /containers/(id)/top` 605 606 **New!** 607 You can now use ps args with docker top, like docker top 608 <container_id> aux 609 610 `GET /events` 611 612 **New!** 613 Image's name added in the events 614 615 ## v1.3 616 617 docker v0.5.0 618 [51f6c4a](https://github.com/docker/docker/commit/51f6c4a7372450d164c61e0054daf0223ddbd909) 619 620 ### Full documentation 621 622 [*Docker Remote API v1.3*](/reference/api/docker_remote_api_v1.3/) 623 624 ### What's new 625 626 `GET /containers/(id)/top` 627 628 List the processes running inside a container. 629 630 `GET /events` 631 632 **New!** 633 Monitor docker's events via streaming or via polling 634 635 Builder (/build): 636 637 - Simplify the upload of the build context 638 - Simply stream a tarball instead of multipart upload with 4 639 intermediary buffers 640 - Simpler, less memory usage, less disk usage and faster 641 642 > **Warning**: 643 > The /build improvements are not reverse-compatible. Pre 1.3 clients will 644 > break on /build. 645 646 List containers (/containers/json): 647 648 - You can use size=1 to get the size of the containers 649 650 Start containers (/containers/<id>/start): 651 652 - You can now pass host-specific configuration (e.g., bind mounts) in 653 the POST body for start calls 654 655 ## v1.2 656 657 docker v0.4.2 658 [2e7649b](https://github.com/docker/docker/commit/2e7649beda7c820793bd46766cbc2cfeace7b168) 659 660 ### Full documentation 661 662 [*Docker Remote API v1.2*](/reference/api/docker_remote_api_v1.2/) 663 664 ### What's new 665 666 The auth configuration is now handled by the client. 667 668 The client should send it's authConfig as POST on each call of 669 `/images/(name)/push` 670 671 `GET /auth` 672 673 **Deprecated.** 674 675 `POST /auth` 676 677 Only checks the configuration but doesn't store it on the server 678 679 Deleting an image is now improved, will only untag the image if it 680 has children and remove all the untagged parents if has any. 681 682 `POST /images/<name>/delete` 683 684 Now returns a JSON structure with the list of images 685 deleted/untagged. 686 687 ## v1.1 688 689 docker v0.4.0 690 [a8ae398](https://github.com/docker/docker/commit/a8ae398bf52e97148ee7bd0d5868de2e15bd297f) 691 692 ### Full documentation 693 694 [*Docker Remote API v1.1*](/reference/api/docker_remote_api_v1.1/) 695 696 ### What's new 697 698 `POST /images/create` 699 700 `POST /images/(name)/insert` 701 702 `POST /images/(name)/push` 703 704 Uses json stream instead of HTML hijack, it looks like this: 705 706 HTTP/1.1 200 OK 707 Content-Type: application/json 708 709 {"status":"Pushing..."} 710 {"status":"Pushing", "progress":"1/? (n/a)"} 711 {"error":"Invalid..."} 712 ... 713 714 ## v1.0 715 716 docker v0.3.4 717 [8d73740](https://github.com/docker/docker/commit/8d73740343778651c09160cde9661f5f387b36f4) 718 719 ### Full documentation 720 721 [*Docker Remote API v1.0*](/reference/api/docker_remote_api_v1.0/) 722 723 ### What's new 724 725 Initial version