github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/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 image 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": "overlay2", 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 1063 **Status codes**: 1064 1065 - **200** – no error 1066 - **400** – bad parameter 1067 - **404** – no such container 1068 - **500** – server error 1069 1070 #### Wait a container 1071 1072 `POST /containers/(id or name)/wait` 1073 1074 Block until container `id` stops, then returns the exit code 1075 1076 **Example request**: 1077 1078 POST /v1.20/containers/16253994b7c4/wait HTTP/1.1 1079 1080 **Example response**: 1081 1082 HTTP/1.1 200 OK 1083 Content-Type: application/json 1084 1085 {"StatusCode": 0} 1086 1087 **Status codes**: 1088 1089 - **200** – no error 1090 - **404** – no such container 1091 - **500** – server error 1092 1093 #### Remove a container 1094 1095 `DELETE /containers/(id or name)` 1096 1097 Remove the container `id` from the filesystem 1098 1099 **Example request**: 1100 1101 DELETE /v1.20/containers/16253994b7c4?v=1 HTTP/1.1 1102 1103 **Example response**: 1104 1105 HTTP/1.1 204 No Content 1106 1107 **Query parameters**: 1108 1109 - **v** – 1/True/true or 0/False/false, Remove the volumes 1110 associated to the container. Default `false`. 1111 - **force** - 1/True/true or 0/False/false, Kill then remove the container. 1112 Default `false`. 1113 - **link** - 1/True/true or 0/False/false, Remove the specified 1114 link associated to the container. Default `false`. 1115 1116 **Status codes**: 1117 1118 - **204** – no error 1119 - **400** – bad parameter 1120 - **404** – no such container 1121 - **409** – conflict 1122 - **500** – server error 1123 1124 #### Copy files or folders from a container 1125 1126 `POST /containers/(id or name)/copy` 1127 1128 Copy files or folders of container `id` 1129 1130 **Deprecated** in favor of the `archive` endpoint below. 1131 1132 **Example request**: 1133 1134 POST /v1.20/containers/4fa6e0f0c678/copy HTTP/1.1 1135 Content-Type: application/json 1136 Content-Length: 12345 1137 1138 { 1139 "Resource": "test.txt" 1140 } 1141 1142 **Example response**: 1143 1144 HTTP/1.1 200 OK 1145 Content-Type: application/x-tar 1146 1147 {% raw %} 1148 {{ TAR STREAM }} 1149 {% endraw %} 1150 1151 **Status codes**: 1152 1153 - **200** – no error 1154 - **404** – no such container 1155 - **500** – server error 1156 1157 #### Retrieving information about files and folders in a container 1158 1159 `HEAD /containers/(id or name)/archive` 1160 1161 See the description of the `X-Docker-Container-Path-Stat` header in the 1162 following section. 1163 1164 #### Get an archive of a filesystem resource in a container 1165 1166 `GET /containers/(id or name)/archive` 1167 1168 Get a tar archive of a resource in the filesystem of container `id`. 1169 1170 **Query parameters**: 1171 1172 - **path** - resource in the container's filesystem to archive. Required. 1173 1174 If not an absolute path, it is relative to the container's root directory. 1175 The resource specified by **path** must exist. To assert that the resource 1176 is expected to be a directory, **path** should end in `/` or `/.` 1177 (assuming a path separator of `/`). If **path** ends in `/.` then this 1178 indicates that only the contents of the **path** directory should be 1179 copied. A symlink is always resolved to its target. 1180 1181 > **Note**: It is not possible to copy certain system files such as resources 1182 > under `/proc`, `/sys`, `/dev`, and mounts created by the user in the 1183 > container. 1184 1185 **Example request**: 1186 1187 GET /v1.20/containers/8cce319429b2/archive?path=/root HTTP/1.1 1188 1189 **Example response**: 1190 1191 HTTP/1.1 200 OK 1192 Content-Type: application/x-tar 1193 X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0= 1194 1195 {% raw %} 1196 {{ TAR STREAM }} 1197 {% endraw %} 1198 1199 On success, a response header `X-Docker-Container-Path-Stat` will be set to a 1200 base64-encoded JSON object containing some filesystem header information about 1201 the archived resource. The above example value would decode to the following 1202 JSON object (whitespace added for readability): 1203 1204 ```json 1205 { 1206 "name": "root", 1207 "size": 4096, 1208 "mode": 2147484096, 1209 "mtime": "2014-02-27T20:51:23Z", 1210 "linkTarget": "" 1211 } 1212 ``` 1213 1214 A `HEAD` request can also be made to this endpoint if only this information is 1215 desired. 1216 1217 **Status codes**: 1218 1219 - **200** - success, returns archive of copied resource 1220 - **400** - client error, bad parameter, details in JSON response body, one of: 1221 - must specify path parameter (**path** cannot be empty) 1222 - not a directory (**path** was asserted to be a directory but exists as a 1223 file) 1224 - **404** - client error, resource not found, one of: 1225 – no such container (container `id` does not exist) 1226 - no such file or directory (**path** does not exist) 1227 - **500** - server error 1228 1229 #### Extract an archive of files or folders to a directory in a container 1230 1231 `PUT /containers/(id or name)/archive` 1232 1233 Upload a tar archive to be extracted to a path in the filesystem of container 1234 `id`. 1235 1236 **Query parameters**: 1237 1238 - **path** - path to a directory in the container 1239 to extract the archive's contents into. Required. 1240 1241 If not an absolute path, it is relative to the container's root directory. 1242 The **path** resource must exist. 1243 - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error 1244 if unpacking the given content would cause an existing directory to be 1245 replaced with a non-directory and vice versa. 1246 1247 **Example request**: 1248 1249 PUT /v1.20/containers/8cce319429b2/archive?path=/vol1 HTTP/1.1 1250 Content-Type: application/x-tar 1251 1252 {% raw %} 1253 {{ TAR STREAM }} 1254 {% endraw %} 1255 1256 **Example response**: 1257 1258 HTTP/1.1 200 OK 1259 1260 **Status codes**: 1261 1262 - **200** – the content was extracted successfully 1263 - **400** - client error, bad parameter, details in JSON response body, one of: 1264 - must specify path parameter (**path** cannot be empty) 1265 - not a directory (**path** should be a directory but exists as a file) 1266 - unable to overwrite existing directory with non-directory 1267 (if **noOverwriteDirNonDir**) 1268 - unable to overwrite existing non-directory with directory 1269 (if **noOverwriteDirNonDir**) 1270 - **403** - client error, permission denied, the volume 1271 or container rootfs is marked as read-only. 1272 - **404** - client error, resource not found, one of: 1273 – no such container (container `id` does not exist) 1274 - no such file or directory (**path** resource does not exist) 1275 - **500** – server error 1276 1277 ### 2.2 Images 1278 1279 #### List Images 1280 1281 `GET /images/json` 1282 1283 **Example request**: 1284 1285 GET /v1.20/images/json?all=0 HTTP/1.1 1286 1287 **Example response**: 1288 1289 HTTP/1.1 200 OK 1290 Content-Type: application/json 1291 1292 [ 1293 { 1294 "RepoTags": [ 1295 "ubuntu:12.04", 1296 "ubuntu:precise", 1297 "ubuntu:latest" 1298 ], 1299 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 1300 "Created": 1365714795, 1301 "Size": 131506275, 1302 "VirtualSize": 131506275, 1303 "Labels": {} 1304 }, 1305 { 1306 "RepoTags": [ 1307 "ubuntu:12.10", 1308 "ubuntu:quantal" 1309 ], 1310 "ParentId": "27cf784147099545", 1311 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1312 "Created": 1364102658, 1313 "Size": 24653, 1314 "VirtualSize": 180116135, 1315 "Labels": { 1316 "com.example.version": "v1" 1317 } 1318 } 1319 ] 1320 1321 **Example request, with digest information**: 1322 1323 GET /v1.20/images/json?digests=1 HTTP/1.1 1324 1325 **Example response, with digest information**: 1326 1327 HTTP/1.1 200 OK 1328 Content-Type: application/json 1329 1330 [ 1331 { 1332 "Created": 1420064636, 1333 "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125", 1334 "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2", 1335 "RepoDigests": [ 1336 "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" 1337 ], 1338 "RepoTags": [ 1339 "localhost:5000/test/busybox:latest", 1340 "playdate:latest" 1341 ], 1342 "Size": 0, 1343 "VirtualSize": 2429728, 1344 "Labels": {} 1345 } 1346 ] 1347 1348 The response shows a single image `Id` associated with two repositories 1349 (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use 1350 either of the `RepoTags` values `localhost:5000/test/busybox:latest` or 1351 `playdate:latest` to reference the image. 1352 1353 You can also use `RepoDigests` values to reference an image. In this response, 1354 the array has only one reference and that is to the 1355 `localhost:5000/test/busybox` repository; the `playdate` repository has no 1356 digest. You can reference this digest using the value: 1357 `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...` 1358 1359 See the `docker run` and `docker build` commands for examples of digest and tag 1360 references on the command line. 1361 1362 **Query parameters**: 1363 1364 - **all** – 1/True/true or 0/False/false, default false 1365 - **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters: 1366 - `dangling=true` 1367 - `label=key` or `label="key=value"` of an image label 1368 - **filter** - only return images with the specified name 1369 1370 #### Build image from a Dockerfile 1371 1372 `POST /build` 1373 1374 Build an image from a Dockerfile 1375 1376 **Example request**: 1377 1378 POST /v1.20/build HTTP/1.1 1379 Content-Type: application/x-tar 1380 1381 {% raw %} 1382 {{ TAR STREAM }} 1383 {% endraw %} 1384 1385 **Example response**: 1386 1387 HTTP/1.1 200 OK 1388 Content-Type: application/json 1389 1390 {"stream": "Step 1/5..."} 1391 {"stream": "..."} 1392 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 1393 1394 The input stream must be a `tar` archive compressed with one of the 1395 following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`. 1396 1397 The archive must include a build instructions file, typically called 1398 `Dockerfile` at the archive's root. The `dockerfile` parameter may be 1399 used to specify a different build instructions file. To do this, its value must be 1400 the path to the alternate build instructions file to use. 1401 1402 The archive may include any number of other files, 1403 which are accessible in the build context (See the [*ADD build 1404 command*](https://docs.docker.com/engine/reference/builder/#add)). 1405 1406 The Docker daemon performs a preliminary validation of the `Dockerfile` before 1407 starting the build, and returns an error if the syntax is incorrect. After that, 1408 each instruction is run one-by-one until the ID of the new image is output. 1409 1410 The build is canceled if the client drops the connection by quitting 1411 or being killed. 1412 1413 **Query parameters**: 1414 1415 - **dockerfile** - Path within the build context to the `Dockerfile`. This is 1416 ignored if `remote` is specified and points to an external `Dockerfile`. 1417 - **t** – A name and optional tag to apply to the image in the `name:tag` format. 1418 If you omit the `tag` the default `latest` value is assumed. 1419 - **remote** – A Git repository URI or HTTP/HTTPS context URI. If the 1420 URI points to a single text file, the file's contents are placed into 1421 a file called `Dockerfile` and the image is built from that file. If 1422 the URI points to a tarball, the file is downloaded by the daemon and 1423 the contents therein used as the context for the build. If the URI 1424 points to a tarball and the `dockerfile` parameter is also specified, 1425 there must be a file with the corresponding path inside the tarball. 1426 - **q** – Suppress verbose build output. 1427 - **nocache** – Do not use the cache when building the image. 1428 - **pull** - Attempt to pull the image even if an older image exists locally. 1429 - **rm** - Remove intermediate containers after a successful build (default behavior). 1430 - **forcerm** - Always remove intermediate containers (includes `rm`). 1431 - **memory** - Set memory limit for build. 1432 - **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap. 1433 - **cpushares** - CPU shares (relative weight). 1434 - **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`). 1435 - **cpuperiod** - The length of a CPU period in microseconds. 1436 - **cpuquota** - Microseconds of CPU time that the container can get in a CPU period. 1437 1438 **Request Headers**: 1439 1440 - **Content-type** – Set to `"application/x-tar"`. 1441 - **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON 1442 object with the following structure: 1443 1444 { 1445 "docker.example.com": { 1446 "username": "janedoe", 1447 "password": "hunter2" 1448 }, 1449 "https://index.docker.io/v1/": { 1450 "username": "mobydock", 1451 "password": "conta1n3rize14" 1452 } 1453 } 1454 1455 This object maps the hostname of a registry to an object containing the 1456 "username" and "password" for that registry. Multiple registries may 1457 be specified as the build may be based on an image requiring 1458 authentication to pull from any arbitrary registry. Only the registry 1459 domain name (and port if not the default "443") are required. However 1460 (for legacy reasons) the "official" Docker, Inc. hosted registry must 1461 be specified with both a "https://" prefix and a "/v1/" suffix even 1462 though Docker will prefer to use the v2 registry API. 1463 1464 **Status codes**: 1465 1466 - **200** – no error 1467 - **500** – server error 1468 1469 #### Create an image 1470 1471 `POST /images/create` 1472 1473 Create an image either by pulling it from the registry or by importing it 1474 1475 **Example request**: 1476 1477 POST /v1.20/images/create?fromImage=busybox&tag=latest HTTP/1.1 1478 1479 **Example response**: 1480 1481 HTTP/1.1 200 OK 1482 Content-Type: application/json 1483 1484 {"status": "Pulling..."} 1485 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 1486 {"error": "Invalid..."} 1487 ... 1488 1489 When using this endpoint to pull an image from the registry, the 1490 `X-Registry-Auth` header can be used to include 1491 a base64-encoded AuthConfig object. 1492 1493 **Query parameters**: 1494 1495 - **fromImage** – Name of the image to pull. 1496 - **fromSrc** – Source to import. The value may be a URL from which the image 1497 can be retrieved or `-` to read the image from the request body. 1498 - **repo** – Repository name. 1499 - **tag** – Tag. If empty when pulling an image, this causes all tags 1500 for the given image to be pulled. 1501 1502 **Request Headers**: 1503 1504 - **X-Registry-Auth** – base64-encoded AuthConfig object 1505 1506 **Status codes**: 1507 1508 - **200** – no error 1509 - **404** - repository does not exist or no read access 1510 - **500** – server error 1511 1512 1513 1514 #### Inspect an image 1515 1516 `GET /images/(name)/json` 1517 1518 Return low-level information on the image `name` 1519 1520 **Example request**: 1521 1522 GET /v1.20/images/ubuntu/json HTTP/1.1 1523 1524 **Example response**: 1525 1526 HTTP/1.1 200 OK 1527 Content-Type: application/json 1528 1529 { 1530 "Created": "2013-03-23T22:24:18.818426-07:00", 1531 "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0", 1532 "ContainerConfig": { 1533 "Hostname": "", 1534 "User": "", 1535 "AttachStdin": false, 1536 "AttachStdout": false, 1537 "AttachStderr": false, 1538 "Tty": true, 1539 "OpenStdin": true, 1540 "StdinOnce": false, 1541 "Env": null, 1542 "Cmd": ["/bin/bash"], 1543 "Dns": null, 1544 "Image": "ubuntu", 1545 "Labels": { 1546 "com.example.vendor": "Acme", 1547 "com.example.license": "GPL", 1548 "com.example.version": "1.0" 1549 }, 1550 "Volumes": null, 1551 "VolumesFrom": "", 1552 "WorkingDir": "" 1553 }, 1554 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1555 "Parent": "27cf784147099545", 1556 "Size": 6824592 1557 } 1558 1559 **Status codes**: 1560 1561 - **200** – no error 1562 - **404** – no such image 1563 - **500** – server error 1564 1565 #### Get the history of an image 1566 1567 `GET /images/(name)/history` 1568 1569 Return the history of the image `name` 1570 1571 **Example request**: 1572 1573 GET /v1.20/images/ubuntu/history HTTP/1.1 1574 1575 **Example response**: 1576 1577 HTTP/1.1 200 OK 1578 Content-Type: application/json 1579 1580 [ 1581 { 1582 "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710", 1583 "Created": 1398108230, 1584 "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /", 1585 "Tags": [ 1586 "ubuntu:lucid", 1587 "ubuntu:10.04" 1588 ], 1589 "Size": 182964289, 1590 "Comment": "" 1591 }, 1592 { 1593 "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8", 1594 "Created": 1398108222, 1595 "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/", 1596 "Tags": null, 1597 "Size": 0, 1598 "Comment": "" 1599 }, 1600 { 1601 "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158", 1602 "Created": 1371157430, 1603 "CreatedBy": "", 1604 "Tags": [ 1605 "scratch12:latest", 1606 "scratch:latest" 1607 ], 1608 "Size": 0, 1609 "Comment": "Imported from -" 1610 } 1611 ] 1612 1613 **Status codes**: 1614 1615 - **200** – no error 1616 - **404** – no such image 1617 - **500** – server error 1618 1619 #### Push an image on the registry 1620 1621 `POST /images/(name)/push` 1622 1623 Push the image `name` on the registry 1624 1625 **Example request**: 1626 1627 POST /v1.20/images/test/push HTTP/1.1 1628 1629 **Example response**: 1630 1631 HTTP/1.1 200 OK 1632 Content-Type: application/json 1633 1634 {"status": "Pushing..."} 1635 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 1636 {"error": "Invalid..."} 1637 ... 1638 1639 If you wish to push an image on to a private registry, that image must already have a tag 1640 into a repository which references that registry `hostname` and `port`. This repository name should 1641 then be used in the URL. This duplicates the command line's flow. 1642 1643 **Example request**: 1644 1645 POST /v1.20/images/registry.acme.com:5000/test/push HTTP/1.1 1646 1647 1648 **Query parameters**: 1649 1650 - **tag** – The tag to associate with the image on the registry. This is optional. 1651 1652 **Request Headers**: 1653 1654 - **X-Registry-Auth** – base64-encoded AuthConfig object. 1655 1656 **Status codes**: 1657 1658 - **200** – no error 1659 - **404** – no such image 1660 - **500** – server error 1661 1662 #### Tag an image into a repository 1663 1664 `POST /images/(name)/tag` 1665 1666 Tag the image `name` into a repository 1667 1668 **Example request**: 1669 1670 POST /v1.20/images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1 1671 1672 **Example response**: 1673 1674 HTTP/1.1 201 Created 1675 1676 **Query parameters**: 1677 1678 - **repo** – The repository to tag in 1679 - **force** – 1/True/true or 0/False/false, default false 1680 - **tag** - The new tag name 1681 1682 **Status codes**: 1683 1684 - **201** – no error 1685 - **400** – bad parameter 1686 - **404** – no such image 1687 - **409** – conflict 1688 - **500** – server error 1689 1690 #### Remove an image 1691 1692 `DELETE /images/(name)` 1693 1694 Remove the image `name` from the filesystem 1695 1696 **Example request**: 1697 1698 DELETE /v1.20/images/test HTTP/1.1 1699 1700 **Example response**: 1701 1702 HTTP/1.1 200 OK 1703 Content-type: application/json 1704 1705 [ 1706 {"Untagged": "3e2f21a89f"}, 1707 {"Deleted": "3e2f21a89f"}, 1708 {"Deleted": "53b4f83ac9"} 1709 ] 1710 1711 **Query parameters**: 1712 1713 - **force** – 1/True/true or 0/False/false, default false 1714 - **noprune** – 1/True/true or 0/False/false, default false 1715 1716 **Status codes**: 1717 1718 - **200** – no error 1719 - **404** – no such image 1720 - **409** – conflict 1721 - **500** – server error 1722 1723 #### Search images 1724 1725 `GET /images/search` 1726 1727 Search for an image on [Docker Hub](https://hub.docker.com). 1728 1729 > **Note**: 1730 > The response keys have changed from API v1.6 to reflect the JSON 1731 > sent by the registry server to the docker daemon's request. 1732 1733 **Example request**: 1734 1735 GET /v1.20/images/search?term=sshd HTTP/1.1 1736 1737 **Example response**: 1738 1739 HTTP/1.1 200 OK 1740 Content-Type: application/json 1741 1742 [ 1743 { 1744 "description": "", 1745 "is_official": false, 1746 "is_automated": false, 1747 "name": "wma55/u1210sshd", 1748 "star_count": 0 1749 }, 1750 { 1751 "description": "", 1752 "is_official": false, 1753 "is_automated": false, 1754 "name": "jdswinbank/sshd", 1755 "star_count": 0 1756 }, 1757 { 1758 "description": "", 1759 "is_official": false, 1760 "is_automated": false, 1761 "name": "vgauthier/sshd", 1762 "star_count": 0 1763 } 1764 ... 1765 ] 1766 1767 **Query parameters**: 1768 1769 - **term** – term to search 1770 1771 **Status codes**: 1772 1773 - **200** – no error 1774 - **500** – server error 1775 1776 ### 2.3 Misc 1777 1778 #### Check auth configuration 1779 1780 `POST /auth` 1781 1782 Get the default username and email 1783 1784 **Example request**: 1785 1786 POST /v1.20/auth HTTP/1.1 1787 Content-Type: application/json 1788 Content-Length: 12345 1789 1790 { 1791 "username": "hannibal", 1792 "password": "xxxx", 1793 "email": "hannibal@a-team.com", 1794 "serveraddress": "https://index.docker.io/v1/" 1795 } 1796 1797 **Example response**: 1798 1799 HTTP/1.1 200 OK 1800 1801 **Status codes**: 1802 1803 - **200** – no error 1804 - **204** – no error 1805 - **500** – server error 1806 1807 #### Display system-wide information 1808 1809 `GET /info` 1810 1811 Display system-wide information 1812 1813 **Example request**: 1814 1815 GET /v1.20/info HTTP/1.1 1816 1817 **Example response**: 1818 1819 HTTP/1.1 200 OK 1820 Content-Type: application/json 1821 1822 { 1823 "Containers": 11, 1824 "CpuCfsPeriod": true, 1825 "CpuCfsQuota": true, 1826 "Debug": false, 1827 "DockerRootDir": "/var/lib/docker", 1828 "Driver": "btrfs", 1829 "DriverStatus": [[""]], 1830 "ExecutionDriver": "native-0.1", 1831 "ExperimentalBuild": false, 1832 "HttpProxy": "http://test:test@localhost:8080", 1833 "HttpsProxy": "https://test:test@localhost:8080", 1834 "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS", 1835 "IPv4Forwarding": true, 1836 "Images": 16, 1837 "IndexServerAddress": "https://index.docker.io/v1/", 1838 "InitPath": "/usr/bin/docker", 1839 "InitSha1": "", 1840 "KernelVersion": "3.12.0-1-amd64", 1841 "Labels": [ 1842 "storage=ssd" 1843 ], 1844 "MemTotal": 2099236864, 1845 "MemoryLimit": true, 1846 "NCPU": 1, 1847 "NEventsListener": 0, 1848 "NFd": 11, 1849 "NGoroutines": 21, 1850 "Name": "prod-server-42", 1851 "NoProxy": "9.81.1.160", 1852 "OomKillDisable": true, 1853 "OperatingSystem": "Boot2Docker", 1854 "RegistryConfig": { 1855 "IndexConfigs": { 1856 "docker.io": { 1857 "Mirrors": null, 1858 "Name": "docker.io", 1859 "Official": true, 1860 "Secure": true 1861 } 1862 }, 1863 "InsecureRegistryCIDRs": [ 1864 "127.0.0.0/8" 1865 ] 1866 }, 1867 "SwapLimit": false, 1868 "SystemTime": "2015-03-10T11:11:23.730591467-07:00" 1869 } 1870 1871 **Status codes**: 1872 1873 - **200** – no error 1874 - **500** – server error 1875 1876 #### Show the docker version information 1877 1878 `GET /version` 1879 1880 Show the docker version information 1881 1882 **Example request**: 1883 1884 GET /v1.20/version HTTP/1.1 1885 1886 **Example response**: 1887 1888 HTTP/1.1 200 OK 1889 Content-Type: application/json 1890 1891 { 1892 "Version": "1.5.0", 1893 "Os": "linux", 1894 "KernelVersion": "3.18.5-tinycore64", 1895 "GoVersion": "go1.4.1", 1896 "GitCommit": "a8a31ef", 1897 "Arch": "amd64", 1898 "ApiVersion": "1.20", 1899 "Experimental": false 1900 } 1901 1902 **Status codes**: 1903 1904 - **200** – no error 1905 - **500** – server error 1906 1907 #### Ping the docker server 1908 1909 `GET /_ping` 1910 1911 Ping the docker server 1912 1913 **Example request**: 1914 1915 GET /v1.20/_ping HTTP/1.1 1916 1917 **Example response**: 1918 1919 HTTP/1.1 200 OK 1920 Content-Type: text/plain 1921 1922 OK 1923 1924 **Status codes**: 1925 1926 - **200** - no error 1927 - **500** - server error 1928 1929 #### Create a new image from a container's changes 1930 1931 `POST /commit` 1932 1933 Create a new image from a container's changes 1934 1935 **Example request**: 1936 1937 POST /v1.20/commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1 1938 Content-Type: application/json 1939 Content-Length: 12345 1940 1941 { 1942 "Hostname": "", 1943 "Domainname": "", 1944 "User": "", 1945 "AttachStdin": false, 1946 "AttachStdout": true, 1947 "AttachStderr": true, 1948 "Tty": false, 1949 "OpenStdin": false, 1950 "StdinOnce": false, 1951 "Env": null, 1952 "Cmd": [ 1953 "date" 1954 ], 1955 "Mounts": [ 1956 { 1957 "Source": "/data", 1958 "Destination": "/data", 1959 "Mode": "ro,Z", 1960 "RW": false 1961 } 1962 ], 1963 "Labels": { 1964 "key1": "value1", 1965 "key2": "value2" 1966 }, 1967 "WorkingDir": "", 1968 "NetworkDisabled": false, 1969 "ExposedPorts": { 1970 "22/tcp": {} 1971 } 1972 } 1973 1974 **Example response**: 1975 1976 HTTP/1.1 201 Created 1977 Content-Type: application/json 1978 1979 {"Id": "596069db4bf5"} 1980 1981 **JSON parameters**: 1982 1983 - **config** - the container's configuration 1984 1985 **Query parameters**: 1986 1987 - **container** – source container 1988 - **repo** – repository 1989 - **tag** – tag 1990 - **comment** – commit message 1991 - **author** – author (e.g., "John Hannibal Smith 1992 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 1993 - **pause** – 1/True/true or 0/False/false, whether to pause the container before committing 1994 - **changes** – Dockerfile instructions to apply while committing 1995 1996 **Status codes**: 1997 1998 - **201** – no error 1999 - **404** – no such container 2000 - **500** – server error 2001 2002 #### Monitor Docker's events 2003 2004 `GET /events` 2005 2006 Get container events from docker, in real time via streaming. 2007 2008 Docker containers report the following events: 2009 2010 attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause 2011 2012 Docker images report the following events: 2013 2014 delete, import, pull, push, tag, untag 2015 2016 **Example request**: 2017 2018 GET /v1.20/events?since=1374067924 2019 2020 **Example response**: 2021 2022 HTTP/1.1 200 OK 2023 Content-Type: application/json 2024 2025 {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 2026 {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 2027 {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966} 2028 {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970} 2029 2030 **Query parameters**: 2031 2032 - **since** – Timestamp. Show all events created since timestamp and then stream 2033 - **until** – Timestamp. Show events created until given timestamp and stop streaming 2034 - **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters: 2035 - `container=<string>`; -- container to filter 2036 - `event=<string>`; -- event to filter 2037 - `image=<string>`; -- image to filter 2038 2039 **Status codes**: 2040 2041 - **200** – no error 2042 - **500** – server error 2043 2044 #### Get a tarball containing all images in a repository 2045 2046 `GET /images/(name)/get` 2047 2048 Get a tarball containing all images and metadata for the repository specified 2049 by `name`. 2050 2051 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image 2052 (and its parents) are returned. If `name` is an image ID, similarly only that 2053 image (and its parents) are returned, but with the exclusion of the 2054 'repositories' file in the tarball, as there were no image names referenced. 2055 2056 See the [image tarball format](#image-tarball-format) for more details. 2057 2058 **Example request** 2059 2060 GET /v1.20/images/ubuntu/get 2061 2062 **Example response**: 2063 2064 HTTP/1.1 200 OK 2065 Content-Type: application/x-tar 2066 2067 Binary data stream 2068 2069 **Status codes**: 2070 2071 - **200** – no error 2072 - **500** – server error 2073 2074 #### Get a tarball containing all images 2075 2076 `GET /images/get` 2077 2078 Get a tarball containing all images and metadata for one or more repositories. 2079 2080 For each value of the `names` parameter: if it is a specific name and tag (e.g. 2081 `ubuntu:latest`), then only that image (and its parents) are returned; if it is 2082 an image ID, similarly only that image (and its parents) are returned and there 2083 would be no names referenced in the 'repositories' file for this image ID. 2084 2085 See the [image tarball format](#image-tarball-format) for more details. 2086 2087 **Example request** 2088 2089 GET /v1.20/images/get?names=myname%2Fmyapp%3Alatest&names=busybox 2090 2091 **Example response**: 2092 2093 HTTP/1.1 200 OK 2094 Content-Type: application/x-tar 2095 2096 Binary data stream 2097 2098 **Status codes**: 2099 2100 - **200** – no error 2101 - **500** – server error 2102 2103 #### Load a tarball with a set of images and tags into docker 2104 2105 `POST /images/load` 2106 2107 Load a set of images and tags into a Docker repository. 2108 See the [image tarball format](#image-tarball-format) for more details. 2109 2110 **Example request** 2111 2112 POST /v1.20/images/load 2113 Content-Type: application/x-tar 2114 Content-Length: 12345 2115 2116 Tarball in body 2117 2118 **Example response**: 2119 2120 HTTP/1.1 200 OK 2121 2122 **Status codes**: 2123 2124 - **200** – no error 2125 - **500** – server error 2126 2127 #### Image tarball format 2128 2129 An image tarball contains one directory per image layer (named using its long ID), 2130 each containing these files: 2131 2132 - `VERSION`: currently `1.0` - the file format version 2133 - `json`: detailed layer information, similar to `docker inspect layer_id` 2134 - `layer.tar`: A tarfile containing the filesystem changes in this layer 2135 2136 The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories 2137 for storing attribute changes and deletions. 2138 2139 If the tarball defines a repository, the tarball should also include a `repositories` file at 2140 the root that contains a list of repository and tag names mapped to layer IDs. 2141 2142 ``` 2143 {"hello-world": 2144 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 2145 } 2146 ``` 2147 2148 #### Exec Create 2149 2150 `POST /containers/(id or name)/exec` 2151 2152 Sets up an exec instance in a running container `id` 2153 2154 **Example request**: 2155 2156 POST /v1.20/containers/e90e34656806/exec HTTP/1.1 2157 Content-Type: application/json 2158 Content-Length: 12345 2159 2160 { 2161 "AttachStdin": true, 2162 "AttachStdout": true, 2163 "AttachStderr": true, 2164 "Cmd": ["sh"], 2165 "Tty": true, 2166 "User": "123:456" 2167 } 2168 2169 **Example response**: 2170 2171 HTTP/1.1 201 Created 2172 Content-Type: application/json 2173 2174 { 2175 "Id": "f90e34656806", 2176 "Warnings":[] 2177 } 2178 2179 **JSON parameters**: 2180 2181 - **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command. 2182 - **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command. 2183 - **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command. 2184 - **Tty** - Boolean value to allocate a pseudo-TTY. 2185 - **Cmd** - Command to run specified as a string or an array of strings. 2186 - **User** - A string value specifying the user, and optionally, group to run 2187 the exec process inside the container. Format is one of: `"user"`, 2188 `"user:group"`, `"uid"`, or `"uid:gid"`. 2189 2190 **Status codes**: 2191 2192 - **201** – no error 2193 - **404** – no such container 2194 2195 #### Exec Start 2196 2197 `POST /exec/(id)/start` 2198 2199 Starts a previously set up `exec` instance `id`. If `detach` is true, this API 2200 returns after starting the `exec` command. Otherwise, this API sets up an 2201 interactive session with the `exec` command. 2202 2203 **Example request**: 2204 2205 POST /v1.20/exec/e90e34656806/start HTTP/1.1 2206 Content-Type: application/json 2207 Content-Length: 12345 2208 2209 { 2210 "Detach": false, 2211 "Tty": false 2212 } 2213 2214 **Example response**: 2215 2216 HTTP/1.1 200 OK 2217 Content-Type: application/vnd.docker.raw-stream 2218 2219 {% raw %} 2220 {{ STREAM }} 2221 {% endraw %} 2222 2223 **JSON parameters**: 2224 2225 - **Detach** - Detach from the `exec` command. 2226 - **Tty** - Boolean value to allocate a pseudo-TTY. 2227 2228 **Status codes**: 2229 2230 - **200** – no error 2231 - **404** – no such exec instance 2232 2233 **Stream details**: 2234 2235 Similar to the stream behavior of `POST /containers/(id or name)/attach` API 2236 2237 #### Exec Resize 2238 2239 `POST /exec/(id)/resize` 2240 2241 Resizes the `tty` session used by the `exec` command `id`. The unit is number of characters. 2242 This API is valid only if `tty` was specified as part of creating and starting the `exec` command. 2243 2244 **Example request**: 2245 2246 POST /v1.20/exec/e90e34656806/resize?h=40&w=80 HTTP/1.1 2247 Content-Type: text/plain 2248 2249 **Example response**: 2250 2251 HTTP/1.1 201 Created 2252 Content-Type: text/plain 2253 2254 **Query parameters**: 2255 2256 - **h** – height of `tty` session 2257 - **w** – width 2258 2259 **Status codes**: 2260 2261 - **201** – no error 2262 - **404** – no such exec instance 2263 2264 #### Exec Inspect 2265 2266 `GET /exec/(id)/json` 2267 2268 Return low-level information about the `exec` command `id`. 2269 2270 **Example request**: 2271 2272 GET /v1.20/exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1 2273 2274 **Example response**: 2275 2276 HTTP/1.1 200 OK 2277 Content-Type: plain/text 2278 2279 { 2280 "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39", 2281 "Running" : false, 2282 "ExitCode" : 2, 2283 "ProcessConfig" : { 2284 "privileged" : false, 2285 "user" : "", 2286 "tty" : false, 2287 "entrypoint" : "sh", 2288 "arguments" : [ 2289 "-c", 2290 "exit 2" 2291 ] 2292 }, 2293 "OpenStdin" : false, 2294 "OpenStderr" : false, 2295 "OpenStdout" : false, 2296 "Container" : { 2297 "State" : { 2298 "Running" : true, 2299 "Paused" : false, 2300 "Restarting" : false, 2301 "OOMKilled" : false, 2302 "Pid" : 3650, 2303 "ExitCode" : 0, 2304 "Error" : "", 2305 "StartedAt" : "2014-11-17T22:26:03.717657531Z", 2306 "FinishedAt" : "0001-01-01T00:00:00Z" 2307 }, 2308 "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c", 2309 "Created" : "2014-11-17T22:26:03.626304998Z", 2310 "Path" : "date", 2311 "Args" : [], 2312 "Config" : { 2313 "Hostname" : "8f177a186b97", 2314 "Domainname" : "", 2315 "User" : "", 2316 "AttachStdin" : false, 2317 "AttachStdout" : false, 2318 "AttachStderr" : false, 2319 "ExposedPorts" : null, 2320 "Tty" : false, 2321 "OpenStdin" : false, 2322 "StdinOnce" : false, 2323 "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ], 2324 "Cmd" : [ 2325 "date" 2326 ], 2327 "Image" : "ubuntu", 2328 "Volumes" : null, 2329 "WorkingDir" : "", 2330 "Entrypoint" : null, 2331 "NetworkDisabled" : false, 2332 "MacAddress" : "", 2333 "OnBuild" : null, 2334 "SecurityOpt" : null 2335 }, 2336 "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5", 2337 "NetworkSettings" : { 2338 "IPAddress" : "172.17.0.2", 2339 "IPPrefixLen" : 16, 2340 "MacAddress" : "02:42:ac:11:00:02", 2341 "Gateway" : "172.17.42.1", 2342 "Bridge" : "docker0", 2343 "PortMapping" : null, 2344 "Ports" : {} 2345 }, 2346 "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf", 2347 "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname", 2348 "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts", 2349 "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log", 2350 "Name" : "/test", 2351 "Driver" : "aufs", 2352 "ExecDriver" : "native-0.2", 2353 "MountLabel" : "", 2354 "ProcessLabel" : "", 2355 "AppArmorProfile" : "", 2356 "RestartCount" : 0, 2357 "Mounts" : [] 2358 } 2359 } 2360 2361 **Status codes**: 2362 2363 - **200** – no error 2364 - **404** – no such exec instance 2365 - **500** - server error 2366 2367 ## 3. Going further 2368 2369 ### 3.1 Inside `docker run` 2370 2371 As an example, the `docker run` command line makes the following API calls: 2372 2373 - Create the container 2374 2375 - If the status code is 404, it means the image doesn't exist: 2376 - Try to pull it. 2377 - Then, retry to create the container. 2378 2379 - Start the container. 2380 2381 - If you are not in detached mode: 2382 - Attach to the container, using `logs=1` (to have `stdout` and 2383 `stderr` from the container's start) and `stream=1` 2384 2385 - If in detached mode or only `stdin` is attached, display the container's id. 2386 2387 ### 3.2 Hijacking 2388 2389 In this version of the API, `/attach`, uses hijacking to transport `stdin`, 2390 `stdout`, and `stderr` on the same socket. 2391 2392 To hint potential proxies about connection hijacking, Docker client sends 2393 connection upgrade headers similarly to websocket. 2394 2395 Upgrade: tcp 2396 Connection: Upgrade 2397 2398 When Docker daemon detects the `Upgrade` header, it switches its status code 2399 from **200 OK** to **101 UPGRADED** and resends the same headers. 2400 2401 2402 ### 3.3 CORS Requests 2403 2404 To set cross origin requests to the Engine API please give values to 2405 `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all, 2406 default or blank means CORS disabled 2407 2408 $ dockerd -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"