github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/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 1106 **Status codes**: 1107 1108 - **204** – no error 1109 - **400** – bad parameter 1110 - **404** – no such container 1111 - **409** – conflict 1112 - **500** – server error 1113 1114 #### Copy files or folders from a container 1115 1116 `POST /containers/(id or name)/copy` 1117 1118 Copy files or folders of container `id` 1119 1120 **Deprecated** in favor of the `archive` endpoint below. 1121 1122 **Example request**: 1123 1124 POST /v1.20/containers/4fa6e0f0c678/copy HTTP/1.1 1125 Content-Type: application/json 1126 1127 { 1128 "Resource": "test.txt" 1129 } 1130 1131 **Example response**: 1132 1133 HTTP/1.1 200 OK 1134 Content-Type: application/x-tar 1135 1136 {% raw %} 1137 {{ TAR STREAM }} 1138 {% endraw %} 1139 1140 **Status codes**: 1141 1142 - **200** – no error 1143 - **404** – no such container 1144 - **500** – server error 1145 1146 #### Retrieving information about files and folders in a container 1147 1148 `HEAD /containers/(id or name)/archive` 1149 1150 See the description of the `X-Docker-Container-Path-Stat` header in the 1151 following section. 1152 1153 #### Get an archive of a filesystem resource in a container 1154 1155 `GET /containers/(id or name)/archive` 1156 1157 Get a tar archive of a resource in the filesystem of container `id`. 1158 1159 **Query parameters**: 1160 1161 - **path** - resource in the container's filesystem to archive. Required. 1162 1163 If not an absolute path, it is relative to the container's root directory. 1164 The resource specified by **path** must exist. To assert that the resource 1165 is expected to be a directory, **path** should end in `/` or `/.` 1166 (assuming a path separator of `/`). If **path** ends in `/.` then this 1167 indicates that only the contents of the **path** directory should be 1168 copied. A symlink is always resolved to its target. 1169 1170 > **Note**: It is not possible to copy certain system files such as resources 1171 > under `/proc`, `/sys`, `/dev`, and mounts created by the user in the 1172 > container. 1173 1174 **Example request**: 1175 1176 GET /v1.20/containers/8cce319429b2/archive?path=/root HTTP/1.1 1177 1178 **Example response**: 1179 1180 HTTP/1.1 200 OK 1181 Content-Type: application/x-tar 1182 X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= 1183 1184 {% raw %} 1185 {{ TAR STREAM }} 1186 {% endraw %} 1187 1188 On success, a response header `X-Docker-Container-Path-Stat` will be set to a 1189 base64-encoded JSON object containing some filesystem header information about 1190 the archived resource. The above example value would decode to the following 1191 JSON object (whitespace added for readability): 1192 1193 ```json 1194 { 1195 "name": "root", 1196 "size": 4096, 1197 "mode": 2147484096, 1198 "mtime": "2014-02-27T20:51:23Z", 1199 "linkTarget": "" 1200 } 1201 ``` 1202 1203 A `HEAD` request can also be made to this endpoint if only this information is 1204 desired. 1205 1206 **Status codes**: 1207 1208 - **200** - success, returns archive of copied resource 1209 - **400** - client error, bad parameter, details in JSON response body, one of: 1210 - must specify path parameter (**path** cannot be empty) 1211 - not a directory (**path** was asserted to be a directory but exists as a 1212 file) 1213 - **404** - client error, resource not found, one of: 1214 – no such container (container `id` does not exist) 1215 - no such file or directory (**path** does not exist) 1216 - **500** - server error 1217 1218 #### Extract an archive of files or folders to a directory in a container 1219 1220 `PUT /containers/(id or name)/archive` 1221 1222 Upload a tar archive to be extracted to a path in the filesystem of container 1223 `id`. 1224 1225 **Query parameters**: 1226 1227 - **path** - path to a directory in the container 1228 to extract the archive's contents into. Required. 1229 1230 If not an absolute path, it is relative to the container's root directory. 1231 The **path** resource must exist. 1232 - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error 1233 if unpacking the given content would cause an existing directory to be 1234 replaced with a non-directory and vice versa. 1235 1236 **Example request**: 1237 1238 PUT /v1.20/containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 1239 Content-Type: application/x-tar 1240 1241 {% raw %} 1242 {{ TAR STREAM }} 1243 {% endraw %} 1244 1245 **Example response**: 1246 1247 HTTP/1.1 200 OK 1248 1249 **Status codes**: 1250 1251 - **200** – the content was extracted successfully 1252 - **400** - client error, bad parameter, details in JSON response body, one of: 1253 - must specify path parameter (**path** cannot be empty) 1254 - not a directory (**path** should be a directory but exists as a file) 1255 - unable to overwrite existing directory with non-directory 1256 (if **noOverwriteDirNonDir**) 1257 - unable to overwrite existing non-directory with directory 1258 (if **noOverwriteDirNonDir**) 1259 - **403** - client error, permission denied, the volume 1260 or container rootfs is marked as read-only. 1261 - **404** - client error, resource not found, one of: 1262 – no such container (container `id` does not exist) 1263 - no such file or directory (**path** resource does not exist) 1264 - **500** – server error 1265 1266 ### 2.2 Images 1267 1268 #### List Images 1269 1270 `GET /images/json` 1271 1272 **Example request**: 1273 1274 GET /v1.20/images/json?all=0 HTTP/1.1 1275 1276 **Example response**: 1277 1278 HTTP/1.1 200 OK 1279 Content-Type: application/json 1280 1281 [ 1282 { 1283 "RepoTags": [ 1284 "ubuntu:12.04", 1285 "ubuntu:precise", 1286 "ubuntu:latest" 1287 ], 1288 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 1289 "Created": 1365714795, 1290 "Size": 131506275, 1291 "VirtualSize": 131506275, 1292 "Labels": {} 1293 }, 1294 { 1295 "RepoTags": [ 1296 "ubuntu:12.10", 1297 "ubuntu:quantal" 1298 ], 1299 "ParentId": "27cf784147099545", 1300 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1301 "Created": 1364102658, 1302 "Size": 24653, 1303 "VirtualSize": 180116135, 1304 "Labels": { 1305 "com.example.version": "v1" 1306 } 1307 } 1308 ] 1309 1310 **Example request, with digest information**: 1311 1312 GET /v1.20/images/json?digests=1 HTTP/1.1 1313 1314 **Example response, with digest information**: 1315 1316 HTTP/1.1 200 OK 1317 Content-Type: application/json 1318 1319 [ 1320 { 1321 "Created": 1420064636, 1322 "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125", 1323 "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2", 1324 "RepoDigests": [ 1325 "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" 1326 ], 1327 "RepoTags": [ 1328 "localhost:5000/test/busybox:latest", 1329 "playdate:latest" 1330 ], 1331 "Size": 0, 1332 "VirtualSize": 2429728, 1333 "Labels": {} 1334 } 1335 ] 1336 1337 The response shows a single image `Id` associated with two repositories 1338 (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use 1339 either of the `RepoTags` values `localhost:5000/test/busybox:latest` or 1340 `playdate:latest` to reference the image. 1341 1342 You can also use `RepoDigests` values to reference an image. In this response, 1343 the array has only one reference and that is to the 1344 `localhost:5000/test/busybox` repository; the `playdate` repository has no 1345 digest. You can reference this digest using the value: 1346 `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...` 1347 1348 See the `docker run` and `docker build` commands for examples of digest and tag 1349 references on the command line. 1350 1351 **Query parameters**: 1352 1353 - **all** – 1/True/true or 0/False/false, default false 1354 - **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters: 1355 - `dangling=true` 1356 - `label=key` or `label="key=value"` of an image label 1357 - **filter** - only return images with the specified name 1358 1359 #### Build image from a Dockerfile 1360 1361 `POST /build` 1362 1363 Build an image from a Dockerfile 1364 1365 **Example request**: 1366 1367 POST /v1.20/build HTTP/1.1 1368 Content-Type: application/x-tar 1369 1370 {% raw %} 1371 {{ TAR STREAM }} 1372 {% endraw %} 1373 1374 **Example response**: 1375 1376 HTTP/1.1 200 OK 1377 Content-Type: application/json 1378 1379 {"stream": "Step 1/5..."} 1380 {"stream": "..."} 1381 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 1382 1383 The input stream must be a `tar` archive compressed with one of the 1384 following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`. 1385 1386 The archive must include a build instructions file, typically called 1387 `Dockerfile` at the archive's root. The `dockerfile` parameter may be 1388 used to specify a different build instructions file. To do this, its value must be 1389 the path to the alternate build instructions file to use. 1390 1391 The archive may include any number of other files, 1392 which are accessible in the build context (See the [*ADD build 1393 command*](../../reference/builder.md#add)). 1394 1395 The Docker daemon performs a preliminary validation of the `Dockerfile` before 1396 starting the build, and returns an error if the syntax is incorrect. After that, 1397 each instruction is run one-by-one until the ID of the new image is output. 1398 1399 The build is canceled if the client drops the connection by quitting 1400 or being killed. 1401 1402 **Query parameters**: 1403 1404 - **dockerfile** - Path within the build context to the `Dockerfile`. This is 1405 ignored if `remote` is specified and points to an external `Dockerfile`. 1406 - **t** – A name and optional tag to apply to the image in the `name:tag` format. 1407 If you omit the `tag` the default `latest` value is assumed. 1408 - **remote** – A Git repository URI or HTTP/HTTPS context URI. If the 1409 URI points to a single text file, the file's contents are placed into 1410 a file called `Dockerfile` and the image is built from that file. If 1411 the URI points to a tarball, the file is downloaded by the daemon and 1412 the contents therein used as the context for the build. If the URI 1413 points to a tarball and the `dockerfile` parameter is also specified, 1414 there must be a file with the corresponding path inside the tarball. 1415 - **q** – Suppress verbose build output. 1416 - **nocache** – Do not use the cache when building the image. 1417 - **pull** - Attempt to pull the image even if an older image exists locally. 1418 - **rm** - Remove intermediate containers after a successful build (default behavior). 1419 - **forcerm** - Always remove intermediate containers (includes `rm`). 1420 - **memory** - Set memory limit for build. 1421 - **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap. 1422 - **cpushares** - CPU shares (relative weight). 1423 - **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`). 1424 - **cpuperiod** - The length of a CPU period in microseconds. 1425 - **cpuquota** - Microseconds of CPU time that the container can get in a CPU period. 1426 1427 **Request Headers**: 1428 1429 - **Content-type** – Set to `"application/x-tar"`. 1430 - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON 1431 object with the following structure: 1432 1433 { 1434 "docker.example.com": { 1435 "username": "janedoe", 1436 "password": "hunter2" 1437 }, 1438 "https://index.docker.io/v1/": { 1439 "username": "mobydock", 1440 "password": "conta1n3rize14" 1441 } 1442 } 1443 1444 This object maps the hostname of a registry to an object containing the 1445 "username" and "password" for that registry. Multiple registries may 1446 be specified as the build may be based on an image requiring 1447 authentication to pull from any arbitrary registry. Only the registry 1448 domain name (and port if not the default "443") are required. However 1449 (for legacy reasons) the "official" Docker, Inc. hosted registry must 1450 be specified with both a "https://" prefix and a "/v1/" suffix even 1451 though Docker will prefer to use the v2 registry API. 1452 1453 **Status codes**: 1454 1455 - **200** – no error 1456 - **500** – server error 1457 1458 #### Create an image 1459 1460 `POST /images/create` 1461 1462 Create an image either by pulling it from the registry or by importing it 1463 1464 **Example request**: 1465 1466 POST /v1.20/images/create?fromImage=busybox&tag=latest HTTP/1.1 1467 1468 **Example response**: 1469 1470 HTTP/1.1 200 OK 1471 Content-Type: application/json 1472 1473 {"status": "Pulling..."} 1474 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 1475 {"error": "Invalid..."} 1476 ... 1477 1478 When using this endpoint to pull an image from the registry, the 1479 `X-Registry-Auth` header can be used to include 1480 a base64-encoded AuthConfig object. 1481 1482 **Query parameters**: 1483 1484 - **fromImage** – Name of the image to pull. 1485 - **fromSrc** – Source to import. The value may be a URL from which the image 1486 can be retrieved or `-` to read the image from the request body. 1487 - **repo** – Repository name. 1488 - **tag** – Tag. If empty when pulling an image, this causes all tags 1489 for the given image to be pulled. 1490 1491 **Request Headers**: 1492 1493 - **X-Registry-Auth** – base64-encoded AuthConfig object 1494 1495 **Status codes**: 1496 1497 - **200** – no error 1498 - **404** - repository does not exist or no read access 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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/_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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 /v1.20/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 Engine 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"