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