github.com/kim0/docker@v0.6.2-0.20161130212042-4addda3f07e7/docs/reference/api/docker_remote_api_v1.20.md (about) 1 --- 2 title: "Remote API v1.20" 3 description: "API Documentation for Docker" 4 keywords: ["API, Docker, rcli, REST, documentation"] 5 --- 6 7 <!-- This file is maintained within the docker/docker Github 8 repository at https://github.com/docker/docker/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # Docker Remote API v1.20 17 18 ## 1. Brief introduction 19 20 - The Remote API has replaced `rcli`. 21 - The daemon listens on `unix:///var/run/docker.sock` but you can 22 [Bind Docker to another host/port or a Unix socket](../commandline/dockerd.md#bind-docker-to-another-host-port-or-a-unix-socket). 23 - The API tends to be REST. However, for some complex commands, like `attach` 24 or `pull`, the HTTP connection is hijacked to transport `stdout`, 25 `stdin` and `stderr`. 26 - When the client API version is newer than the daemon's, these calls return an HTTP 27 `400 Bad Request` error message. 28 29 # 2. Endpoints 30 31 ## 2.1 Containers 32 33 ### List containers 34 35 `GET /containers/json` 36 37 List containers 38 39 **Example request**: 40 41 GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1 42 43 **Example response**: 44 45 HTTP/1.1 200 OK 46 Content-Type: application/json 47 48 [ 49 { 50 "Id": "8dfafdbc3a40", 51 "Names":["/boring_feynman"], 52 "Image": "ubuntu:latest", 53 "Command": "echo 1", 54 "Created": 1367854155, 55 "Status": "Exit 0", 56 "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}], 57 "Labels": { 58 "com.example.vendor": "Acme", 59 "com.example.license": "GPL", 60 "com.example.version": "1.0" 61 }, 62 "SizeRw": 12288, 63 "SizeRootFs": 0 64 }, 65 { 66 "Id": "9cd87474be90", 67 "Names":["/coolName"], 68 "Image": "ubuntu:latest", 69 "Command": "echo 222222", 70 "Created": 1367854155, 71 "Status": "Exit 0", 72 "Ports": [], 73 "Labels": {}, 74 "SizeRw": 12288, 75 "SizeRootFs": 0 76 }, 77 { 78 "Id": "3176a2479c92", 79 "Names":["/sleepy_dog"], 80 "Image": "ubuntu:latest", 81 "Command": "echo 3333333333333333", 82 "Created": 1367854154, 83 "Status": "Exit 0", 84 "Ports":[], 85 "Labels": {}, 86 "SizeRw":12288, 87 "SizeRootFs":0 88 }, 89 { 90 "Id": "4cb07b47f9fb", 91 "Names":["/running_cat"], 92 "Image": "ubuntu:latest", 93 "Command": "echo 444444444444444444444444444444444", 94 "Created": 1367854152, 95 "Status": "Exit 0", 96 "Ports": [], 97 "Labels": {}, 98 "SizeRw": 12288, 99 "SizeRootFs": 0 100 } 101 ] 102 103 **Query parameters**: 104 105 - **all** – 1/True/true or 0/False/false, Show all containers. 106 Only running containers are shown by default (i.e., this defaults to false) 107 - **limit** – Show `limit` last created 108 containers, include non-running ones. 109 - **since** – Show only containers created since Id, include 110 non-running ones. 111 - **before** – Show only containers created before Id, include 112 non-running ones. 113 - **size** – 1/True/true or 0/False/false, Show the containers 114 sizes 115 - **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters: 116 - `exited=<int>`; -- containers with exit code of `<int>` ; 117 - `status=`(`created`|`restarting`|`running`|`paused`|`exited`) 118 - `label=key` or `label="key=value"` of a container label 119 120 **Status codes**: 121 122 - **200** – no error 123 - **400** – bad parameter 124 - **500** – server error 125 126 ### Create a container 127 128 `POST /containers/create` 129 130 Create a container 131 132 **Example request**: 133 134 POST /containers/create HTTP/1.1 135 Content-Type: application/json 136 137 { 138 "Hostname": "", 139 "Domainname": "", 140 "User": "", 141 "AttachStdin": false, 142 "AttachStdout": true, 143 "AttachStderr": true, 144 "Tty": false, 145 "OpenStdin": false, 146 "StdinOnce": false, 147 "Env": [ 148 "FOO=bar", 149 "BAZ=quux" 150 ], 151 "Cmd": [ 152 "date" 153 ], 154 "Entrypoint": null, 155 "Image": "ubuntu", 156 "Labels": { 157 "com.example.vendor": "Acme", 158 "com.example.license": "GPL", 159 "com.example.version": "1.0" 160 }, 161 "Volumes": { 162 "/volumes/data": {} 163 }, 164 "WorkingDir": "", 165 "NetworkDisabled": false, 166 "MacAddress": "12:34:56:78:9a:bc", 167 "ExposedPorts": { 168 "22/tcp": {} 169 }, 170 "HostConfig": { 171 "Binds": ["/tmp:/tmp"], 172 "Links": ["redis3:redis"], 173 "LxcConf": {"lxc.utsname":"docker"}, 174 "Memory": 0, 175 "MemorySwap": 0, 176 "CpuShares": 512, 177 "CpuPeriod": 100000, 178 "CpuQuota": 50000, 179 "CpusetCpus": "0,1", 180 "CpusetMems": "0,1", 181 "BlkioWeight": 300, 182 "MemorySwappiness": 60, 183 "OomKillDisable": false, 184 "PidMode": "", 185 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] }, 186 "PublishAllPorts": false, 187 "Privileged": false, 188 "ReadonlyRootfs": false, 189 "Dns": ["8.8.8.8"], 190 "DnsSearch": [""], 191 "ExtraHosts": null, 192 "VolumesFrom": ["parent", "other:ro"], 193 "CapAdd": ["NET_ADMIN"], 194 "CapDrop": ["MKNOD"], 195 "GroupAdd": ["newgroup"], 196 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 }, 197 "NetworkMode": "bridge", 198 "Devices": [], 199 "Ulimits": [{}], 200 "LogConfig": { "Type": "json-file", "Config": {} }, 201 "SecurityOpt": [], 202 "CgroupParent": "" 203 } 204 } 205 206 **Example response**: 207 208 HTTP/1.1 201 Created 209 Content-Type: application/json 210 211 { 212 "Id":"e90e34656806", 213 "Warnings":[] 214 } 215 216 **JSON parameters**: 217 218 - **Hostname** - A string value containing the hostname to use for the 219 container. 220 - **Domainname** - A string value containing the domain name to use 221 for the container. 222 - **User** - A string value specifying the user inside the container. 223 - **AttachStdin** - Boolean value, attaches to `stdin`. 224 - **AttachStdout** - Boolean value, attaches to `stdout`. 225 - **AttachStderr** - Boolean value, attaches to `stderr`. 226 - **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed. 227 - **OpenStdin** - Boolean value, opens `stdin`, 228 - **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects. 229 - **Env** - A list of environment variables in the form of `["VAR=value", ...]` 230 - **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value", ... }` 231 - **Cmd** - Command to run specified as a string or an array of strings. 232 - **Entrypoint** - Set the entry point for the container as a string or an array 233 of strings. 234 - **Image** - A string specifying the image name to use for the container. 235 - **Volumes** - An object mapping mount point paths (strings) inside the 236 container to empty objects. 237 - **WorkingDir** - A string specifying the working directory for commands to 238 run in. 239 - **NetworkDisabled** - Boolean value, when true disables networking for the 240 container 241 - **ExposedPorts** - An object mapping ports to an empty object in the form of: 242 `"ExposedPorts": { "<port>/<tcp|udp>: {}" }` 243 - **HostConfig** 244 - **Binds** – A list of bind-mounts for this container. Each item is a string in one of these forms: 245 + `host-src:container-dest` to bind-mount a host path into the 246 container. Both `host-src`, and `container-dest` must be an 247 _absolute_ path. 248 + `host-src:container-dest:ro` to make the bind-mount read-only 249 inside the container. Both `host-src`, and `container-dest` must be 250 an _absolute_ path. 251 - **Links** - A list of links for the container. Each link entry should be 252 in the form of `container_name:alias`. 253 - **LxcConf** - LXC specific configurations. These configurations only 254 work when using the `lxc` execution driver. 255 - **Memory** - Memory limit in bytes. 256 - **MemorySwap** - Total memory limit (memory + swap); set `-1` to enable unlimited swap. 257 You must use this with `memory` and make the swap value larger than `memory`. 258 - **CpuShares** - An integer value containing the container's CPU Shares 259 (ie. the relative weight vs other containers). 260 - **CpuPeriod** - The length of a CPU period in microseconds. 261 - **CpuQuota** - Microseconds of CPU time that the container can get in a CPU period. 262 - **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use. 263 - **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. 264 - **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000. 265 - **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100. 266 - **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not. 267 - **PidMode** - Set the PID (Process) Namespace mode for the container; 268 `"container:<name|id>"`: joins another container's PID namespace 269 `"host"`: use the host's PID namespace inside the container 270 - **PortBindings** - A map of exposed container ports and the host port they 271 should map to. A JSON object in the form 272 `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }` 273 Take note that `port` is specified as a string and not an integer value. 274 - **PublishAllPorts** - Allocates a random host port for all of a container's 275 exposed ports. Specified as a boolean value. 276 - **Privileged** - Gives the container full access to the host. Specified as 277 a boolean value. 278 - **ReadonlyRootfs** - Mount the container's root filesystem as read only. 279 Specified as a boolean value. 280 - **Dns** - A list of DNS servers for the container to use. 281 - **DnsSearch** - A list of DNS search domains 282 - **ExtraHosts** - A list of hostnames/IP mappings to add to the 283 container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`. 284 - **VolumesFrom** - A list of volumes to inherit from another container. 285 Specified in the form `<container name>[:<ro|rw>]` 286 - **CapAdd** - A list of kernel capabilities to add to the container. 287 - **Capdrop** - A list of kernel capabilities to drop from the container. 288 - **GroupAdd** - A list of additional groups that the container process will run as 289 - **RestartPolicy** – The behavior to apply when the container exits. The 290 value is an object with a `Name` property of either `"always"` to 291 always restart or `"on-failure"` to restart only when the container 292 exit code is non-zero. If `on-failure` is used, `MaximumRetryCount` 293 controls the number of times to retry before giving up. 294 The default is not to restart. (optional) 295 An ever increasing delay (double the previous delay, starting at 100mS) 296 is added before each restart to prevent flooding the server. 297 - **NetworkMode** - Sets the networking mode for the container. Supported 298 values are: `bridge`, `host`, `none`, and `container:<name|id>` 299 - **Devices** - A list of devices to add to the container specified as a JSON object in the 300 form 301 `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}` 302 - **Ulimits** - A list of ulimits to set in the container, specified as 303 `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example: 304 `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }` 305 - **SecurityOpt**: A list of string values to customize labels for MLS 306 systems, such as SELinux. 307 - **LogConfig** - Log configuration for the container, specified as a JSON object in the form 308 `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`. 309 Available types: `json-file`, `syslog`, `journald`, `gelf`, `none`. 310 `json-file` logging driver. 311 - **CgroupParent** - Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist. 312 313 **Query parameters**: 314 315 - **name** – Assign the specified name to the container. Must 316 match `/?[a-zA-Z0-9_-]+`. 317 318 **Status codes**: 319 320 - **201** – no error 321 - **400** – bad parameter 322 - **404** – no such container 323 - **406** – impossible to attach (container not running) 324 - **409** – conflict 325 - **500** – server error 326 327 ### Inspect a container 328 329 `GET /containers/(id or name)/json` 330 331 Return low-level information on the container `id` 332 333 **Example request**: 334 335 GET /containers/4fa6e0f0c678/json HTTP/1.1 336 337 **Example response**: 338 339 HTTP/1.1 200 OK 340 Content-Type: application/json 341 342 { 343 "AppArmorProfile": "", 344 "Args": [ 345 "-c", 346 "exit 9" 347 ], 348 "Config": { 349 "AttachStderr": true, 350 "AttachStdin": false, 351 "AttachStdout": true, 352 "Cmd": [ 353 "/bin/sh", 354 "-c", 355 "exit 9" 356 ], 357 "Domainname": "", 358 "Entrypoint": null, 359 "Env": [ 360 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 361 ], 362 "ExposedPorts": null, 363 "Hostname": "ba033ac44011", 364 "Image": "ubuntu", 365 "Labels": { 366 "com.example.vendor": "Acme", 367 "com.example.license": "GPL", 368 "com.example.version": "1.0" 369 }, 370 "MacAddress": "", 371 "NetworkDisabled": false, 372 "OnBuild": null, 373 "OpenStdin": false, 374 "StdinOnce": false, 375 "Tty": false, 376 "User": "", 377 "Volumes": null, 378 "WorkingDir": "" 379 }, 380 "Created": "2015-01-06T15:47:31.485331387Z", 381 "Driver": "devicemapper", 382 "ExecDriver": "native-0.2", 383 "ExecIDs": null, 384 "HostConfig": { 385 "Binds": null, 386 "BlkioWeight": 0, 387 "CapAdd": null, 388 "CapDrop": null, 389 "ContainerIDFile": "", 390 "CpusetCpus": "", 391 "CpusetMems": "", 392 "CpuShares": 0, 393 "CpuPeriod": 100000, 394 "Devices": [], 395 "Dns": null, 396 "DnsSearch": null, 397 "ExtraHosts": null, 398 "IpcMode": "", 399 "Links": null, 400 "LxcConf": [], 401 "Memory": 0, 402 "MemorySwap": 0, 403 "OomKillDisable": false, 404 "NetworkMode": "bridge", 405 "PidMode": "", 406 "PortBindings": {}, 407 "Privileged": false, 408 "ReadonlyRootfs": false, 409 "PublishAllPorts": false, 410 "RestartPolicy": { 411 "MaximumRetryCount": 2, 412 "Name": "on-failure" 413 }, 414 "LogConfig": { 415 "Config": null, 416 "Type": "json-file" 417 }, 418 "SecurityOpt": null, 419 "VolumesFrom": null, 420 "Ulimits": [{}] 421 }, 422 "HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname", 423 "HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts", 424 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log", 425 "Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39", 426 "Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2", 427 "MountLabel": "", 428 "Name": "/boring_euclid", 429 "NetworkSettings": { 430 "Bridge": "", 431 "Gateway": "", 432 "IPAddress": "", 433 "IPPrefixLen": 0, 434 "MacAddress": "", 435 "PortMapping": null, 436 "Ports": null 437 }, 438 "Path": "/bin/sh", 439 "ProcessLabel": "", 440 "ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf", 441 "RestartCount": 1, 442 "State": { 443 "Error": "", 444 "ExitCode": 9, 445 "FinishedAt": "2015-01-06T15:47:32.080254511Z", 446 "OOMKilled": false, 447 "Paused": false, 448 "Pid": 0, 449 "Restarting": false, 450 "Running": true, 451 "StartedAt": "2015-01-06T15:47:32.072697474Z" 452 }, 453 "Mounts": [ 454 { 455 "Source": "/data", 456 "Destination": "/data", 457 "Mode": "ro,Z", 458 "RW": false 459 } 460 ] 461 } 462 463 **Status codes**: 464 465 - **200** – no error 466 - **404** – no such container 467 - **500** – server error 468 469 ### List processes running inside a container 470 471 `GET /containers/(id or name)/top` 472 473 List processes running inside the container `id`. On Unix systems this 474 is done by running the `ps` command. This endpoint is not 475 supported on Windows. 476 477 **Example request**: 478 479 GET /containers/4fa6e0f0c678/top HTTP/1.1 480 481 **Example response**: 482 483 HTTP/1.1 200 OK 484 Content-Type: application/json 485 486 { 487 "Titles" : [ 488 "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD" 489 ], 490 "Processes" : [ 491 [ 492 "root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash" 493 ], 494 [ 495 "root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10" 496 ] 497 ] 498 } 499 500 **Example request**: 501 502 GET /containers/4fa6e0f0c678/top?ps_args=aux HTTP/1.1 503 504 **Example response**: 505 506 HTTP/1.1 200 OK 507 Content-Type: application/json 508 509 { 510 "Titles" : [ 511 "USER","PID","%CPU","%MEM","VSZ","RSS","TTY","STAT","START","TIME","COMMAND" 512 ] 513 "Processes" : [ 514 [ 515 "root","13642","0.0","0.1","18172","3184","pts/0","Ss","17:03","0:00","/bin/bash" 516 ], 517 [ 518 "root","13895","0.0","0.0","4348","692","pts/0","S+","17:15","0:00","sleep 10" 519 ] 520 ], 521 } 522 523 **Query parameters**: 524 525 - **ps_args** – `ps` arguments to use (e.g., `aux`), defaults to `-ef` 526 527 **Status codes**: 528 529 - **200** – no error 530 - **404** – no such container 531 - **500** – server error 532 533 ### Get container logs 534 535 `GET /containers/(id or name)/logs` 536 537 Get `stdout` and `stderr` logs from the container ``id`` 538 539 > **Note**: 540 > This endpoint works only for containers with the `json-file` or `journald` logging drivers. 541 542 **Example request**: 543 544 GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1 545 546 **Example response**: 547 548 HTTP/1.1 101 UPGRADED 549 Content-Type: application/vnd.docker.raw-stream 550 Connection: Upgrade 551 Upgrade: tcp 552 553 {% raw %} 554 {{ STREAM }} 555 {% endraw %} 556 557 **Query parameters**: 558 559 - **follow** – 1/True/true or 0/False/false, return stream. Default `false`. 560 - **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`. 561 - **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`. 562 - **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp 563 will only output log-entries since that timestamp. Default: 0 (unfiltered) 564 - **timestamps** – 1/True/true or 0/False/false, print timestamps for 565 every log line. Default `false`. 566 - **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all. 567 568 **Status codes**: 569 570 - **101** – no error, hints proxy about hijacking 571 - **200** – no error, no upgrade header found 572 - **404** – no such container 573 - **500** – server error 574 575 ### Inspect changes on a container's filesystem 576 577 `GET /containers/(id or name)/changes` 578 579 Inspect changes on container `id`'s filesystem 580 581 **Example request**: 582 583 GET /containers/4fa6e0f0c678/changes HTTP/1.1 584 585 **Example response**: 586 587 HTTP/1.1 200 OK 588 Content-Type: application/json 589 590 [ 591 { 592 "Path": "/dev", 593 "Kind": 0 594 }, 595 { 596 "Path": "/dev/kmsg", 597 "Kind": 1 598 }, 599 { 600 "Path": "/test", 601 "Kind": 1 602 } 603 ] 604 605 Values for `Kind`: 606 607 - `0`: Modify 608 - `1`: Add 609 - `2`: Delete 610 611 **Status codes**: 612 613 - **200** – no error 614 - **404** – no such container 615 - **500** – server error 616 617 ### Export a container 618 619 `GET /containers/(id or name)/export` 620 621 Export the contents of container `id` 622 623 **Example request**: 624 625 GET /containers/4fa6e0f0c678/export HTTP/1.1 626 627 **Example response**: 628 629 HTTP/1.1 200 OK 630 Content-Type: application/octet-stream 631 632 {% raw %} 633 {{ TAR STREAM }} 634 {% endraw %} 635 636 **Status codes**: 637 638 - **200** – no error 639 - **404** – no such container 640 - **500** – server error 641 642 ### Get container stats based on resource usage 643 644 `GET /containers/(id or name)/stats` 645 646 This endpoint returns a live stream of a container's resource usage statistics. 647 648 **Example request**: 649 650 GET /containers/redis1/stats HTTP/1.1 651 652 **Example response**: 653 654 HTTP/1.1 200 OK 655 Content-Type: application/json 656 657 { 658 "read" : "2015-01-08T22:57:31.547920715Z", 659 "network" : { 660 "rx_dropped" : 0, 661 "rx_bytes" : 648, 662 "rx_errors" : 0, 663 "tx_packets" : 8, 664 "tx_dropped" : 0, 665 "rx_packets" : 8, 666 "tx_errors" : 0, 667 "tx_bytes" : 648 668 }, 669 "memory_stats" : { 670 "stats" : { 671 "total_pgmajfault" : 0, 672 "cache" : 0, 673 "mapped_file" : 0, 674 "total_inactive_file" : 0, 675 "pgpgout" : 414, 676 "rss" : 6537216, 677 "total_mapped_file" : 0, 678 "writeback" : 0, 679 "unevictable" : 0, 680 "pgpgin" : 477, 681 "total_unevictable" : 0, 682 "pgmajfault" : 0, 683 "total_rss" : 6537216, 684 "total_rss_huge" : 6291456, 685 "total_writeback" : 0, 686 "total_inactive_anon" : 0, 687 "rss_huge" : 6291456, 688 "hierarchical_memory_limit" : 67108864, 689 "total_pgfault" : 964, 690 "total_active_file" : 0, 691 "active_anon" : 6537216, 692 "total_active_anon" : 6537216, 693 "total_pgpgout" : 414, 694 "total_cache" : 0, 695 "inactive_anon" : 0, 696 "active_file" : 0, 697 "pgfault" : 964, 698 "inactive_file" : 0, 699 "total_pgpgin" : 477 700 }, 701 "max_usage" : 6651904, 702 "usage" : 6537216, 703 "failcnt" : 0, 704 "limit" : 67108864 705 }, 706 "blkio_stats" : {}, 707 "cpu_stats" : { 708 "cpu_usage" : { 709 "percpu_usage" : [ 710 8646879, 711 24472255, 712 36438778, 713 30657443 714 ], 715 "usage_in_usermode" : 50000000, 716 "total_usage" : 100215355, 717 "usage_in_kernelmode" : 30000000 718 }, 719 "system_cpu_usage" : 739306590000000, 720 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0} 721 }, 722 "precpu_stats" : { 723 "cpu_usage" : { 724 "percpu_usage" : [ 725 8646879, 726 24350896, 727 36438778, 728 30657443 729 ], 730 "usage_in_usermode" : 50000000, 731 "total_usage" : 100093996, 732 "usage_in_kernelmode" : 30000000 733 }, 734 "system_cpu_usage" : 9492140000000, 735 "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0} 736 } 737 } 738 739 The precpu_stats is the cpu statistic of last read, which is used for calculating the cpu usage percent. It is not the exact copy of the “cpu_stats” field. 740 741 **Query parameters**: 742 743 - **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`. 744 745 **Status codes**: 746 747 - **200** – no error 748 - **404** – no such container 749 - **500** – server error 750 751 ### Resize a container TTY 752 753 `POST /containers/(id or name)/resize?h=<height>&w=<width>` 754 755 Resize the TTY for container with `id`. You must restart the container for the resize to take effect. 756 757 **Example request**: 758 759 POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1 760 761 **Example response**: 762 763 HTTP/1.1 200 OK 764 Content-Length: 0 765 Content-Type: text/plain; charset=utf-8 766 767 **Query parameters**: 768 769 - **h** – height of `tty` session 770 - **w** – width 771 772 **Status codes**: 773 774 - **200** – no error 775 - **404** – No such container 776 - **500** – Cannot resize container 777 778 ### Start a container 779 780 `POST /containers/(id or name)/start` 781 782 Start the container `id` 783 784 > **Note**: 785 > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body. 786 > See [create a container](#create-a-container) for details. 787 788 **Example request**: 789 790 POST /containers/e90e34656806/start HTTP/1.1 791 792 **Example response**: 793 794 HTTP/1.1 204 No Content 795 796 **Status codes**: 797 798 - **204** – no error 799 - **304** – container already started 800 - **404** – no such container 801 - **500** – server error 802 803 ### Stop a container 804 805 `POST /containers/(id or name)/stop` 806 807 Stop the container `id` 808 809 **Example request**: 810 811 POST /containers/e90e34656806/stop?t=5 HTTP/1.1 812 813 **Example response**: 814 815 HTTP/1.1 204 No Content 816 817 **Query parameters**: 818 819 - **t** – number of seconds to wait before killing the container 820 821 **Status codes**: 822 823 - **204** – no error 824 - **304** – container already stopped 825 - **404** – no such container 826 - **500** – server error 827 828 ### Restart a container 829 830 `POST /containers/(id or name)/restart` 831 832 Restart the container `id` 833 834 **Example request**: 835 836 POST /containers/e90e34656806/restart?t=5 HTTP/1.1 837 838 **Example response**: 839 840 HTTP/1.1 204 No Content 841 842 **Query parameters**: 843 844 - **t** – number of seconds to wait before killing the container 845 846 **Status codes**: 847 848 - **204** – no error 849 - **404** – no such container 850 - **500** – server error 851 852 ### Kill a container 853 854 `POST /containers/(id or name)/kill` 855 856 Kill the container `id` 857 858 **Example request**: 859 860 POST /containers/e90e34656806/kill HTTP/1.1 861 862 **Example response**: 863 864 HTTP/1.1 204 No Content 865 866 **Query parameters**: 867 868 - **signal** - Signal to send to the container: integer or string like `SIGINT`. 869 When not set, `SIGKILL` is assumed and the call waits for the container to exit. 870 871 **Status codes**: 872 873 - **204** – no error 874 - **404** – no such container 875 - **500** – server error 876 877 ### Rename a container 878 879 `POST /containers/(id or name)/rename` 880 881 Rename the container `id` to a `new_name` 882 883 **Example request**: 884 885 POST /containers/e90e34656806/rename?name=new_name HTTP/1.1 886 887 **Example response**: 888 889 HTTP/1.1 204 No Content 890 891 **Query parameters**: 892 893 - **name** – new name for the container 894 895 **Status codes**: 896 897 - **204** – no error 898 - **404** – no such container 899 - **409** - conflict name already assigned 900 - **500** – server error 901 902 ### Pause a container 903 904 `POST /containers/(id or name)/pause` 905 906 Pause the container `id` 907 908 **Example request**: 909 910 POST /containers/e90e34656806/pause HTTP/1.1 911 912 **Example response**: 913 914 HTTP/1.1 204 No Content 915 916 **Status codes**: 917 918 - **204** – no error 919 - **404** – no such container 920 - **500** – server error 921 922 ### Unpause a container 923 924 `POST /containers/(id or name)/unpause` 925 926 Unpause the container `id` 927 928 **Example request**: 929 930 POST /containers/e90e34656806/unpause HTTP/1.1 931 932 **Example response**: 933 934 HTTP/1.1 204 No Content 935 936 **Status codes**: 937 938 - **204** – no error 939 - **404** – no such container 940 - **500** – server error 941 942 ### Attach to a container 943 944 `POST /containers/(id or name)/attach` 945 946 Attach to the container `id` 947 948 **Example request**: 949 950 POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1 951 952 **Example response**: 953 954 HTTP/1.1 101 UPGRADED 955 Content-Type: application/vnd.docker.raw-stream 956 Connection: Upgrade 957 Upgrade: tcp 958 959 {% raw %} 960 {{ STREAM }} 961 {% endraw %} 962 963 **Query parameters**: 964 965 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`. 966 - **stream** – 1/True/true or 0/False/false, return stream. 967 Default `false`. 968 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach 969 to `stdin`. Default `false`. 970 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return 971 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`. 972 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return 973 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`. 974 975 **Status codes**: 976 977 - **101** – no error, hints proxy about hijacking 978 - **200** – no error, no upgrade header found 979 - **400** – bad parameter 980 - **404** – no such container 981 - **500** – server error 982 983 **Stream details**: 984 985 When using the TTY setting is enabled in 986 [`POST /containers/create` 987 ](#create-a-container), 988 the stream is the raw data from the process PTY and client's `stdin`. 989 When the TTY is disabled, then the stream is multiplexed to separate 990 `stdout` and `stderr`. 991 992 The format is a **Header** and a **Payload** (frame). 993 994 **HEADER** 995 996 The header contains the information which the stream writes (`stdout` or 997 `stderr`). It also contains the size of the associated frame encoded in the 998 last four bytes (`uint32`). 999 1000 It is encoded on the first eight bytes like this: 1001 1002 header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} 1003 1004 `STREAM_TYPE` can be: 1005 1006 - 0: `stdin` (is written on `stdout`) 1007 - 1: `stdout` 1008 - 2: `stderr` 1009 1010 `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of 1011 the `uint32` size encoded as big endian. 1012 1013 **PAYLOAD** 1014 1015 The payload is the raw stream. 1016 1017 **IMPLEMENTATION** 1018 1019 The simplest way to implement the Attach protocol is the following: 1020 1021 1. Read eight bytes. 1022 2. Choose `stdout` or `stderr` depending on the first byte. 1023 3. Extract the frame size from the last four bytes. 1024 4. Read the extracted size and output it on the correct output. 1025 5. Goto 1. 1026 1027 ### Attach to a container (websocket) 1028 1029 `GET /containers/(id or name)/attach/ws` 1030 1031 Attach to the container `id` via websocket 1032 1033 Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455) 1034 1035 **Example request** 1036 1037 GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1 1038 1039 **Example response** 1040 1041 {% raw %} 1042 {{ STREAM }} 1043 {% endraw %} 1044 1045 **Query parameters**: 1046 1047 - **logs** – 1/True/true or 0/False/false, return logs. Default `false`. 1048 - **stream** – 1/True/true or 0/False/false, return stream. 1049 Default `false`. 1050 - **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach 1051 to `stdin`. Default `false`. 1052 - **stdout** – 1/True/true or 0/False/false, if `logs=true`, return 1053 `stdout` log, if `stream=true`, attach to `stdout`. Default `false`. 1054 - **stderr** – 1/True/true or 0/False/false, if `logs=true`, return 1055 `stderr` log, if `stream=true`, attach to `stderr`. Default `false`. 1056 1057 **Status codes**: 1058 1059 - **200** – no error 1060 - **400** – bad parameter 1061 - **404** – no such container 1062 - **500** – server error 1063 1064 ### Wait a container 1065 1066 `POST /containers/(id or name)/wait` 1067 1068 Block until container `id` stops, then returns the exit code 1069 1070 **Example request**: 1071 1072 POST /containers/16253994b7c4/wait HTTP/1.1 1073 1074 **Example response**: 1075 1076 HTTP/1.1 200 OK 1077 Content-Type: application/json 1078 1079 {"StatusCode": 0} 1080 1081 **Status codes**: 1082 1083 - **200** – no error 1084 - **404** – no such container 1085 - **500** – server error 1086 1087 ### Remove a container 1088 1089 `DELETE /containers/(id or name)` 1090 1091 Remove the container `id` from the filesystem 1092 1093 **Example request**: 1094 1095 DELETE /containers/16253994b7c4?v=1 HTTP/1.1 1096 1097 **Example response**: 1098 1099 HTTP/1.1 204 No Content 1100 1101 **Query parameters**: 1102 1103 - **v** – 1/True/true or 0/False/false, Remove the volumes 1104 associated to the container. Default `false`. 1105 - **force** - 1/True/true or 0/False/false, Kill then remove the container. 1106 Default `false`. 1107 1108 **Status codes**: 1109 1110 - **204** – no error 1111 - **400** – bad parameter 1112 - **404** – no such container 1113 - **409** – conflict 1114 - **500** – server error 1115 1116 ### Copy files or folders from a container 1117 1118 `POST /containers/(id or name)/copy` 1119 1120 Copy files or folders of container `id` 1121 1122 **Deprecated** in favor of the `archive` endpoint below. 1123 1124 **Example request**: 1125 1126 POST /containers/4fa6e0f0c678/copy HTTP/1.1 1127 Content-Type: application/json 1128 1129 { 1130 "Resource": "test.txt" 1131 } 1132 1133 **Example response**: 1134 1135 HTTP/1.1 200 OK 1136 Content-Type: application/x-tar 1137 1138 {% raw %} 1139 {{ TAR STREAM }} 1140 {% endraw %} 1141 1142 **Status codes**: 1143 1144 - **200** – no error 1145 - **404** – no such container 1146 - **500** – server error 1147 1148 ### Retrieving information about files and folders in a container 1149 1150 `HEAD /containers/(id or name)/archive` 1151 1152 See the description of the `X-Docker-Container-Path-Stat` header in the 1153 following section. 1154 1155 ### Get an archive of a filesystem resource in a container 1156 1157 `GET /containers/(id or name)/archive` 1158 1159 Get a tar archive of a resource in the filesystem of container `id`. 1160 1161 **Query parameters**: 1162 1163 - **path** - resource in the container's filesystem to archive. Required. 1164 1165 If not an absolute path, it is relative to the container's root directory. 1166 The resource specified by **path** must exist. To assert that the resource 1167 is expected to be a directory, **path** should end in `/` or `/.` 1168 (assuming a path separator of `/`). If **path** ends in `/.` then this 1169 indicates that only the contents of the **path** directory should be 1170 copied. A symlink is always resolved to its target. 1171 1172 > **Note**: It is not possible to copy certain system files such as resources 1173 > under `/proc`, `/sys`, `/dev`, and mounts created by the user in the 1174 > container. 1175 1176 **Example request**: 1177 1178 GET /containers/8cce319429b2/archive?path=/root HTTP/1.1 1179 1180 **Example response**: 1181 1182 HTTP/1.1 200 OK 1183 Content-Type: application/x-tar 1184 X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= 1185 1186 {% raw %} 1187 {{ TAR STREAM }} 1188 {% endraw %} 1189 1190 On success, a response header `X-Docker-Container-Path-Stat` will be set to a 1191 base64-encoded JSON object containing some filesystem header information about 1192 the archived resource. The above example value would decode to the following 1193 JSON object (whitespace added for readability): 1194 1195 ```json 1196 { 1197 "name": "root", 1198 "size": 4096, 1199 "mode": 2147484096, 1200 "mtime": "2014-02-27T20:51:23Z", 1201 "linkTarget": "" 1202 } 1203 ``` 1204 1205 A `HEAD` request can also be made to this endpoint if only this information is 1206 desired. 1207 1208 **Status codes**: 1209 1210 - **200** - success, returns archive of copied resource 1211 - **400** - client error, bad parameter, details in JSON response body, one of: 1212 - must specify path parameter (**path** cannot be empty) 1213 - not a directory (**path** was asserted to be a directory but exists as a 1214 file) 1215 - **404** - client error, resource not found, one of: 1216 – no such container (container `id` does not exist) 1217 - no such file or directory (**path** does not exist) 1218 - **500** - server error 1219 1220 ### Extract an archive of files or folders to a directory in a container 1221 1222 `PUT /containers/(id or name)/archive` 1223 1224 Upload a tar archive to be extracted to a path in the filesystem of container 1225 `id`. 1226 1227 **Query parameters**: 1228 1229 - **path** - path to a directory in the container 1230 to extract the archive's contents into. Required. 1231 1232 If not an absolute path, it is relative to the container's root directory. 1233 The **path** resource must exist. 1234 - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error 1235 if unpacking the given content would cause an existing directory to be 1236 replaced with a non-directory and vice versa. 1237 1238 **Example request**: 1239 1240 PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 1241 Content-Type: application/x-tar 1242 1243 {% raw %} 1244 {{ TAR STREAM }} 1245 {% endraw %} 1246 1247 **Example response**: 1248 1249 HTTP/1.1 200 OK 1250 1251 **Status codes**: 1252 1253 - **200** – the content was extracted successfully 1254 - **400** - client error, bad parameter, details in JSON response body, one of: 1255 - must specify path parameter (**path** cannot be empty) 1256 - not a directory (**path** should be a directory but exists as a file) 1257 - unable to overwrite existing directory with non-directory 1258 (if **noOverwriteDirNonDir**) 1259 - unable to overwrite existing non-directory with directory 1260 (if **noOverwriteDirNonDir**) 1261 - **403** - client error, permission denied, the volume 1262 or container rootfs is marked as read-only. 1263 - **404** - client error, resource not found, one of: 1264 – no such container (container `id` does not exist) 1265 - no such file or directory (**path** resource does not exist) 1266 - **500** – server error 1267 1268 ## 2.2 Images 1269 1270 ### List Images 1271 1272 `GET /images/json` 1273 1274 **Example request**: 1275 1276 GET /images/json?all=0 HTTP/1.1 1277 1278 **Example response**: 1279 1280 HTTP/1.1 200 OK 1281 Content-Type: application/json 1282 1283 [ 1284 { 1285 "RepoTags": [ 1286 "ubuntu:12.04", 1287 "ubuntu:precise", 1288 "ubuntu:latest" 1289 ], 1290 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 1291 "Created": 1365714795, 1292 "Size": 131506275, 1293 "VirtualSize": 131506275, 1294 "Labels": {} 1295 }, 1296 { 1297 "RepoTags": [ 1298 "ubuntu:12.10", 1299 "ubuntu:quantal" 1300 ], 1301 "ParentId": "27cf784147099545", 1302 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1303 "Created": 1364102658, 1304 "Size": 24653, 1305 "VirtualSize": 180116135, 1306 "Labels": { 1307 "com.example.version": "v1" 1308 } 1309 } 1310 ] 1311 1312 **Example request, with digest information**: 1313 1314 GET /images/json?digests=1 HTTP/1.1 1315 1316 **Example response, with digest information**: 1317 1318 HTTP/1.1 200 OK 1319 Content-Type: application/json 1320 1321 [ 1322 { 1323 "Created": 1420064636, 1324 "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125", 1325 "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2", 1326 "RepoDigests": [ 1327 "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" 1328 ], 1329 "RepoTags": [ 1330 "localhost:5000/test/busybox:latest", 1331 "playdate:latest" 1332 ], 1333 "Size": 0, 1334 "VirtualSize": 2429728, 1335 "Labels": {} 1336 } 1337 ] 1338 1339 The response shows a single image `Id` associated with two repositories 1340 (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use 1341 either of the `RepoTags` values `localhost:5000/test/busybox:latest` or 1342 `playdate:latest` to reference the image. 1343 1344 You can also use `RepoDigests` values to reference an image. In this response, 1345 the array has only one reference and that is to the 1346 `localhost:5000/test/busybox` repository; the `playdate` repository has no 1347 digest. You can reference this digest using the value: 1348 `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...` 1349 1350 See the `docker run` and `docker build` commands for examples of digest and tag 1351 references on the command line. 1352 1353 **Query parameters**: 1354 1355 - **all** – 1/True/true or 0/False/false, default false 1356 - **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters: 1357 - `dangling=true` 1358 - `label=key` or `label="key=value"` of an image label 1359 - **filter** - only return images with the specified name 1360 1361 ### Build image from a Dockerfile 1362 1363 `POST /build` 1364 1365 Build an image from a Dockerfile 1366 1367 **Example request**: 1368 1369 POST /build HTTP/1.1 1370 1371 {% raw %} 1372 {{ TAR STREAM }} 1373 {% endraw %} 1374 1375 **Example response**: 1376 1377 HTTP/1.1 200 OK 1378 Content-Type: application/json 1379 1380 {"stream": "Step 1..."} 1381 {"stream": "..."} 1382 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 1383 1384 The input stream must be a `tar` archive compressed with one of the 1385 following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`. 1386 1387 The archive must include a build instructions file, typically called 1388 `Dockerfile` at the archive's root. The `dockerfile` parameter may be 1389 used to specify a different build instructions file. To do this, its value must be 1390 the path to the alternate build instructions file to use. 1391 1392 The archive may include any number of other files, 1393 which are accessible in the build context (See the [*ADD build 1394 command*](../../reference/builder.md#add)). 1395 1396 The Docker daemon performs a preliminary validation of the `Dockerfile` before 1397 starting the build, and returns an error if the syntax is incorrect. After that, 1398 each instruction is run one-by-one until the ID of the new image is output. 1399 1400 The build is canceled if the client drops the connection by quitting 1401 or being killed. 1402 1403 **Query parameters**: 1404 1405 - **dockerfile** - Path within the build context to the `Dockerfile`. This is 1406 ignored if `remote` is specified and points to an external `Dockerfile`. 1407 - **t** – A name and optional tag to apply to the image in the `name:tag` format. 1408 If you omit the `tag` the default `latest` value is assumed. 1409 - **remote** – A Git repository URI or HTTP/HTTPS context URI. If the 1410 URI points to a single text file, the file's contents are placed into 1411 a file called `Dockerfile` and the image is built from that file. If 1412 the URI points to a tarball, the file is downloaded by the daemon and 1413 the contents therein used as the context for the build. If the URI 1414 points to a tarball and the `dockerfile` parameter is also specified, 1415 there must be a file with the corresponding path inside the tarball. 1416 - **q** – Suppress verbose build output. 1417 - **nocache** – Do not use the cache when building the image. 1418 - **pull** - Attempt to pull the image even if an older image exists locally. 1419 - **rm** - Remove intermediate containers after a successful build (default behavior). 1420 - **forcerm** - Always remove intermediate containers (includes `rm`). 1421 - **memory** - Set memory limit for build. 1422 - **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap. 1423 - **cpushares** - CPU shares (relative weight). 1424 - **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`). 1425 - **cpuperiod** - The length of a CPU period in microseconds. 1426 - **cpuquota** - Microseconds of CPU time that the container can get in a CPU period. 1427 1428 **Request Headers**: 1429 1430 - **Content-type** – Set to `"application/tar"`. 1431 - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON 1432 object with the following structure: 1433 1434 { 1435 "docker.example.com": { 1436 "username": "janedoe", 1437 "password": "hunter2" 1438 }, 1439 "https://index.docker.io/v1/": { 1440 "username": "mobydock", 1441 "password": "conta1n3rize14" 1442 } 1443 } 1444 1445 This object maps the hostname of a registry to an object containing the 1446 "username" and "password" for that registry. Multiple registries may 1447 be specified as the build may be based on an image requiring 1448 authentication to pull from any arbitrary registry. Only the registry 1449 domain name (and port if not the default "443") are required. However 1450 (for legacy reasons) the "official" Docker, Inc. hosted registry must 1451 be specified with both a "https://" prefix and a "/v1/" suffix even 1452 though Docker will prefer to use the v2 registry API. 1453 1454 **Status codes**: 1455 1456 - **200** – no error 1457 - **500** – server error 1458 1459 ### Create an image 1460 1461 `POST /images/create` 1462 1463 Create an image either by pulling it from the registry or by importing it 1464 1465 **Example request**: 1466 1467 POST /images/create?fromImage=busybox&tag=latest HTTP/1.1 1468 1469 **Example response**: 1470 1471 HTTP/1.1 200 OK 1472 Content-Type: application/json 1473 1474 {"status": "Pulling..."} 1475 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 1476 {"error": "Invalid..."} 1477 ... 1478 1479 When using this endpoint to pull an image from the registry, the 1480 `X-Registry-Auth` header can be used to include 1481 a base64-encoded AuthConfig object. 1482 1483 **Query parameters**: 1484 1485 - **fromImage** – Name of the image to pull. 1486 - **fromSrc** – Source to import. The value may be a URL from which the image 1487 can be retrieved or `-` to read the image from the request body. 1488 - **repo** – Repository name. 1489 - **tag** – Tag. If empty when pulling an image, this causes all tags 1490 for the given image to be pulled. 1491 1492 **Request Headers**: 1493 1494 - **X-Registry-Auth** – base64-encoded AuthConfig object 1495 1496 **Status codes**: 1497 1498 - **200** – no error 1499 - **500** – server error 1500 1501 1502 1503 ### Inspect an image 1504 1505 `GET /images/(name)/json` 1506 1507 Return low-level information on the image `name` 1508 1509 **Example request**: 1510 1511 GET /images/ubuntu/json HTTP/1.1 1512 1513 **Example response**: 1514 1515 HTTP/1.1 200 OK 1516 Content-Type: application/json 1517 1518 { 1519 "Created": "2013-03-23T22:24:18.818426-07:00", 1520 "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0", 1521 "ContainerConfig": { 1522 "Hostname": "", 1523 "User": "", 1524 "AttachStdin": false, 1525 "AttachStdout": false, 1526 "AttachStderr": false, 1527 "Tty": true, 1528 "OpenStdin": true, 1529 "StdinOnce": false, 1530 "Env": null, 1531 "Cmd": ["/bin/bash"], 1532 "Dns": null, 1533 "Image": "ubuntu", 1534 "Labels": { 1535 "com.example.vendor": "Acme", 1536 "com.example.license": "GPL", 1537 "com.example.version": "1.0" 1538 }, 1539 "Volumes": null, 1540 "VolumesFrom": "", 1541 "WorkingDir": "" 1542 }, 1543 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1544 "Parent": "27cf784147099545", 1545 "Size": 6824592 1546 } 1547 1548 **Status codes**: 1549 1550 - **200** – no error 1551 - **404** – no such image 1552 - **500** – server error 1553 1554 ### Get the history of an image 1555 1556 `GET /images/(name)/history` 1557 1558 Return the history of the image `name` 1559 1560 **Example request**: 1561 1562 GET /images/ubuntu/history HTTP/1.1 1563 1564 **Example response**: 1565 1566 HTTP/1.1 200 OK 1567 Content-Type: application/json 1568 1569 [ 1570 { 1571 "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710", 1572 "Created": 1398108230, 1573 "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /", 1574 "Tags": [ 1575 "ubuntu:lucid", 1576 "ubuntu:10.04" 1577 ], 1578 "Size": 182964289, 1579 "Comment": "" 1580 }, 1581 { 1582 "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8", 1583 "Created": 1398108222, 1584 "CreatedBy": "/bin/sh -c #(nop) MAINTAINER Tianon Gravi <admwiggin@gmail.com> - mkimage-debootstrap.sh -i iproute,iputils-ping,ubuntu-minimal -t lucid.tar.xz lucid http://archive.ubuntu.com/ubuntu/", 1585 "Tags": null, 1586 "Size": 0, 1587 "Comment": "" 1588 }, 1589 { 1590 "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158", 1591 "Created": 1371157430, 1592 "CreatedBy": "", 1593 "Tags": [ 1594 "scratch12:latest", 1595 "scratch:latest" 1596 ], 1597 "Size": 0, 1598 "Comment": "Imported from -" 1599 } 1600 ] 1601 1602 **Status codes**: 1603 1604 - **200** – no error 1605 - **404** – no such image 1606 - **500** – server error 1607 1608 ### Push an image on the registry 1609 1610 `POST /images/(name)/push` 1611 1612 Push the image `name` on the registry 1613 1614 **Example request**: 1615 1616 POST /images/test/push HTTP/1.1 1617 1618 **Example response**: 1619 1620 HTTP/1.1 200 OK 1621 Content-Type: application/json 1622 1623 {"status": "Pushing..."} 1624 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 1625 {"error": "Invalid..."} 1626 ... 1627 1628 If you wish to push an image on to a private registry, that image must already have a tag 1629 into a repository which references that registry `hostname` and `port`. This repository name should 1630 then be used in the URL. This duplicates the command line's flow. 1631 1632 **Example request**: 1633 1634 POST /images/registry.acme.com:5000/test/push HTTP/1.1 1635 1636 1637 **Query parameters**: 1638 1639 - **tag** – The tag to associate with the image on the registry. This is optional. 1640 1641 **Request Headers**: 1642 1643 - **X-Registry-Auth** – base64-encoded AuthConfig object. 1644 1645 **Status codes**: 1646 1647 - **200** – no error 1648 - **404** – no such image 1649 - **500** – server error 1650 1651 ### Tag an image into a repository 1652 1653 `POST /images/(name)/tag` 1654 1655 Tag the image `name` into a repository 1656 1657 **Example request**: 1658 1659 POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1 1660 1661 **Example response**: 1662 1663 HTTP/1.1 201 Created 1664 1665 **Query parameters**: 1666 1667 - **repo** – The repository to tag in 1668 - **force** – 1/True/true or 0/False/false, default false 1669 - **tag** - The new tag name 1670 1671 **Status codes**: 1672 1673 - **201** – no error 1674 - **400** – bad parameter 1675 - **404** – no such image 1676 - **409** – conflict 1677 - **500** – server error 1678 1679 ### Remove an image 1680 1681 `DELETE /images/(name)` 1682 1683 Remove the image `name` from the filesystem 1684 1685 **Example request**: 1686 1687 DELETE /images/test HTTP/1.1 1688 1689 **Example response**: 1690 1691 HTTP/1.1 200 OK 1692 Content-type: application/json 1693 1694 [ 1695 {"Untagged": "3e2f21a89f"}, 1696 {"Deleted": "3e2f21a89f"}, 1697 {"Deleted": "53b4f83ac9"} 1698 ] 1699 1700 **Query parameters**: 1701 1702 - **force** – 1/True/true or 0/False/false, default false 1703 - **noprune** – 1/True/true or 0/False/false, default false 1704 1705 **Status codes**: 1706 1707 - **200** – no error 1708 - **404** – no such image 1709 - **409** – conflict 1710 - **500** – server error 1711 1712 ### Search images 1713 1714 `GET /images/search` 1715 1716 Search for an image on [Docker Hub](https://hub.docker.com). 1717 1718 > **Note**: 1719 > The response keys have changed from API v1.6 to reflect the JSON 1720 > sent by the registry server to the docker daemon's request. 1721 1722 **Example request**: 1723 1724 GET /images/search?term=sshd HTTP/1.1 1725 1726 **Example response**: 1727 1728 HTTP/1.1 200 OK 1729 Content-Type: application/json 1730 1731 [ 1732 { 1733 "description": "", 1734 "is_official": false, 1735 "is_automated": false, 1736 "name": "wma55/u1210sshd", 1737 "star_count": 0 1738 }, 1739 { 1740 "description": "", 1741 "is_official": false, 1742 "is_automated": false, 1743 "name": "jdswinbank/sshd", 1744 "star_count": 0 1745 }, 1746 { 1747 "description": "", 1748 "is_official": false, 1749 "is_automated": false, 1750 "name": "vgauthier/sshd", 1751 "star_count": 0 1752 } 1753 ... 1754 ] 1755 1756 **Query parameters**: 1757 1758 - **term** – term to search 1759 1760 **Status codes**: 1761 1762 - **200** – no error 1763 - **500** – server error 1764 1765 ## 2.3 Misc 1766 1767 ### Check auth configuration 1768 1769 `POST /auth` 1770 1771 Get the default username and email 1772 1773 **Example request**: 1774 1775 POST /auth HTTP/1.1 1776 Content-Type: application/json 1777 1778 { 1779 "username": "hannibal", 1780 "password": "xxxx", 1781 "email": "hannibal@a-team.com", 1782 "serveraddress": "https://index.docker.io/v1/" 1783 } 1784 1785 **Example response**: 1786 1787 HTTP/1.1 200 OK 1788 1789 **Status codes**: 1790 1791 - **200** – no error 1792 - **204** – no error 1793 - **500** – server error 1794 1795 ### Display system-wide information 1796 1797 `GET /info` 1798 1799 Display system-wide information 1800 1801 **Example request**: 1802 1803 GET /info HTTP/1.1 1804 1805 **Example response**: 1806 1807 HTTP/1.1 200 OK 1808 Content-Type: application/json 1809 1810 { 1811 "Containers": 11, 1812 "CpuCfsPeriod": true, 1813 "CpuCfsQuota": true, 1814 "Debug": false, 1815 "DockerRootDir": "/var/lib/docker", 1816 "Driver": "btrfs", 1817 "DriverStatus": [[""]], 1818 "ExecutionDriver": "native-0.1", 1819 "ExperimentalBuild": false, 1820 "HttpProxy": "http://test:test@localhost:8080", 1821 "HttpsProxy": "https://test:test@localhost:8080", 1822 "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS", 1823 "IPv4Forwarding": true, 1824 "Images": 16, 1825 "IndexServerAddress": "https://index.docker.io/v1/", 1826 "InitPath": "/usr/bin/docker", 1827 "InitSha1": "", 1828 "KernelVersion": "3.12.0-1-amd64", 1829 "Labels": [ 1830 "storage=ssd" 1831 ], 1832 "MemTotal": 2099236864, 1833 "MemoryLimit": true, 1834 "NCPU": 1, 1835 "NEventsListener": 0, 1836 "NFd": 11, 1837 "NGoroutines": 21, 1838 "Name": "prod-server-42", 1839 "NoProxy": "9.81.1.160", 1840 "OomKillDisable": true, 1841 "OperatingSystem": "Boot2Docker", 1842 "RegistryConfig": { 1843 "IndexConfigs": { 1844 "docker.io": { 1845 "Mirrors": null, 1846 "Name": "docker.io", 1847 "Official": true, 1848 "Secure": true 1849 } 1850 }, 1851 "InsecureRegistryCIDRs": [ 1852 "127.0.0.0/8" 1853 ] 1854 }, 1855 "SwapLimit": false, 1856 "SystemTime": "2015-03-10T11:11:23.730591467-07:00" 1857 } 1858 1859 **Status codes**: 1860 1861 - **200** – no error 1862 - **500** – server error 1863 1864 ### Show the docker version information 1865 1866 `GET /version` 1867 1868 Show the docker version information 1869 1870 **Example request**: 1871 1872 GET /version HTTP/1.1 1873 1874 **Example response**: 1875 1876 HTTP/1.1 200 OK 1877 Content-Type: application/json 1878 1879 { 1880 "Version": "1.5.0", 1881 "Os": "linux", 1882 "KernelVersion": "3.18.5-tinycore64", 1883 "GoVersion": "go1.4.1", 1884 "GitCommit": "a8a31ef", 1885 "Arch": "amd64", 1886 "ApiVersion": "1.20", 1887 "Experimental": false 1888 } 1889 1890 **Status codes**: 1891 1892 - **200** – no error 1893 - **500** – server error 1894 1895 ### Ping the docker server 1896 1897 `GET /_ping` 1898 1899 Ping the docker server 1900 1901 **Example request**: 1902 1903 GET /_ping HTTP/1.1 1904 1905 **Example response**: 1906 1907 HTTP/1.1 200 OK 1908 Content-Type: text/plain 1909 1910 OK 1911 1912 **Status codes**: 1913 1914 - **200** - no error 1915 - **500** - server error 1916 1917 ### Create a new image from a container's changes 1918 1919 `POST /commit` 1920 1921 Create a new image from a container's changes 1922 1923 **Example request**: 1924 1925 POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1 1926 Content-Type: application/json 1927 1928 { 1929 "Hostname": "", 1930 "Domainname": "", 1931 "User": "", 1932 "AttachStdin": false, 1933 "AttachStdout": true, 1934 "AttachStderr": true, 1935 "Tty": false, 1936 "OpenStdin": false, 1937 "StdinOnce": false, 1938 "Env": null, 1939 "Cmd": [ 1940 "date" 1941 ], 1942 "Mounts": [ 1943 { 1944 "Source": "/data", 1945 "Destination": "/data", 1946 "Mode": "ro,Z", 1947 "RW": false 1948 } 1949 ], 1950 "Labels": { 1951 "key1": "value1", 1952 "key2": "value2" 1953 }, 1954 "WorkingDir": "", 1955 "NetworkDisabled": false, 1956 "ExposedPorts": { 1957 "22/tcp": {} 1958 } 1959 } 1960 1961 **Example response**: 1962 1963 HTTP/1.1 201 Created 1964 Content-Type: application/json 1965 1966 {"Id": "596069db4bf5"} 1967 1968 **JSON parameters**: 1969 1970 - **config** - the container's configuration 1971 1972 **Query parameters**: 1973 1974 - **container** – source container 1975 - **repo** – repository 1976 - **tag** – tag 1977 - **comment** – commit message 1978 - **author** – author (e.g., "John Hannibal Smith 1979 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 1980 - **pause** – 1/True/true or 0/False/false, whether to pause the container before committing 1981 - **changes** – Dockerfile instructions to apply while committing 1982 1983 **Status codes**: 1984 1985 - **201** – no error 1986 - **404** – no such container 1987 - **500** – server error 1988 1989 ### Monitor Docker's events 1990 1991 `GET /events` 1992 1993 Get container events from docker, in real time via streaming. 1994 1995 Docker containers report the following events: 1996 1997 attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause 1998 1999 Docker images report the following events: 2000 2001 delete, import, pull, push, tag, untag 2002 2003 **Example request**: 2004 2005 GET /events?since=1374067924 2006 2007 **Example response**: 2008 2009 HTTP/1.1 200 OK 2010 Content-Type: application/json 2011 2012 {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 2013 {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 2014 {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966} 2015 {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970} 2016 2017 **Query parameters**: 2018 2019 - **since** – Timestamp. Show all events created since timestamp and then stream 2020 - **until** – Timestamp. Show events created until given timestamp and stop streaming 2021 - **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters: 2022 - `container=<string>`; -- container to filter 2023 - `event=<string>`; -- event to filter 2024 - `image=<string>`; -- image to filter 2025 2026 **Status codes**: 2027 2028 - **200** – no error 2029 - **500** – server error 2030 2031 ### Get a tarball containing all images in a repository 2032 2033 `GET /images/(name)/get` 2034 2035 Get a tarball containing all images and metadata for the repository specified 2036 by `name`. 2037 2038 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image 2039 (and its parents) are returned. If `name` is an image ID, similarly only that 2040 image (and its parents) are returned, but with the exclusion of the 2041 'repositories' file in the tarball, as there were no image names referenced. 2042 2043 See the [image tarball format](#image-tarball-format) for more details. 2044 2045 **Example request** 2046 2047 GET /images/ubuntu/get 2048 2049 **Example response**: 2050 2051 HTTP/1.1 200 OK 2052 Content-Type: application/x-tar 2053 2054 Binary data stream 2055 2056 **Status codes**: 2057 2058 - **200** – no error 2059 - **500** – server error 2060 2061 ### Get a tarball containing all images 2062 2063 `GET /images/get` 2064 2065 Get a tarball containing all images and metadata for one or more repositories. 2066 2067 For each value of the `names` parameter: if it is a specific name and tag (e.g. 2068 `ubuntu:latest`), then only that image (and its parents) are returned; if it is 2069 an image ID, similarly only that image (and its parents) are returned and there 2070 would be no names referenced in the 'repositories' file for this image ID. 2071 2072 See the [image tarball format](#image-tarball-format) for more details. 2073 2074 **Example request** 2075 2076 GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox 2077 2078 **Example response**: 2079 2080 HTTP/1.1 200 OK 2081 Content-Type: application/x-tar 2082 2083 Binary data stream 2084 2085 **Status codes**: 2086 2087 - **200** – no error 2088 - **500** – server error 2089 2090 ### Load a tarball with a set of images and tags into docker 2091 2092 `POST /images/load` 2093 2094 Load a set of images and tags into a Docker repository. 2095 See the [image tarball format](#image-tarball-format) for more details. 2096 2097 **Example request** 2098 2099 POST /images/load 2100 Content-Type: application/x-tar 2101 2102 Tarball in body 2103 2104 **Example response**: 2105 2106 HTTP/1.1 200 OK 2107 2108 **Status codes**: 2109 2110 - **200** – no error 2111 - **500** – server error 2112 2113 ### Image tarball format 2114 2115 An image tarball contains one directory per image layer (named using its long ID), 2116 each containing these files: 2117 2118 - `VERSION`: currently `1.0` - the file format version 2119 - `json`: detailed layer information, similar to `docker inspect layer_id` 2120 - `layer.tar`: A tarfile containing the filesystem changes in this layer 2121 2122 The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories 2123 for storing attribute changes and deletions. 2124 2125 If the tarball defines a repository, the tarball should also include a `repositories` file at 2126 the root that contains a list of repository and tag names mapped to layer IDs. 2127 2128 ``` 2129 {"hello-world": 2130 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 2131 } 2132 ``` 2133 2134 ### Exec Create 2135 2136 `POST /containers/(id or name)/exec` 2137 2138 Sets up an exec instance in a running container `id` 2139 2140 **Example request**: 2141 2142 POST /containers/e90e34656806/exec HTTP/1.1 2143 Content-Type: application/json 2144 2145 { 2146 "AttachStdin": true, 2147 "AttachStdout": true, 2148 "AttachStderr": true, 2149 "Cmd": ["sh"], 2150 "Tty": true, 2151 "User": "123:456" 2152 } 2153 2154 **Example response**: 2155 2156 HTTP/1.1 201 Created 2157 Content-Type: application/json 2158 2159 { 2160 "Id": "f90e34656806", 2161 "Warnings":[] 2162 } 2163 2164 **JSON parameters**: 2165 2166 - **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command. 2167 - **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command. 2168 - **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command. 2169 - **Tty** - Boolean value to allocate a pseudo-TTY. 2170 - **Cmd** - Command to run specified as a string or an array of strings. 2171 - **User** - A string value specifying the user, and optionally, group to run 2172 the exec process inside the container. Format is one of: `"user"`, 2173 `"user:group"`, `"uid"`, or `"uid:gid"`. 2174 2175 **Status codes**: 2176 2177 - **201** – no error 2178 - **404** – no such container 2179 2180 ### Exec Start 2181 2182 `POST /exec/(id)/start` 2183 2184 Starts a previously set up `exec` instance `id`. If `detach` is true, this API 2185 returns after starting the `exec` command. Otherwise, this API sets up an 2186 interactive session with the `exec` command. 2187 2188 **Example request**: 2189 2190 POST /exec/e90e34656806/start HTTP/1.1 2191 Content-Type: application/json 2192 2193 { 2194 "Detach": false, 2195 "Tty": false 2196 } 2197 2198 **Example response**: 2199 2200 HTTP/1.1 200 OK 2201 Content-Type: application/vnd.docker.raw-stream 2202 2203 {% raw %} 2204 {{ STREAM }} 2205 {% endraw %} 2206 2207 **JSON parameters**: 2208 2209 - **Detach** - Detach from the `exec` command. 2210 - **Tty** - Boolean value to allocate a pseudo-TTY. 2211 2212 **Status codes**: 2213 2214 - **200** – no error 2215 - **404** – no such exec instance 2216 2217 **Stream details**: 2218 2219 Similar to the stream behavior of `POST /containers/(id or name)/attach` API 2220 2221 ### Exec Resize 2222 2223 `POST /exec/(id)/resize` 2224 2225 Resizes the `tty` session used by the `exec` command `id`. The unit is number of characters. 2226 This API is valid only if `tty` was specified as part of creating and starting the `exec` command. 2227 2228 **Example request**: 2229 2230 POST /exec/e90e34656806/resize?h=40&w=80 HTTP/1.1 2231 Content-Type: text/plain 2232 2233 **Example response**: 2234 2235 HTTP/1.1 201 Created 2236 Content-Type: text/plain 2237 2238 **Query parameters**: 2239 2240 - **h** – height of `tty` session 2241 - **w** – width 2242 2243 **Status codes**: 2244 2245 - **201** – no error 2246 - **404** – no such exec instance 2247 2248 ### Exec Inspect 2249 2250 `GET /exec/(id)/json` 2251 2252 Return low-level information about the `exec` command `id`. 2253 2254 **Example request**: 2255 2256 GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1 2257 2258 **Example response**: 2259 2260 HTTP/1.1 200 OK 2261 Content-Type: plain/text 2262 2263 { 2264 "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39", 2265 "Running" : false, 2266 "ExitCode" : 2, 2267 "ProcessConfig" : { 2268 "privileged" : false, 2269 "user" : "", 2270 "tty" : false, 2271 "entrypoint" : "sh", 2272 "arguments" : [ 2273 "-c", 2274 "exit 2" 2275 ] 2276 }, 2277 "OpenStdin" : false, 2278 "OpenStderr" : false, 2279 "OpenStdout" : false, 2280 "Container" : { 2281 "State" : { 2282 "Running" : true, 2283 "Paused" : false, 2284 "Restarting" : false, 2285 "OOMKilled" : false, 2286 "Pid" : 3650, 2287 "ExitCode" : 0, 2288 "Error" : "", 2289 "StartedAt" : "2014-11-17T22:26:03.717657531Z", 2290 "FinishedAt" : "0001-01-01T00:00:00Z" 2291 }, 2292 "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c", 2293 "Created" : "2014-11-17T22:26:03.626304998Z", 2294 "Path" : "date", 2295 "Args" : [], 2296 "Config" : { 2297 "Hostname" : "8f177a186b97", 2298 "Domainname" : "", 2299 "User" : "", 2300 "AttachStdin" : false, 2301 "AttachStdout" : false, 2302 "AttachStderr" : false, 2303 "ExposedPorts" : null, 2304 "Tty" : false, 2305 "OpenStdin" : false, 2306 "StdinOnce" : false, 2307 "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], 2308 "Cmd" : [ 2309 "date" 2310 ], 2311 "Image" : "ubuntu", 2312 "Volumes" : null, 2313 "WorkingDir" : "", 2314 "Entrypoint" : null, 2315 "NetworkDisabled" : false, 2316 "MacAddress" : "", 2317 "OnBuild" : null, 2318 "SecurityOpt" : null 2319 }, 2320 "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5", 2321 "NetworkSettings" : { 2322 "IPAddress" : "172.17.0.2", 2323 "IPPrefixLen" : 16, 2324 "MacAddress" : "02:42:ac:11:00:02", 2325 "Gateway" : "172.17.42.1", 2326 "Bridge" : "docker0", 2327 "PortMapping" : null, 2328 "Ports" : {} 2329 }, 2330 "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf", 2331 "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname", 2332 "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts", 2333 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log", 2334 "Name" : "/test", 2335 "Driver" : "aufs", 2336 "ExecDriver" : "native-0.2", 2337 "MountLabel" : "", 2338 "ProcessLabel" : "", 2339 "AppArmorProfile" : "", 2340 "RestartCount" : 0, 2341 "Mounts" : [] 2342 } 2343 } 2344 2345 **Status codes**: 2346 2347 - **200** – no error 2348 - **404** – no such exec instance 2349 - **500** - server error 2350 2351 # 3. Going further 2352 2353 ## 3.1 Inside `docker run` 2354 2355 As an example, the `docker run` command line makes the following API calls: 2356 2357 - Create the container 2358 2359 - If the status code is 404, it means the image doesn't exist: 2360 - Try to pull it. 2361 - Then, retry to create the container. 2362 2363 - Start the container. 2364 2365 - If you are not in detached mode: 2366 - Attach to the container, using `logs=1` (to have `stdout` and 2367 `stderr` from the container's start) and `stream=1` 2368 2369 - If in detached mode or only `stdin` is attached, display the container's id. 2370 2371 ## 3.2 Hijacking 2372 2373 In this version of the API, `/attach`, uses hijacking to transport `stdin`, 2374 `stdout`, and `stderr` on the same socket. 2375 2376 To hint potential proxies about connection hijacking, Docker client sends 2377 connection upgrade headers similarly to websocket. 2378 2379 Upgrade: tcp 2380 Connection: Upgrade 2381 2382 When Docker daemon detects the `Upgrade` header, it switches its status code 2383 from **200 OK** to **101 UPGRADED** and resends the same headers. 2384 2385 2386 ## 3.3 CORS Requests 2387 2388 To set cross origin requests to the remote api please give values to 2389 `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, 2390 default or blank means CORS disabled 2391 2392 $ dockerd -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"