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