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