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