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