github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/docs/reference/api/docker_remote_api_v1.15.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Remote API v1.15" 4 description = "API Documentation for Docker" 5 keywords = ["API, Docker, rcli, REST, documentation"] 6 [menu.main] 7 parent = "engine_remoteapi" 8 weight = 6 9 +++ 10 <![end-metadata]--> 11 12 # Docker Remote API v1.15 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](../../quickstart.md#bind-docker-to-another-host-port-or-a-unix-socket). 19 - The API tends to be REST, but for some complex commands, like `attach` 20 or `pull`, the HTTP connection is hijacked to transport `STDOUT`, 21 `STDIN` and `STDERR`. 22 23 # 2. Endpoints 24 25 ## 2.1 Containers 26 27 ### List containers 28 29 `GET /containers/json` 30 31 List containers 32 33 **Example request**: 34 35 GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1 36 37 **Example response**: 38 39 HTTP/1.1 200 OK 40 Content-Type: application/json 41 42 [ 43 { 44 "Id": "8dfafdbc3a40", 45 "Names":["/boring_feynman"], 46 "Image": "ubuntu:latest", 47 "Command": "echo 1", 48 "Created": 1367854155, 49 "Status": "Exit 0", 50 "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}], 51 "SizeRw": 12288, 52 "SizeRootFs": 0 53 }, 54 { 55 "Id": "9cd87474be90", 56 "Names":["/coolName"], 57 "Image": "ubuntu:latest", 58 "Command": "echo 222222", 59 "Created": 1367854155, 60 "Status": "Exit 0", 61 "Ports": [], 62 "SizeRw": 12288, 63 "SizeRootFs": 0 64 }, 65 { 66 "Id": "3176a2479c92", 67 "Names":["/sleepy_dog"], 68 "Image": "ubuntu:latest", 69 "Command": "echo 3333333333333333", 70 "Created": 1367854154, 71 "Status": "Exit 0", 72 "Ports":[], 73 "SizeRw":12288, 74 "SizeRootFs":0 75 }, 76 { 77 "Id": "4cb07b47f9fb", 78 "Names":["/running_cat"], 79 "Image": "ubuntu:latest", 80 "Command": "echo 444444444444444444444444444444444", 81 "Created": 1367854152, 82 "Status": "Exit 0", 83 "Ports": [], 84 "SizeRw": 12288, 85 "SizeRootFs": 0 86 } 87 ] 88 89 Query Parameters: 90 91 - **all** – 1/True/true or 0/False/false, Show all containers. 92 Only running containers are shown by default (i.e., this defaults to false) 93 - **limit** – Show `limit` last created 94 containers, include non-running ones. 95 - **since** – Show only containers created since Id, include 96 non-running ones. 97 - **before** – Show only containers created before Id, include 98 non-running ones. 99 - **size** – 1/True/true or 0/False/false, Show the containers 100 sizes 101 - **filters** - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters: 102 - exited=<int> -- containers with exit code of <int> 103 - status=(restarting|running|paused|exited) 104 105 Status Codes: 106 107 - **200** – no error 108 - **400** – bad parameter 109 - **500** – server error 110 111 ### Create a container 112 113 `POST /containers/create` 114 115 Create a container 116 117 **Example request**: 118 119 POST /containers/create HTTP/1.1 120 Content-Type: application/json 121 122 { 123 "Hostname": "", 124 "Domainname": "", 125 "User": "", 126 "Memory": 0, 127 "MemorySwap": 0, 128 "CpuShares": 512, 129 "Cpuset": "0,1", 130 "AttachStdin": false, 131 "AttachStdout": true, 132 "AttachStderr": true, 133 "Tty": false, 134 "OpenStdin": false, 135 "StdinOnce": false, 136 "Env": [ 137 "FOO=bar", 138 "BAZ=quux" 139 ], 140 "Cmd": [ 141 "date" 142 ], 143 "Entrypoint": "", 144 "Image": "ubuntu", 145 "Volumes": { 146 "/tmp": {} 147 }, 148 "WorkingDir": "", 149 "NetworkDisabled": false, 150 "MacAddress": "12:34:56:78:9a:bc", 151 "ExposedPorts": { 152 "22/tcp": {} 153 }, 154 "SecurityOpts": [], 155 "HostConfig": { 156 "Binds": ["/tmp:/tmp"], 157 "Links": ["redis3:redis"], 158 "LxcConf": {"lxc.utsname":"docker"}, 159 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] }, 160 "PublishAllPorts": false, 161 "Privileged": false, 162 "Dns": ["8.8.8.8"], 163 "DnsSearch": [""], 164 "ExtraHosts": null, 165 "VolumesFrom": ["parent", "other:ro"], 166 "CapAdd": ["NET_ADMIN"], 167 "CapDrop": ["MKNOD"], 168 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 }, 169 "NetworkMode": "bridge", 170 "Devices": [] 171 } 172 } 173 174 **Example response**: 175 176 HTTP/1.1 201 Created 177 Content-Type: application/json 178 179 { 180 "Id": "f91ddc4b01e079c4481a8340bbbeca4dbd33d6e4a10662e499f8eacbb5bf252b" 181 "Warnings": [] 182 } 183 184 Json Parameters: 185 186 - **Hostname** - A string value containing the desired hostname to use for the 187 container. 188 - **Domainname** - A string value containing the desired domain name to use 189 for the container. 190 - **User** - A string value containing the user to use inside the container. 191 - **Memory** - Memory limit in bytes. 192 - **MemorySwap** - Total memory limit (memory + swap); set `-1` to enable unlimited swap. 193 - **CpuShares** - An integer value containing the CPU Shares for container 194 (ie. the relative weight vs other containers). 195 **CpuSet** - String value containing the cgroups Cpuset to use. 196 - **AttachStdin** - Boolean value, attaches to stdin. 197 - **AttachStdout** - Boolean value, attaches to stdout. 198 - **AttachStderr** - Boolean value, attaches to stderr. 199 - **Tty** - Boolean value, Attach standard streams to a tty, including stdin if it is not closed. 200 - **OpenStdin** - Boolean value, opens stdin, 201 - **StdinOnce** - Boolean value, close stdin after the 1 attached client disconnects. 202 - **Env** - A list of environment variables in the form of `["VAR=value"[,"VAR2=value2"]]` 203 - **Cmd** - Command to run specified as a string or an array of strings. 204 - **Entrypoint** - Set the entrypoint for the container a string or an array 205 of strings 206 - **Image** - String value containing the image name to use for the container 207 - **Volumes** – An object mapping mountpoint paths (strings) inside the 208 container to empty objects. 209 - **WorkingDir** - A string value containing the working dir for commands to 210 run in. 211 - **NetworkDisabled** - Boolean value, when true disables networking for the 212 container 213 - **ExposedPorts** - An object mapping ports to an empty object in the form of: 214 `"ExposedPorts": { "<port>/<tcp|udp>: {}" }` 215 - **SecurityOpts**: A list of string values to customize labels for MLS 216 systems, such as SELinux. 217 - **HostConfig** 218 - **Binds** – A list of volume bindings for this container. Each volume 219 binding is a string of the form `container_path` (to create a new 220 volume for the container), `host_path:container_path` (to bind-mount 221 a host path into the container), or `host_path:container_path:ro` 222 (to make the bind-mount read-only inside the container). 223 - **Links** - A list of links for the container. Each link entry should be 224 in the form of "container_name:alias". 225 - **LxcConf** - LXC specific configurations. These configurations will only 226 work when using the `lxc` execution driver. 227 - **PortBindings** - A map of exposed container ports and the host port they 228 should map to. It should be specified in the form 229 `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }` 230 Take note that `port` is specified as a string and not an integer value. 231 - **PublishAllPorts** - Allocates a random host port for all of a container's 232 exposed ports. Specified as a boolean value. 233 - **Privileged** - Gives the container full access to the host. Specified as 234 a boolean value. 235 - **Dns** - A list of dns servers for the container to use. 236 - **DnsSearch** - A list of DNS search domains 237 - **ExtraHosts** - A list of hostnames/IP mappings to be added to the 238 container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`. 239 - **VolumesFrom** - A list of volumes to inherit from another container. 240 Specified in the form `<container name>[:<ro|rw>]` 241 - **CapAdd** - A list of kernel capabilities to add to the container. 242 - **Capdrop** - A list of kernel capabilities to drop from the container. 243 - **RestartPolicy** – The behavior to apply when the container exits. The 244 value is an object with a `Name` property of either `"always"` to 245 always restart or `"on-failure"` to restart only when the container 246 exit code is non-zero. If `on-failure` is used, `MaximumRetryCount` 247 controls the number of times to retry before giving up. 248 The default is not to restart. (optional) 249 An ever increasing delay (double the previous delay, starting at 100mS) 250 is added before each restart to prevent flooding the server. 251 - **NetworkMode** - Sets the networking mode for the container. Supported 252 values are: `bridge`, `host`, `none`, and `container:<name|id>` 253 - **Devices** - A list of devices to add to the container specified in the 254 form 255 `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}` 256 257 Query Parameters: 258 259 - **name** – Assign the specified name to the container. Must 260 match `/?[a-zA-Z0-9_-]+`. 261 262 Status Codes: 263 264 - **201** – no error 265 - **404** – no such container 266 - **406** – impossible to attach (container not running) 267 - **500** – server error 268 269 ### Inspect a container 270 271 `GET /containers/(id or name)/json` 272 273 Return low-level information on the container `id` 274 275 276 **Example request**: 277 278 GET /containers/4fa6e0f0c678/json HTTP/1.1 279 280 **Example response**: 281 282 HTTP/1.1 200 OK 283 Content-Type: application/json 284 285 { 286 "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2", 287 "Created": "2013-05-07T14:51:42.041847+02:00", 288 "Path": "date", 289 "Args": [], 290 "Config": { 291 "Hostname": "4fa6e0f0c678", 292 "User": "", 293 "Memory": 0, 294 "MemorySwap": 0, 295 "AttachStdin": false, 296 "AttachStdout": true, 297 "AttachStderr": true, 298 "PortSpecs": null, 299 "Tty": false, 300 "OpenStdin": false, 301 "StdinOnce": false, 302 "Env": null, 303 "Cmd": [ 304 "date" 305 ], 306 "Dns": null, 307 "Image": "ubuntu", 308 "Volumes": {}, 309 "VolumesFrom": "", 310 "WorkingDir": "" 311 }, 312 "State": { 313 "Running": false, 314 "Pid": 0, 315 "ExitCode": 0, 316 "StartedAt": "2013-05-07T14:51:42.087658+02:01360", 317 "Ghost": false 318 }, 319 "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 320 "NetworkSettings": { 321 "IpAddress": "", 322 "IpPrefixLen": 0, 323 "Gateway": "", 324 "Bridge": "", 325 "PortMapping": null 326 }, 327 "SysInitPath": "/home/kitty/go/src/github.com/docker/docker/bin/docker", 328 "ResolvConfPath": "/etc/resolv.conf", 329 "Volumes": {}, 330 "HostConfig": { 331 "Binds": null, 332 "ContainerIDFile": "", 333 "LxcConf": [], 334 "Privileged": false, 335 "PortBindings": { 336 "80/tcp": [ 337 { 338 "HostIp": "0.0.0.0", 339 "HostPort": "49153" 340 } 341 ] 342 }, 343 "Links": ["/name:alias"], 344 "PublishAllPorts": false, 345 "CapAdd": ["NET_ADMIN"], 346 "CapDrop": ["MKNOD"] 347 } 348 } 349 350 Status Codes: 351 352 - **200** – no error 353 - **404** – no such container 354 - **500** – server error 355 356 ### List processes running inside a container 357 358 `GET /containers/(id or name)/top` 359 360 List processes running inside the container `id`. On Unix systems this 361 is done by running the `ps` command. This endpoint is not 362 supported on Windows. 363 364 **Example request**: 365 366 GET /containers/4fa6e0f0c678/top HTTP/1.1 367 368 **Example response**: 369 370 HTTP/1.1 200 OK 371 Content-Type: application/json 372 373 { 374 "Titles" : [ 375 "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD" 376 ], 377 "Processes" : [ 378 [ 379 "root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash" 380 ], 381 [ 382 "root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10" 383 ] 384 ] 385 } 386 387 **Example request**: 388 389 GET /containers/4fa6e0f0c678/top?ps_args=aux HTTP/1.1 390 391 **Example response**: 392 393 HTTP/1.1 200 OK 394 Content-Type: application/json 395 396 { 397 "Titles" : [ 398 "USER","PID","%CPU","%MEM","VSZ","RSS","TTY","STAT","START","TIME","COMMAND" 399 ] 400 "Processes" : [ 401 [ 402 "root","13642","0.0","0.1","18172","3184","pts/0","Ss","17:03","0:00","/bin/bash" 403 ], 404 [ 405 "root","13895","0.0","0.0","4348","692","pts/0","S+","17:15","0:00","sleep 10" 406 ] 407 ], 408 } 409 410 Query Parameters: 411 412 - **ps_args** – `ps` arguments to use (e.g., `aux`), defaults to `-ef` 413 414 Status Codes: 415 416 - **200** – no error 417 - **404** – no such container 418 - **500** – server error 419 420 ### Get container logs 421 422 `GET /containers/(id or name)/logs` 423 424 Get stdout and stderr logs from the container ``id`` 425 426 **Example request**: 427 428 GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1&tail=10 HTTP/1.1 429 430 **Example response**: 431 432 HTTP/1.1 200 OK 433 Content-Type: application/vnd.docker.raw-stream 434 435 {{ STREAM }} 436 437 Query Parameters: 438 439 - **follow** – 1/True/true or 0/False/false, return stream. Default false 440 - **stdout** – 1/True/true or 0/False/false, show stdout log. Default false 441 - **stderr** – 1/True/true or 0/False/false, show stderr log. Default false 442 - **timestamps** – 1/True/true or 0/False/false, print timestamps for 443 every log line. Default false 444 - **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all 445 446 Status Codes: 447 448 - **200** – no error 449 - **404** – no such container 450 - **500** – server error 451 452 ### Inspect changes on a container's filesystem 453 454 `GET /containers/(id or name)/changes` 455 456 Inspect changes on container `id`'s filesystem 457 458 **Example request**: 459 460 GET /containers/4fa6e0f0c678/changes HTTP/1.1 461 462 **Example response**: 463 464 HTTP/1.1 200 OK 465 Content-Type: application/json 466 467 [ 468 { 469 "Path": "/dev", 470 "Kind": 0 471 }, 472 { 473 "Path": "/dev/kmsg", 474 "Kind": 1 475 }, 476 { 477 "Path": "/test", 478 "Kind": 1 479 } 480 ] 481 482 Status Codes: 483 484 - **200** – no error 485 - **404** – no such container 486 - **500** – server error 487 488 ### Export a container 489 490 `GET /containers/(id or name)/export` 491 492 Export the contents of container `id` 493 494 **Example request**: 495 496 GET /containers/4fa6e0f0c678/export HTTP/1.1 497 498 **Example response**: 499 500 HTTP/1.1 200 OK 501 Content-Type: application/octet-stream 502 503 {{ TAR STREAM }} 504 505 Status Codes: 506 507 - **200** – no error 508 - **404** – no such container 509 - **500** – server error 510 511 ### Resize a container TTY 512 513 `GET /containers/(id or name)/resize?h=<height>&w=<width>` 514 515 Resize the TTY of container `id` 516 517 **Example request**: 518 519 GET /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1 520 521 **Example response**: 522 523 HTTP/1.1 200 OK 524 Content-Length: 0 525 Content-Type: text/plain; charset=utf-8 526 527 Status Codes: 528 529 - **200** – no error 530 - **404** – No such container 531 - **500** – bad file descriptor 532 533 ### Start a container 534 535 `POST /containers/(id or name)/start` 536 537 Start the container `id` 538 539 **Example request**: 540 541 POST /containers/e90e34656806/start HTTP/1.1 542 Content-Type: application/json 543 544 { 545 "Binds": ["/tmp:/tmp"], 546 "Links": ["redis3:redis"], 547 "LxcConf": {"lxc.utsname":"docker"}, 548 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] }, 549 "PublishAllPorts": false, 550 "Privileged": false, 551 "Dns": ["8.8.8.8"], 552 "DnsSearch": [""], 553 "VolumesFrom": ["parent", "other:ro"], 554 "CapAdd": ["NET_ADMIN"], 555 "CapDrop": ["MKNOD"], 556 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 }, 557 "NetworkMode": "bridge", 558 "Devices": [] 559 } 560 561 **Example response**: 562 563 HTTP/1.1 204 No Content 564 565 Json Parameters: 566 567 - **Binds** – A list of volume bindings for this container. Each volume 568 binding is a string of the form `container_path` (to create a new 569 volume for the container), `host_path:container_path` (to bind-mount 570 a host path into the container), or `host_path:container_path:ro` 571 (to make the bind-mount read-only inside the container). 572 - **Links** - A list of links for the container. Each link entry should be of 573 of the form "container_name:alias". 574 - **LxcConf** - LXC specific configurations. These configurations will only 575 work when using the `lxc` execution driver. 576 - **PortBindings** - A map of exposed container ports and the host port they 577 should map to. It should be specified in the form 578 `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }` 579 Take note that `port` is specified as a string and not an integer value. 580 - **PublishAllPorts** - Allocates a random host port for all of a container's 581 exposed ports. Specified as a boolean value. 582 - **Privileged** - Gives the container full access to the host. Specified as 583 a boolean value. 584 - **Dns** - A list of dns servers for the container to use. 585 - **DnsSearch** - A list of DNS search domains 586 - **VolumesFrom** - A list of volumes to inherit from another container. 587 Specified in the form `<container name>[:<ro|rw>]` 588 - **CapAdd** - A list of kernel capabilities to add to the container. 589 - **Capdrop** - A list of kernel capabilities to drop from the container. 590 - **RestartPolicy** – The behavior to apply when the container exits. The 591 value is an object with a `Name` property of either `"always"` to 592 always restart or `"on-failure"` to restart only when the container 593 exit code is non-zero. If `on-failure` is used, `MaximumRetryCount` 594 controls the number of times to retry before giving up. 595 The default is not to restart. (optional) 596 An ever increasing delay (double the previous delay, starting at 100mS) 597 is added before each restart to prevent flooding the server. 598 - **NetworkMode** - Sets the networking mode for the container. Supported 599 values are: `bridge`, `host`, `none`, and `container:<name|id>` 600 - **Devices** - A list of devices to add to the container specified in the 601 form 602 `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}` 603 604 Status Codes: 605 606 - **204** – no error 607 - **304** – container already started 608 - **404** – no such container 609 - **500** – server error 610 611 ### Stop a container 612 613 `POST /containers/(id or name)/stop` 614 615 Stop the container `id` 616 617 **Example request**: 618 619 POST /containers/e90e34656806/stop?t=5 HTTP/1.1 620 621 **Example response**: 622 623 HTTP/1.1 204 No Content 624 625 Query Parameters: 626 627 - **t** – number of seconds to wait before killing the container 628 629 Status Codes: 630 631 - **204** – no error 632 - **304** – container already stopped 633 - **404** – no such container 634 - **500** – server error 635 636 ### Restart a container 637 638 `POST /containers/(id or name)/restart` 639 640 Restart the container `id` 641 642 **Example request**: 643 644 POST /containers/e90e34656806/restart?t=5 HTTP/1.1 645 646 **Example response**: 647 648 HTTP/1.1 204 No Content 649 650 Query Parameters: 651 652 - **t** – number of seconds to wait before killing the container 653 654 Status Codes: 655 656 - **204** – no error 657 - **404** – no such container 658 - **500** – server error 659 660 ### Kill a container 661 662 `POST /containers/(id or name)/kill` 663 664 Kill the container `id` 665 666 **Example request**: 667 668 POST /containers/e90e34656806/kill HTTP/1.1 669 670 **Example response**: 671 672 HTTP/1.1 204 No Content 673 674 Query Parameters 675 676 - **signal** - Signal to send to the container: integer or string like "SIGINT". 677 When not set, SIGKILL is assumed and the call will waits for the container to exit. 678 679 Status Codes: 680 681 - **204** – no error 682 - **404** – no such container 683 - **500** – server error 684 685 ### Pause a container 686 687 `POST /containers/(id or name)/pause` 688 689 Pause the container `id` 690 691 **Example request**: 692 693 POST /containers/e90e34656806/pause HTTP/1.1 694 695 **Example response**: 696 697 HTTP/1.1 204 No Content 698 699 Status Codes: 700 701 - **204** – no error 702 - **404** – no such container 703 - **500** – server error 704 705 ### Unpause a container 706 707 `POST /containers/(id or name)/unpause` 708 709 Unpause the container `id` 710 711 **Example request**: 712 713 POST /containers/e90e34656806/unpause HTTP/1.1 714 715 **Example response**: 716 717 HTTP/1.1 204 No Content 718 719 Status Codes: 720 721 - **204** – no error 722 - **404** – no such container 723 - **500** – server error 724 725 ### Attach to a container 726 727 `POST /containers/(id or name)/attach` 728 729 Attach to the container `id` 730 731 **Example request**: 732 733 POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1 734 735 **Example response**: 736 737 HTTP/1.1 200 OK 738 Content-Type: application/vnd.docker.raw-stream 739 740 {{ STREAM }} 741 742 Query Parameters: 743 744 - **logs** – 1/True/true or 0/False/false, return logs. Default false 745 - **stream** – 1/True/true or 0/False/false, return stream. 746 Default false 747 - **stdin** – 1/True/true or 0/False/false, if stream=true, attach 748 to stdin. Default false 749 - **stdout** – 1/True/true or 0/False/false, if logs=true, return 750 stdout log, if stream=true, attach to stdout. Default false 751 - **stderr** – 1/True/true or 0/False/false, if logs=true, return 752 stderr log, if stream=true, attach to stderr. Default false 753 754 Status Codes: 755 756 - **200** – no error 757 - **400** – bad parameter 758 - **404** – no such container 759 - **500** – server error 760 761 **Stream details**: 762 763 When using the TTY setting is enabled in 764 [`POST /containers/create`](#create-a-container), 765 the stream is the raw data from the process PTY and client's stdin. 766 When the TTY is disabled, then the stream is multiplexed to separate 767 stdout and stderr. 768 769 The format is a **Header** and a **Payload** (frame). 770 771 **HEADER** 772 773 The header will contain the information on which stream write the 774 stream (stdout or stderr). It also contain the size of the 775 associated frame encoded on the last 4 bytes (uint32). 776 777 It is encoded on the first 8 bytes like this: 778 779 header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} 780 781 `STREAM_TYPE` can be: 782 783 - 0: stdin (will be written on stdout) 784 - 1: stdout 785 - 2: stderr 786 787 `SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of 788 the uint32 size encoded as big endian. 789 790 **PAYLOAD** 791 792 The payload is the raw stream. 793 794 **IMPLEMENTATION** 795 796 The simplest way to implement the Attach protocol is the following: 797 798 1. Read 8 bytes 799 2. chose stdout or stderr depending on the first byte 800 3. Extract the frame size from the last 4 bytes 801 4. Read the extracted size and output it on the correct output 802 5. Goto 1 803 804 ### Attach to a container (websocket) 805 806 `GET /containers/(id or name)/attach/ws` 807 808 Attach to the container `id` via websocket 809 810 Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455) 811 812 **Example request** 813 814 GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1 815 816 **Example response** 817 818 {{ STREAM }} 819 820 Query Parameters: 821 822 - **logs** – 1/True/true or 0/False/false, return logs. Default false 823 - **stream** – 1/True/true or 0/False/false, return stream. 824 Default false 825 - **stdin** – 1/True/true or 0/False/false, if stream=true, attach 826 to stdin. Default false 827 - **stdout** – 1/True/true or 0/False/false, if logs=true, return 828 stdout log, if stream=true, attach to stdout. Default false 829 - **stderr** – 1/True/true or 0/False/false, if logs=true, return 830 stderr log, if stream=true, attach to stderr. Default false 831 832 Status Codes: 833 834 - **200** – no error 835 - **400** – bad parameter 836 - **404** – no such container 837 - **500** – server error 838 839 ### Wait a container 840 841 `POST /containers/(id or name)/wait` 842 843 Block until container `id` stops, then returns the exit code 844 845 **Example request**: 846 847 POST /containers/16253994b7c4/wait HTTP/1.1 848 849 **Example response**: 850 851 HTTP/1.1 200 OK 852 Content-Type: application/json 853 854 {"StatusCode": 0} 855 856 Status Codes: 857 858 - **200** – no error 859 - **404** – no such container 860 - **500** – server error 861 862 ### Remove a container 863 864 `DELETE /containers/(id or name)` 865 866 Remove the container `id` from the filesystem 867 868 **Example request**: 869 870 DELETE /containers/16253994b7c4?v=1 HTTP/1.1 871 872 **Example response**: 873 874 HTTP/1.1 204 No Content 875 876 Query Parameters: 877 878 - **v** – 1/True/true or 0/False/false, Remove the volumes 879 associated to the container. Default false 880 - **force** - 1/True/true or 0/False/false, Kill then remove the container. 881 Default false 882 883 Status Codes: 884 885 - **204** – no error 886 - **400** – bad parameter 887 - **404** – no such container 888 - **500** – server error 889 890 ### Copy files or folders from a container 891 892 `POST /containers/(id or name)/copy` 893 894 Copy files or folders of container `id` 895 896 **Example request**: 897 898 POST /containers/4fa6e0f0c678/copy HTTP/1.1 899 Content-Type: application/json 900 901 { 902 "Resource": "test.txt" 903 } 904 905 **Example response**: 906 907 HTTP/1.1 200 OK 908 Content-Type: application/x-tar 909 910 {{ TAR STREAM }} 911 912 Status Codes: 913 914 - **200** – no error 915 - **404** – no such container 916 - **500** – server error 917 918 ## 2.2 Images 919 920 ### List Images 921 922 `GET /images/json` 923 924 **Example request**: 925 926 GET /images/json?all=0 HTTP/1.1 927 928 **Example response**: 929 930 HTTP/1.1 200 OK 931 Content-Type: application/json 932 933 [ 934 { 935 "RepoTags": [ 936 "ubuntu:12.04", 937 "ubuntu:precise", 938 "ubuntu:latest" 939 ], 940 "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c", 941 "Created": 1365714795, 942 "Size": 131506275, 943 "VirtualSize": 131506275 944 }, 945 { 946 "RepoTags": [ 947 "ubuntu:12.10", 948 "ubuntu:quantal" 949 ], 950 "ParentId": "27cf784147099545", 951 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 952 "Created": 1364102658, 953 "Size": 24653, 954 "VirtualSize": 180116135 955 } 956 ] 957 958 959 Query Parameters: 960 961 - **all** – 1/True/true or 0/False/false, default false 962 - **filters** – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters: 963 - dangling=true 964 - **filter** - only return images with the specified name 965 966 ### Create an image 967 968 `POST /images/create` 969 970 Create an image, either by pulling it from the registry or by importing it 971 972 **Example request**: 973 974 POST /images/create?fromImage=ubuntu HTTP/1.1 975 976 **Example response**: 977 978 HTTP/1.1 200 OK 979 Content-Type: application/json 980 981 {"status": "Pulling..."} 982 {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}} 983 {"error": "Invalid..."} 984 ... 985 986 When using this endpoint to pull an image from the registry, the 987 `X-Registry-Auth` header can be used to include 988 a base64-encoded AuthConfig object. 989 990 Query Parameters: 991 992 - **fromImage** – name of the image to pull 993 - **fromSrc** – source to import. The value may be a URL from which the image 994 can be retrieved or `-` to read the image from the request body. 995 - **repo** – repository 996 - **tag** – tag 997 - **registry** – the registry to pull from 998 999 Request Headers: 1000 1001 - **X-Registry-Auth** – base64-encoded AuthConfig object 1002 1003 Status Codes: 1004 1005 - **200** – no error 1006 - **500** – server error 1007 1008 1009 1010 ### Inspect an image 1011 1012 `GET /images/(name)/json` 1013 1014 Return low-level information on the image `name` 1015 1016 **Example request**: 1017 1018 GET /images/ubuntu/json HTTP/1.1 1019 1020 **Example response**: 1021 1022 HTTP/1.1 200 OK 1023 Content-Type: application/json 1024 1025 { 1026 "Created": "2013-03-23T22:24:18.818426-07:00", 1027 "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0", 1028 "ContainerConfig": 1029 { 1030 "Hostname": "", 1031 "User": "", 1032 "Memory": 0, 1033 "MemorySwap": 0, 1034 "AttachStdin": false, 1035 "AttachStdout": false, 1036 "AttachStderr": false, 1037 "PortSpecs": null, 1038 "Tty": true, 1039 "OpenStdin": true, 1040 "StdinOnce": false, 1041 "Env": null, 1042 "Cmd": ["/bin/bash"], 1043 "Dns": null, 1044 "Image": "ubuntu", 1045 "Volumes": null, 1046 "VolumesFrom": "", 1047 "WorkingDir": "" 1048 }, 1049 "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc", 1050 "Parent": "27cf784147099545", 1051 "Size": 6824592 1052 } 1053 1054 Status Codes: 1055 1056 - **200** – no error 1057 - **404** – no such image 1058 - **500** – server error 1059 1060 ### Get the history of an image 1061 1062 `GET /images/(name)/history` 1063 1064 Return the history of the image `name` 1065 1066 **Example request**: 1067 1068 GET /images/ubuntu/history HTTP/1.1 1069 1070 **Example response**: 1071 1072 HTTP/1.1 200 OK 1073 Content-Type: application/json 1074 1075 [ 1076 { 1077 "Id": "b750fe79269d", 1078 "Created": 1364102658, 1079 "CreatedBy": "/bin/bash" 1080 }, 1081 { 1082 "Id": "27cf78414709", 1083 "Created": 1364068391, 1084 "CreatedBy": "" 1085 } 1086 ] 1087 1088 Status Codes: 1089 1090 - **200** – no error 1091 - **404** – no such image 1092 - **500** – server error 1093 1094 ### Push an image on the registry 1095 1096 `POST /images/(name)/push` 1097 1098 Push the image `name` on the registry 1099 1100 **Example request**: 1101 1102 POST /images/test/push HTTP/1.1 1103 1104 **Example response**: 1105 1106 HTTP/1.1 200 OK 1107 Content-Type: application/json 1108 1109 {"status": "Pushing..."} 1110 {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}} 1111 {"error": "Invalid..."} 1112 ... 1113 1114 If you wish to push an image on to a private registry, that image must already have been tagged 1115 into a repository which references that registry host name and port. This repository name should 1116 then be used in the URL. This mirrors the flow of the CLI. 1117 1118 **Example request**: 1119 1120 POST /images/registry.acme.com:5000/test/push HTTP/1.1 1121 1122 1123 Query Parameters: 1124 1125 - **tag** – the tag to associate with the image on the registry, optional 1126 1127 Request Headers: 1128 1129 - **X-Registry-Auth** – include a base64-encoded AuthConfig 1130 object. 1131 1132 Status Codes: 1133 1134 - **200** – no error 1135 - **404** – no such image 1136 - **500** – server error 1137 1138 ### Tag an image into a repository 1139 1140 `POST /images/(name)/tag` 1141 1142 Tag the image `name` into a repository 1143 1144 **Example request**: 1145 1146 POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1 1147 1148 **Example response**: 1149 1150 HTTP/1.1 201 Created 1151 1152 Query Parameters: 1153 1154 - **repo** – The repository to tag in 1155 - **force** – 1/True/true or 0/False/false, default false 1156 - **tag** - The new tag name 1157 1158 Status Codes: 1159 1160 - **201** – no error 1161 - **400** – bad parameter 1162 - **404** – no such image 1163 - **409** – conflict 1164 - **500** – server error 1165 1166 ### Remove an image 1167 1168 `DELETE /images/(name)` 1169 1170 Remove the image `name` from the filesystem 1171 1172 **Example request**: 1173 1174 DELETE /images/test HTTP/1.1 1175 1176 **Example response**: 1177 1178 HTTP/1.1 200 OK 1179 Content-type: application/json 1180 1181 [ 1182 {"Untagged": "3e2f21a89f"}, 1183 {"Deleted": "3e2f21a89f"}, 1184 {"Deleted": "53b4f83ac9"} 1185 ] 1186 1187 Query Parameters: 1188 1189 - **force** – 1/True/true or 0/False/false, default false 1190 - **noprune** – 1/True/true or 0/False/false, default false 1191 1192 Status Codes: 1193 1194 - **200** – no error 1195 - **404** – no such image 1196 - **409** – conflict 1197 - **500** – server error 1198 1199 ### Search images 1200 1201 `GET /images/search` 1202 1203 Search for an image on [Docker Hub](https://hub.docker.com). 1204 1205 > **Note**: 1206 > The response keys have changed from API v1.6 to reflect the JSON 1207 > sent by the registry server to the docker daemon's request. 1208 1209 **Example request**: 1210 1211 GET /images/search?term=sshd HTTP/1.1 1212 1213 **Example response**: 1214 1215 HTTP/1.1 200 OK 1216 Content-Type: application/json 1217 1218 [ 1219 { 1220 "description": "", 1221 "is_official": false, 1222 "is_automated": false, 1223 "name": "wma55/u1210sshd", 1224 "star_count": 0 1225 }, 1226 { 1227 "description": "", 1228 "is_official": false, 1229 "is_automated": false, 1230 "name": "jdswinbank/sshd", 1231 "star_count": 0 1232 }, 1233 { 1234 "description": "", 1235 "is_official": false, 1236 "is_automated": false, 1237 "name": "vgauthier/sshd", 1238 "star_count": 0 1239 } 1240 ... 1241 ] 1242 1243 Query Parameters: 1244 1245 - **term** – term to search 1246 1247 Status Codes: 1248 1249 - **200** – no error 1250 - **500** – server error 1251 1252 ## 2.3 Misc 1253 1254 ### Build an image from Dockerfile via stdin 1255 1256 `POST /build` 1257 1258 Build an image from Dockerfile via stdin 1259 1260 **Example request**: 1261 1262 POST /build HTTP/1.1 1263 1264 {{ TAR STREAM }} 1265 1266 **Example response**: 1267 1268 HTTP/1.1 200 OK 1269 Content-Type: application/json 1270 1271 {"stream": "Step 1..."} 1272 {"stream": "..."} 1273 {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}} 1274 1275 The stream must be a tar archive compressed with one of the 1276 following algorithms: identity (no compression), gzip, bzip2, xz. 1277 1278 The archive must include a file called `Dockerfile` 1279 at its root. It may include any number of other files, 1280 which will be accessible in the build context (See the [*ADD build 1281 command*](../../reference/builder.md#dockerbuilder)). 1282 1283 Query Parameters: 1284 1285 - **t** – repository name (and optionally a tag) to be applied to 1286 the resulting image in case of success 1287 - **remote** – git or HTTP/HTTPS URI build source 1288 - **q** – suppress verbose build output 1289 - **nocache** – do not use the cache when building the image 1290 - **rm** - remove intermediate containers after a successful build (default behavior) 1291 - **forcerm** - always remove intermediate containers (includes rm) 1292 1293 Request Headers: 1294 1295 - **Content-type** – should be set to `"application/tar"`. 1296 - **X-Registry-Config** – base64-encoded ConfigFile object 1297 1298 Status Codes: 1299 1300 - **200** – no error 1301 - **500** – server error 1302 1303 ### Check auth configuration 1304 1305 `POST /auth` 1306 1307 Get the default username and email 1308 1309 **Example request**: 1310 1311 POST /auth HTTP/1.1 1312 Content-Type: application/json 1313 1314 { 1315 "username":" hannibal", 1316 "password: "xxxx", 1317 "email": "hannibal@a-team.com", 1318 "serveraddress": "https://index.docker.io/v1/" 1319 } 1320 1321 **Example response**: 1322 1323 HTTP/1.1 200 OK 1324 1325 Status Codes: 1326 1327 - **200** – no error 1328 - **204** – no error 1329 - **500** – server error 1330 1331 ### Display system-wide information 1332 1333 `GET /info` 1334 1335 Display system-wide information 1336 1337 **Example request**: 1338 1339 GET /info HTTP/1.1 1340 1341 **Example response**: 1342 1343 HTTP/1.1 200 OK 1344 Content-Type: application/json 1345 1346 { 1347 "Containers": 11, 1348 "Images": 16, 1349 "Driver": "btrfs", 1350 "ExecutionDriver": "native-0.1", 1351 "KernelVersion": "3.12.0-1-amd64" 1352 "Debug": false, 1353 "NFd": 11, 1354 "NGoroutines": 21, 1355 "NEventsListener": 0, 1356 "InitPath": "/usr/bin/docker", 1357 "IndexServerAddress": ["https://index.docker.io/v1/"], 1358 "MemoryLimit": true, 1359 "SwapLimit": false, 1360 "IPv4Forwarding": true 1361 } 1362 1363 Status Codes: 1364 1365 - **200** – no error 1366 - **500** – server error 1367 1368 ### Show the docker version information 1369 1370 `GET /version` 1371 1372 Show the docker version information 1373 1374 **Example request**: 1375 1376 GET /version HTTP/1.1 1377 1378 **Example response**: 1379 1380 HTTP/1.1 200 OK 1381 Content-Type: application/json 1382 1383 { 1384 "ApiVersion": "1.12", 1385 "Version": "0.2.2", 1386 "GitCommit": "5a2a5cc+CHANGES", 1387 "GoVersion": "go1.0.3" 1388 } 1389 1390 Status Codes: 1391 1392 - **200** – no error 1393 - **500** – server error 1394 1395 ### Ping the docker server 1396 1397 `GET /_ping` 1398 1399 Ping the docker server 1400 1401 **Example request**: 1402 1403 GET /_ping HTTP/1.1 1404 1405 **Example response**: 1406 1407 HTTP/1.1 200 OK 1408 Content-Type: text/plain 1409 1410 OK 1411 1412 Status Codes: 1413 1414 - **200** - no error 1415 - **500** - server error 1416 1417 ### Create a new image from a container's changes 1418 1419 `POST /commit` 1420 1421 Create a new image from a container's changes 1422 1423 **Example request**: 1424 1425 POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1 1426 Content-Type: application/json 1427 1428 { 1429 "Hostname": "", 1430 "Domainname": "", 1431 "User": "", 1432 "Memory": 0, 1433 "MemorySwap": 0, 1434 "CpuShares": 512, 1435 "Cpuset": "0,1", 1436 "AttachStdin": false, 1437 "AttachStdout": true, 1438 "AttachStderr": true, 1439 "PortSpecs": null, 1440 "Tty": false, 1441 "OpenStdin": false, 1442 "StdinOnce": false, 1443 "Env": null, 1444 "Cmd": [ 1445 "date" 1446 ], 1447 "Volumes": { 1448 "/tmp": {} 1449 }, 1450 "WorkingDir": "", 1451 "NetworkDisabled": false, 1452 "ExposedPorts": { 1453 "22/tcp": {} 1454 } 1455 } 1456 1457 **Example response**: 1458 1459 HTTP/1.1 201 Created 1460 Content-Type: application/json 1461 1462 {"Id": "596069db4bf5"} 1463 1464 Json Parameters: 1465 1466 - **config** - the container's configuration 1467 1468 Query Parameters: 1469 1470 - **container** – source container 1471 - **repo** – repository 1472 - **tag** – tag 1473 - **comment** – commit message 1474 - **author** – author (e.g., "John Hannibal Smith 1475 <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>") 1476 1477 Status Codes: 1478 1479 - **201** – no error 1480 - **404** – no such container 1481 - **500** – server error 1482 1483 ### Monitor Docker's events 1484 1485 `GET /events` 1486 1487 Get container events from docker, either in real time via streaming, or via 1488 polling (using since). 1489 1490 Docker containers will report the following events: 1491 1492 create, destroy, die, export, kill, pause, restart, start, stop, unpause 1493 1494 and Docker images will report: 1495 1496 untag, delete 1497 1498 **Example request**: 1499 1500 GET /events?since=1374067924 1501 1502 **Example response**: 1503 1504 HTTP/1.1 200 OK 1505 Content-Type: application/json 1506 1507 {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 1508 {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924} 1509 {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966} 1510 {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970} 1511 1512 Query Parameters: 1513 1514 - **since** – timestamp used for polling 1515 - **until** – timestamp used for polling 1516 1517 Status Codes: 1518 1519 - **200** – no error 1520 - **500** – server error 1521 1522 ### Get a tarball containing all images in a repository 1523 1524 `GET /images/(name)/get` 1525 1526 Get a tarball containing all images and metadata for the repository specified 1527 by `name`. 1528 1529 If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image 1530 (and its parents) are returned. If `name` is an image ID, similarly only that 1531 image (and its parents) are returned, but with the exclusion of the 1532 'repositories' file in the tarball, as there were no image names referenced. 1533 1534 See the [image tarball format](#image-tarball-format) for more details. 1535 1536 **Example request** 1537 1538 GET /images/ubuntu/get 1539 1540 **Example response**: 1541 1542 HTTP/1.1 200 OK 1543 Content-Type: application/x-tar 1544 1545 Binary data stream 1546 1547 Status Codes: 1548 1549 - **200** – no error 1550 - **500** – server error 1551 1552 ### Get a tarball containing all images. 1553 1554 `GET /images/get` 1555 1556 Get a tarball containing all images and metadata for one or more repositories. 1557 1558 For each value of the `names` parameter: if it is a specific name and tag (e.g. 1559 ubuntu:latest), then only that image (and its parents) are returned; if it is 1560 an image ID, similarly only that image (and its parents) are returned and there 1561 would be no names referenced in the 'repositories' file for this image ID. 1562 1563 See the [image tarball format](#image-tarball-format) for more details. 1564 1565 **Example request** 1566 1567 GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox 1568 1569 **Example response**: 1570 1571 HTTP/1.1 200 OK 1572 Content-Type: application/x-tar 1573 1574 Binary data stream 1575 1576 Status Codes: 1577 1578 - **200** – no error 1579 - **500** – server error 1580 1581 ### Load a tarball with a set of images and tags into docker 1582 1583 `POST /images/load` 1584 1585 Load a set of images and tags into the docker repository. 1586 See the [image tarball format](#image-tarball-format) for more details. 1587 1588 **Example request** 1589 1590 POST /images/load 1591 1592 Tarball in body 1593 1594 **Example response**: 1595 1596 HTTP/1.1 200 OK 1597 1598 Status Codes: 1599 1600 - **200** – no error 1601 - **500** – server error 1602 1603 ### Image tarball format 1604 1605 An image tarball contains one directory per image layer (named using its long ID), 1606 each containing three files: 1607 1608 1. `VERSION`: currently `1.0` - the file format version 1609 2. `json`: detailed layer information, similar to `docker inspect layer_id` 1610 3. `layer.tar`: A tarfile containing the filesystem changes in this layer 1611 1612 The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories 1613 for storing attribute changes and deletions. 1614 1615 If the tarball defines a repository, there will also be a `repositories` file at 1616 the root that contains a list of repository and tag names mapped to layer IDs. 1617 1618 ``` 1619 {"hello-world": 1620 {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"} 1621 } 1622 ``` 1623 1624 ### Exec Create 1625 1626 `POST /containers/(id or name)/exec` 1627 1628 Sets up an exec instance in a running container `id` 1629 1630 **Example request**: 1631 1632 POST /containers/e90e34656806/exec HTTP/1.1 1633 Content-Type: application/json 1634 1635 { 1636 "AttachStdin": false, 1637 "AttachStdout": true, 1638 "AttachStderr": true, 1639 "Tty": false, 1640 "Cmd": [ 1641 "date" 1642 ], 1643 } 1644 1645 **Example response**: 1646 1647 HTTP/1.1 201 Created 1648 Content-Type: application/json 1649 1650 { 1651 "Id": "f90e34656806" 1652 } 1653 1654 Json Parameters: 1655 1656 - **AttachStdin** - Boolean value, attaches to stdin of the exec command. 1657 - **AttachStdout** - Boolean value, attaches to stdout of the exec command. 1658 - **AttachStderr** - Boolean value, attaches to stderr of the exec command. 1659 - **Tty** - Boolean value to allocate a pseudo-TTY 1660 - **Cmd** - Command to run specified as a string or an array of strings. 1661 1662 1663 Status Codes: 1664 1665 - **201** – no error 1666 - **404** – no such container 1667 1668 ### Exec Start 1669 1670 `POST /exec/(id)/start` 1671 1672 Starts a previously set up exec instance `id`. If `detach` is true, this API 1673 returns after starting the `exec` command. Otherwise, this API sets up an 1674 interactive session with the `exec` command. 1675 1676 **Example request**: 1677 1678 POST /exec/e90e34656806/start HTTP/1.1 1679 Content-Type: application/json 1680 1681 { 1682 "Detach": false, 1683 "Tty": false, 1684 } 1685 1686 **Example response**: 1687 1688 HTTP/1.1 200 OK 1689 Content-Type: application/vnd.docker.raw-stream 1690 1691 {{ STREAM }} 1692 1693 Json Parameters: 1694 1695 - **Detach** - Detach from the exec command 1696 - **Tty** - Boolean value to allocate a pseudo-TTY 1697 1698 Status Codes: 1699 1700 - **200** – no error 1701 - **404** – no such exec instance 1702 1703 **Stream details**: 1704 Similar to the stream behavior of `POST /containers/(id or name)/attach` API 1705 1706 ### Exec Resize 1707 1708 `POST /exec/(id)/resize` 1709 1710 Resizes the tty session used by the exec command `id`. 1711 This API is valid only if `tty` was specified as part of creating and starting the exec command. 1712 1713 **Example request**: 1714 1715 POST /exec/e90e34656806/resize HTTP/1.1 1716 Content-Type: plain/text 1717 1718 **Example response**: 1719 1720 HTTP/1.1 201 Created 1721 Content-Type: plain/text 1722 1723 Query Parameters: 1724 1725 - **h** – height of tty session 1726 - **w** – width 1727 1728 Status Codes: 1729 1730 - **201** – no error 1731 - **404** – no such exec instance 1732 1733 # 3. Going further 1734 1735 ## 3.1 Inside `docker run` 1736 1737 As an example, the `docker run` command line makes the following API calls: 1738 1739 - Create the container 1740 1741 - If the status code is 404, it means the image doesn't exist: 1742 - Try to pull it 1743 - Then retry to create the container 1744 1745 - Start the container 1746 1747 - If you are not in detached mode: 1748 - Attach to the container, using logs=1 (to have stdout and 1749 stderr from the container's start) and stream=1 1750 1751 - If in detached mode or only stdin is attached: 1752 - Display the container's id 1753 1754 ## 3.2 Hijacking 1755 1756 In this version of the API, /attach, uses hijacking to transport stdin, 1757 stdout and stderr on the same socket. This might change in the future. 1758 1759 ## 3.3 CORS Requests 1760 1761 To enable cross origin requests to the remote api add the flag 1762 "--api-enable-cors" when running docker in daemon mode. 1763 1764 $ docker -d -H="192.168.1.9:2375" --api-enable-cors