Docker Remote API v1.21
Brief introduction¶
-
The Remote API has replaced
rcli. -
The daemon listens on
unix:///var/run/docker.sockbut you can Bind Docker to another host/port or a Unix socket. -
The API tends to be REST. However, for some complex commands, like
attachorpull, the HTTP connection is hijacked to transportstdout,stdinandstderr. -
When the client API version is newer than the daemon’s, these calls return an HTTP
400 Bad Requesterror message.
Endpoints¶
Containers¶
List containersGET/containers/json{?all,limit,since,before,size,filters}
Status Codes:
-
200 - no error
-
400 - bad parameter
-
500 - server error
- all
string(required) Example: 01/True/true or 0/False/false, Show all containers. Only running containers are shown by default (i.e., this defaults to false)
- limit
number(required)Show
limitlast created containers, include non-running ones.- since
string(required)Show only containers created since Id, include non-running ones.
- before
string(required) Example: 8dfafdbc3a40Show only containers created before Id, include non-running ones.
- size
string(required) Example: 11/True/true or 0/False/false, Show the containers sizes
- filters
string) - a JSON encoded value of the filters (a(required) Example: map[string][]string-
exited=<int>; – containers with exit code of<int>; -
status=(created|restarting|running|paused|exited) -
label=keyorlabel="key=value"of a container label
-
Headers
Content-Type: application/jsonBody
GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1200Headers
Content-Type: application/jsonBody
[
{
"Id": "8dfafdbc3a40",
"Names": [
"/boring_feynman"
],
"Image": "ubuntu:latest",
"Command": "echo 1",
"Created": 1367854155,
"Status": "Exit 0",
"Ports": [
{
"PrivatePort": 2222,
"PublicPort": 3333,
"Type": "tcp"
}
],
"Labels": {
"com.example.vendor": "Acme",
"com.example.license": "GPL",
"com.example.version": "1.0"
},
"SizeRw": 12288,
"SizeRootFs": 0
},
{
"Id": "9cd87474be90",
"Names": [
"/coolName"
],
"Image": "ubuntu:latest",
"Command": "echo 222222",
"Created": 1367854155,
"Status": "Exit 0",
"Ports": [],
"Labels": {},
"SizeRw": 12288,
"SizeRootFs": 0
},
{
"Id": "3176a2479c92",
"Names": [
"/sleepy_dog"
],
"Image": "ubuntu:latest",
"Command": "echo 3333333333333333",
"Created": 1367854154,
"Status": "Exit 0",
"Ports": [],
"Labels": {},
"SizeRw": 12288,
"SizeRootFs": 0
},
{
"Id": "4cb07b47f9fb",
"Names": [
"/running_cat"
],
"Image": "ubuntu:latest",
"Command": "echo 444444444444444444444444444444444",
"Created": 1367854152,
"Status": "Exit 0",
"Ports": [],
"Labels": {},
"SizeRw": 12288,
"SizeRootFs": 0
}
]Create a containerPOST/containers/create
Create a container
Status Codes:
-
201 - no error
-
404 - no such container
-
406 - impossible to attach (container not running)
-
500 - server error
Headers
Content-Type: application/jsonBody
{
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"date"
],
"Entrypoint": "",
"Image": "ubuntu",
"Labels": {
"com.example.vendor": "Acme",
"com.example.license": "GPL",
"com.example.version": "1.0"
},
"Mounts": [
{
"Source": "/data",
"Destination": "/data",
"Mode": "ro,Z",
"RW": false
}
],
"WorkingDir": "",
"NetworkDisabled": false,
"MacAddress": "12:34:56:78:9a:bc",
"ExposedPorts": {
"22/tcp": {}
},
"StopSignal": "SIGTERM",
"HostConfig": {
"Binds": [
"/tmp:/tmp"
],
"Links": [
"redis3:redis"
],
"LxcConf": {
"lxc.utsname": "docker"
},
"Memory": 0,
"MemorySwap": 0,
"KernelMemory": 0,
"CpuShares": 512,
"CpuPeriod": 100000,
"CpusetCpus": "0,1",
"CpusetMems": "0,1",
"BlkioWeight": 300,
"MemorySwappiness": 60,
"OomKillDisable": false,
"PortBindings": {
"22/tcp": [
{
"HostPort": "11022"
}
]
},
"PublishAllPorts": false,
"Privileged": false,
"ReadonlyRootfs": false,
"Dns": [
"8.8.8.8"
],
"DnsOptions": [
""
],
"DnsSearch": [
""
],
"ExtraHosts": null,
"VolumesFrom": [
"parent",
"other:ro"
],
"CapAdd": [
"NET_ADMIN"
],
"CapDrop": [
"MKNOD"
],
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"NetworkMode": "bridge",
"Devices": [],
"Ulimits": [
{}
],
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"SecurityOpt": [
""
],
"CgroupParent": "",
"VolumeDriver": ""
}
}Schema
{
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#"
}201Headers
Content-Type: application/jsonBody
{
"Id": "e90e34656806",
"Warnings": []
}Schema
{
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#"
}Inspect a containerGET/containers/json
Return low-level information on the container id
Status Codes:
-
200 - no error
-
404 - no such container
-
500 - server error
Headers
Content-Type: application/jsonBody
GET /containers/4fa6e0f0c678/json HTTP/1.1200Headers
Content-Type: application/jsonBody
{
"AppArmorProfile": "",
"Args": [
"-c",
"exit 9"
],
"Config": {
"AttachStderr": true,
"AttachStdin": false,
"AttachStdout": true,
"Cmd": [
"/bin/sh",
"-c",
"exit 9"
],
"Domainname": "",
"Entrypoint": null,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"ExposedPorts": null,
"Hostname": "ba033ac44011",
"Image": "ubuntu",
"Labels": {
"com.example.vendor": "Acme",
"com.example.license": "GPL",
"com.example.version": "1.0"
},
"MacAddress": "",
"NetworkDisabled": false,
"OnBuild": null,
"OpenStdin": false,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": null,
"WorkingDir": "",
"StopSignal": "SIGTERM"
},
"Created": "2015-01-06T15:47:31.485331387Z",
"Driver": "devicemapper",
"ExecDriver": "native-0.2",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"BlkioWeight": 0,
"CapAdd": null,
"CapDrop": null,
"ContainerIDFile": "",
"CpusetCpus": "",
"CpusetMems": "",
"CpuShares": 0,
"CpuPeriod": 100000,
"Devices": [],
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"IpcMode": "",
"Links": null,
"LxcConf": [],
"Memory": 0,
"MemorySwap": 0,
"KernelMemory": 0,
"OomKillDisable": false,
"NetworkMode": "bridge",
"PortBindings": {},
"Privileged": false,
"ReadonlyRootfs": false,
"PublishAllPorts": false,
"RestartPolicy": {
"MaximumRetryCount": 2,
"Name": "on-failure"
},
"LogConfig": {
"Config": null,
"Type": "json-file"
},
"SecurityOpt": null,
"VolumesFrom": null,
"Ulimits": [
{}
],
"VolumeDriver": ""
},
"HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
"HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
"Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
"Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
"MountLabel": "",
"Name": "/boring_euclid",
"NetworkSettings": {
"Bridge": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"MacAddress": "",
"Ports": null
},
"Path": "/bin/sh",
"ProcessLabel": "",
"ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
"RestartCount": 1,
"State": {
"Error": "",
"ExitCode": 9,
"FinishedAt": "2015-01-06T15:47:32.080254511Z",
"OOMKilled": false,
"Paused": false,
"Pid": 0,
"Restarting": false,
"Running": true,
"StartedAt": "2015-01-06T15:47:32.072697474Z",
"Status": "running"
},
"Mounts": [
{
"Source": "/data",
"Destination": "/data",
"Mode": "ro,Z",
"RW": false
}
]
}List processes running inside a containerGET/containers/{id}/(ps_args)
List processes running inside the container id
Status Codes:
-
200 – no error
-
404 – no such container
-
500 – server error
- id
string(required) Example: 4fa6e0f0c678container id
- ps_args
string(required) Example: topps arguments to use (e.g., aux)
Headers
Content-Type: application/jsonBody
GET /containers/4fa6e0f0c678/top HTTP/1.1200Headers
Content-Type: application/jsonBody
{
"Titles": [
"USER",
"PID",
"%CPU",
"%MEM",
"VSZ",
"RSS",
"TTY",
"STAT",
"START",
"TIME",
"COMMAND"
],
"Processes": [
[
"root",
"20147",
"0.0",
"0.1",
"18060",
"1864",
"pts/4",
"S",
"10:06",
"0:00",
"bash"
],
[
"root",
"20271",
"0.0",
"0.0",
"4312",
"352",
"pts/4",
"S+",
"10:07",
"0:00",
"sleep",
"10"
]
]
}Get container logsGET/containers/logs{?follow,stdout,stderr,since,timestamps,tail}
Get stdout and stderr logs from the container id
Note: This endpoint works only for containers with
json-filelogging driver.
Status Codes:
-
101 - no error, hints proxy about hijacking
-
200 - no error, no upgrade header found
-
404 - no such container
-
500 - server error
- follow
string(required) Example: false1/True/true or 0/False/false, return stream. Default
false.- stdout
string(required) Example: false1/True/true or 0/False/false, show
stdoutlog. Defaultfalse.- stderr
string(required) Example: false1/True/true or 0/False/false, show
stderrlog. Defaultfalse.- since
string(required) Example: 0UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default: 0 (unfiltered)
- timestamps
string(required) Example: false1/True/true or 0/False/false, print timestamps for every log line. Default
false.- tail
string(required) Example: allOutput specified number of lines at the end of logs:
allor<number>. Default all.
Headers
Content-Type: application/jsonBody
GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1×tamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1101Headers
Content-Type: application/vnd.docker.raw-streamInspect changes on a container's filesystemGET/containers/{id}/changes
Inspect changes on container id's filesystem
Status Codes:
-
200 - no error
-
404 - no such container
-
500 - server error
- id
string(required) Example: 4fa6e0f0c678container id
Headers
Content-Type: application/jsonBody
GET /containers/4fa6e0f0c678/changes HTTP/1.1200Headers
Content-Type: application/jsonBody
[
{
"Path": "/dev",
"Kind": 0
},
{
"Path": "/dev/kmsg",
"Kind": 1
},
{
"Path": "/test",
"Kind": 1
}
]Schema
{
"type": "object",
"properties": {
"Path": {
"type": "string"
},
"Kind": {
"type": "string",
"description": "`0`: Modify, `1`: Add, `2`: Delete"
}
},
"$schema": "http://json-schema.org/draft-04/schema#"
}Export a containerGET/containers/export
Export the contents of container id
Status Codes:
-
200 - no error
-
404 - no such container
-
500 - server error
Headers
Content-Type: application/jsonBody
GET /containers/4fa6e0f0c678/export HTTP/1.1200Headers
Content-Type: application/jsonBody
{{ TAR STREAM }}Get container stats based on resource usageGET/containers/stats{?stream}
This endpoint returns a live stream of a container’s resource usage statistics.
Note: this functionality currently only works when using the libcontainer exec-driver.
Status Codes:
-
200 - no error
-
404 - no such container
-
500 - server error
- stream
string(required) Example: true1/True/true or 0/False/false, pull stats once then disconnect. Default
true.
Body
GET /containers/redis1/stats HTTP/1.1200Headers
Content-Type: application/jsonBody
{
"read": "2015-01-08T22:57:31.547920715Z",
"network": {
"eth0": {
"rx_bytes": 5338,
"rx_dropped": 0,
"rx_errors": 0,
"rx_packets": 36,
"tx_bytes": 648,
"tx_dropped": 0,
"tx_errors": 0,
"tx_packets": 8
},
"eth5": {
"rx_bytes": 4641,
"rx_dropped": 0,
"rx_errors": 0,
"rx_packets": 26,
"tx_bytes": 690,
"tx_dropped": 0,
"tx_errors": 0,
"tx_packets": 9
}
},
"memory_stats": {
"stats": {
"total_pgmajfault": 0,
"cache": 0,
"mapped_file": 0,
"total_inactive_file": 0,
"pgpgout": 414,
"rss": 6537216,
"total_mapped_file": 0,
"writeback": 0,
"unevictable": 0,
"pgpgin": 477,
"total_unevictable": 0,
"pgmajfault": 0,
"total_rss": 6537216,
"total_rss_huge": 6291456,
"total_writeback": 0,
"total_inactive_anon": 0,
"rss_huge": 6291456,
"hierarchical_memory_limit": 67108864,
"total_pgfault": 964,
"total_active_file": 0,
"active_anon": 6537216,
"total_active_anon": 6537216,
"total_pgpgout": 414,
"total_cache": 0,
"inactive_anon": 0,
"active_file": 0,
"pgfault": 964,
"inactive_file": 0,
"total_pgpgin": 477
},
"max_usage": 6651904,
"usage": 6537216,
"failcnt": 0,
"limit": 67108864
},
"blkio_stats": {},
"cpu_stats": {
"cpu_usage": {
"percpu_usage": [
16970827,
1839451,
7107380,
10571290
],
"usage_in_usermode": 10000000,
"total_usage": 36488948,
"usage_in_kernelmode": 20000000
},
"system_cpu_usage": 20091722000000000,
"throttling_data": {}
}
}Resize a container TTYPOST/containers/resize{?h,w}
Resize the TTY for container with id. The unit is number of characters. You must restart the container for the resize to take effect.
Status Codes:
-
200 - no error
-
404 - No such container
-
500 - Cannot resize container
- h
number(required) Example: 40height of
ttysession- w
number(required) Example: 80width
Body
POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1200Headers
Content-Type: text/plain; charset=utf-8Start a containerPOST/containers/start
Start the container id
Note: For backwards compatibility, this endpoint accepts a
HostConfigas JSON-encoded request body. See create a container for details.
Status Codes:
-
200 - no error
-
304 - container already started
-
404 - no such container
-
500 - server error
Headers
Content-Type: application/jsonBody
POST /containers/e90e34656806/start HTTP/1.1204Headers
Content-Type: application/jsonStop a containerPOST/containers/stop
Stop the container id
Status Codes:
-
204 - no error
-
304 - container already stopped
-
404 - no such container
-
500 - server error
- t
string(required)number of seconds to wait before killing the container
Headers
Content-Type: application/jsonBody
POST /containers/e90e34656806/stop?t=5 HTTP/1.1204Headers
Content-Type: application/jsonRestart a containerPOST/containers/restart{?t}
Restart the container id
Status Codes:
-
204 - no error
-
404 - no such container
-
500 - server error
- t
string(required)number of seconds to wait before killing the container
204Headers
Content-Type: application/jsonKill a containerPOST/containers/kill
Kill the container id
Status Codes:
-
204 - no error
-
404 - no such container
-
500 - server error
-
Parameters:
- signal (string) - Signal to send to the container: integer or string like
SIGINT. When not set,SIGKILLis assumed and the call waits for the container to exit.
- signal (string) - Signal to send to the container: integer or string like
Headers
Content-Type: application/jsonBody
POST /containers/e90e34656806/kill HTTP/1.1204Headers
Content-Type: application/jsonRename a containerPOST/containers/rename{?name}
Rename the container id to a new_name
Status Codes:
-
204 - no error
-
404 - no such container
-
409 - conflict name already assigned
-
500 - server error
- name
string(required) Example: new_namenew name for the container
204Pause a containerPOST/containers/{id}/pause
Pause the container id
Status Codes:
-
204 - no error
-
404 - no such container
-
500 - server error
- id
string(required) Example: e90e34656806
204Unpause a containerPOST/containers/{id}/unpause
Unpause the container id
Status Codes:
-
204 - no error
-
404 - no such container
-
500 - server error
- id
string(required) Example: e90e34656806
204Attach to a containerPOST/containers/attach{?logs,stream,stdin,stdout,stderr}
Attach to the container id
Status Codes:
-
101 - no error, hints proxy about hijacking
-
200 - no error, no upgrade header found
-
400 - bad parameter
-
404 - no such container
-
500 - server error
Stream details
When using the TTY setting is enabled in POST /containers/create, the stream is the raw data from the process PTY and client’s stdin. When the TTY is disabled, then the stream is multiplexed to separate stdout and stderr.
The format is a Header and a Payload (frame).
HEADER
The header contains the information which the stream writes (stdout or
stderr). It also contains the size of the associated frame encoded in the
last four bytes (uint32).
It is encoded on the first eight bytes like this:
header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
STREAM_TYPE can be:
-
0:
stdin(is written onstdout) -
1:
stdout -
2:
stderr
SIZE1, SIZE2, SIZE3, SIZE4 are the four bytes of
the uint32 size encoded as big endian.
PAYLOAD
The payload is the raw stream.
IMPLEMENTATION
The simplest way to implement the Attach protocol is the following:
-
Read eight bytes.
-
Choose
stdoutorstderrdepending on the first byte. -
Extract the frame size from the last four bytes.
-
Read the extracted size and output it on the correct output.
-
Goto 1.
- logs
string(required)1/True/true or 0/False/false, return logs. Default
false.- stream
string(required)1/True/true or 0/False/false, return stream. Default
false.- stdin
string(required)1/True/true or 0/False/false, if
stream=true, attach tostdin. Defaultfalse.- stdout
string(required)1/True/true or 0/False/false, if
logs=true, returnstdoutlog, ifstream=true, attach tostdout. Defaultfalse.- stderr
string(required)1/True/true or 0/False/false, if
logs=true, returnstderrlog, ifstream=true, attach tostderr. Defaultfalse.
Headers
Content-Type: application/jsonBody
POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1101Headers
Content-Type: application/vnd.docker.raw-streamAttach to a container using websocketGET/containers/attach/ws{?logs,stream,stdin,stdout,stderr}
Attach to the container id via websocket
Implements websocket protocol handshake according to RFC 6455
Status Codes:
-
200 - no error
-
400 - bad parameter
-
404 - no such container
-
500 - server error
- logs
string(required)1/True/true or 0/False/false, return logs. Default
false.- stream
string(required)1/True/true or 0/False/false, return stream. Default
false.- stdin
string(required)1/True/true or 0/False/false, if
stream=true, attach tostdin. Defaultfalse.- stdout
string(required)1/True/true or 0/False/false, if
logs=true, returnstdoutlog, ifstream=true, attach tostdout. Defaultfalse.- stderr
string(required)1/True/true or 0/False/false, if
logs=true, returnstderrlog, ifstream=true, attach tostderr. Defaultfalse.
200Body
{{ STREAM }}Wait a containerPOST/containers/wait
Block until container id stops, then returns the exit code
Status Codes:
-
200 - no error
-
404 - no such container
-
500 - server error
Headers
Content-Type: application/jsonBody
POST /containers/16253994b7c4/wait HTTP/1.1200Headers
Content-Type: application/jsonBody
{
"StatusCode": 0
}Remove a containerDELETE/containers/{?v}
Remove the container id from the filesystem
Status Codes:
-
204 - no error
-
400 - bad parameter
-
404 - no such container
-
500 - server error
- v
string(required)1/True/true or 0/False/false, Remove the volumes associated to the container. Default false
Headers
Content-Type: application/jsonBody
DELETE /containers/16253994b7c4?v=1 HTTP/1.1204Headers
Content-Type: application/jsonCopy files or folders from a containerPOST/containers/copy
Copy files or folders of container id
Deprecated in favor of the archive endpoint below.
Status Codes:
-
200 - no error
-
404 - no such container
-
500 - server error
Body
POST /containers/4fa6e0f0c678/copy HTTP/1.1
Content-Type: application/json
{
"Resource": "test.txt"
}200Headers
Content-Type: application/x-tarRetrieving information about files and folders in a containerHEAD/containers/archive
See the description of the X-Docker-Container-Path-Stat header in the following section.
200Get an archive of a filesystem resource in a containerGET/containers/archive{?path}
Get an tar archive of a resource in the filesystem of container id.
Status Codes:
-
200 - success, returns archive of copied resource
-
400 - client error, bad parameter, details in JSON response body, one of:
- must specify path parameter (path cannot be empty)
- not a directory (path was asserted to be a directory but exists as a file)
-
404 - client error, resource not found, one of: – no such container (container
iddoes not exist)- no such file or directory (path does not exist)
-
500 - server error
On success, a response header X-Docker-Container-Path-Stat will be set to a
base64-encoded JSON object containing some filesystem header information about
the archived resource. The above example value would decode to the following
JSON object (whitespace added for readability):
{
"name": "root",
"size": 4096,
"mode": 2147484096,
"mtime": "2014-02-27T20:51:23Z",
"linkTarget": ""
}
A HEAD request can also be made to this endpoint if only this information is desired.
- path
mandatory(required) Example: /rootresource in the container’s filesystem to archive
If not an absolute path, it is relative to the container’s root directory. The resource specified by path must exist. To assert that the resource is expected to be a directory, path should end in
/or/.(assuming a path separator of/). If path ends in/.then this indicates that only the contents of the path directory should be copied. A symlink is always resolved to its target.Note: It is not possible to copy certain system files such as resources under
/proc,/sys,/dev, and mounts created by the user in the container.
200Headers
Content-Type: application/x-tar
X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=Body
{{ TAR STREAM }}Extract an archive of files or folders to a directory in a containerPUT/containers/archive{?path,noOverwriteDirNonDir}
Upload a tar archive to be extracted to a path in the filesystem of container id.
Status Codes:
-
200 - the content was extracted successfully
-
400 - client error, bad parameter, details in JSON response body, one of:
- must specify path parameter (path cannot be empty)
- not a directory (path should be a directory but exists as a file)
- unable to overwrite existing directory with non-directory (if noOverwriteDirNonDir)
- unable to overwrite existing non-directory with directory (if noOverwriteDirNonDir)
-
403 - client error, permission denied, the volume or container rootfs is marked as read-only.
-
404 - client error, resource not found, one of: – no such container (container
iddoes not exist)- no such file or directory (path resource does not exist)
-
500 - server error
- path
string(required) Example: /root- noOverwriteDirNonDir
string(required) Example: trueIf “1”, “true”, or “True” then it will be an error if unpacking the given content would cause an existing directory to be replaced with a non-directory and vice versa.
Body
PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
Content-Type: application/x-tar
{{ TAR STREAM }}200Body
HTTP/1.1 200 OKImages¶
List ImagesGET/images/{format}{?all,filters,filter}
List images format could be json or viz (json default)
Status Codes:
-
200 - no error
-
400 - bad parameter
-
500 - server error
- format
string(required) Example: 'json'List images
formatcould be json or viz (json default)- all
string(required) Example: 01/True/true or 0/False/false, default false
- filters
string(required) Example: nulla JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
-
dangling=true -
label=keyorlabel="key=value"of an image label
-
- filter
string(required) Example: nullonly return images with the specified name
Headers
Content-Type: application/jsonBody
GET /images/json?all=0 HTTP/1.1200Headers
Content-Type: application/jsonBody
[
{
"RepoTags": [
"ubuntu:12.04",
"ubuntu:precise",
"ubuntu:latest"
],
"Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
"Created": 1365714795,
"Size": 131506275,
"VirtualSize": 131506275
},
{
"RepoTags": [
"ubuntu:12.10",
"ubuntu:quantal"
],
"ParentId": "27cf784147099545",
"Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
"Created": 1364102658,
"Size": 24653,
"VirtualSize": 180116135
}
]Headers
Content-Type: application/jsonBody
GET /images/json?digests=1 HTTP/1.1200Headers
Content-Type: application/jsonBody
[
{
"Created": 1420064636,
"Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
"ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
"RepoDigests": [
"localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
],
"RepoTags": [
"localhost:5000/test/busybox:latest",
"playdate:latest"
],
"Size": 0,
"VirtualSize": 2429728
}
]
The response shows a single image `Id` associated with two repositories (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use either of the `RepoTags` values `localhost:5000/test/busybox:latest` or `playdate:latest` to reference the image.
You can also use `RepoDigests` values to reference an image. In this response,
the array has only one reference and that is to the
`localhost:5000/test/busybox` repository; the `playdate` repository has no
digest. You can reference this digest using the value: `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
See the `docker run` and `docker build` commands for examples of digest and tag references on the command line.Build image from a DockerfilePOST/build{?dockerfile,t,remote,q,nocache,pull,rm,forcerm,memory,memswap,cpushares,cpusetcpus,buildargs}
Build an image from a Dockerfile
Status Codes
-
200 - no error
-
500 - server error
This object maps the hostname of a registry to an object containing the “username” and “password” for that registry. Multiple registries may be specified as the build may be based on an image requiring authentication to pull from any arbitrary registry. Only the registry domain name (and port if not the default “443”) are required. However (for legacy reasons) the “official” Docker, Inc. hosted registry must be specified with both a “https://” prefix and a “/v1/” suffix even though Docker will prefer to use the v2 registry API.
- dockerfile
string(required)Path within the build context to the Dockerfile. This is ignored if
remoteis specified and points to an individual filename.- t
string(required) Example: nullA repository name (and optionally a tag) to apply to the resulting image in case of success.
- remote
string(required) Example: nullA Git repository URI or HTTP/HTTPS URI build source. If the URI specifies a filename, the file’s contents are placed into a file called
Dockerfile.- q
string(required) Example: nullSuppress verbose build output.
- nocache
string(required) Example: nullDo not use the cache when building the image.
- pull
string(required) Example: nullAttempt to pull the image even if an older image exists locally.
- rm
string(required) Example: nullRemove intermediate containers after a successful build (default behavior).
- forcerm
string(required) Example: nullAlways remove intermediate containers (includes
rm).- memory
string(required) Example: nullSet memory limit for build.
- memswap
string(required) Example: nullTotal memory (memory + swap),
-1to disable swap.- cpushares
string(required) Example: nullCPU shares (relative weight).
- cpusetcpus
string(required) Example: nullCPUs in which to allow execution (e.g.,
0-3,0,1).- buildargs
string(required) Example: nullJSON map of string pairs for build-time variables. Users pass these values at build-time. Docker uses the
buildargsas the environment context for command(s) run via the Dockerfile’sRUNinstruction or for variable expansion in other Dockerfile instructions. This is not meant for passing secret values. Read more about the buildargs instruction
Headers
Content-Type: application/tar
X-Registry-Config: {"docker.example.com": {"username": "janedoe", "password": "hunter2"}, "https://index.docker.io/v1/": {"username": "mobydock", "password": "conta1n3rize14"} }Body
{{ TAR STREAM }}200Headers
Content-Type: application/jsonBody
{"stream": "Step 1..."}
{"stream": "..."}
{"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
The input stream must be a `tar` archive compressed with one of the following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`.
The archive must include a build instructions file, typically called `Dockerfile` at the archive's root. The `dockerfile` parameter may be
used to specify a different build instructions file. To do this, its value must be the path to the alternate build instructions file to use.
The archive may include any number of other files, which are accessible in the build context (See the [*ADD build command*](/reference/builder/#dockerbuilder)).
The build is canceled if the client drops the connection by quitting or being killed.Create an imagePOST/images/create{?fromImage,fromSrc,repo,tag,registry}
Create an image either by pulling it from the registry or by importing it
Status Codes:
-
200 - no error
-
500 - server error
When using this endpoint to pull an image from the registry, the X-Registry-Auth header can be used to include a base64-encoded AuthConfig object.
- fromImage
string(required) Example: ubuntuName of the image to pull.
- fromSrc
string(required)Source to import. The value may be a URL from which the image can be retrieved or
-to read the image from the request body.- repo
string(required)Repository name.
- tag
string(required)Tag.
- registry
string(required)The registry to pull from.
Headers
Content-Type: application/json
X-Registry-Auth: base64-encoded AuthConfig object200Headers
Content-Type: application/jsonBody
{"status": "Pulling..."}
{"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
{"error": "Invalid..."}Inspect an imageGET/images/json
Return low-level information on the image name
Status Codes:
-
200 - no error
-
404 - no such image
-
500 - server error
Headers
Content-Type: application/jsonBody
GET /images/example/json HTTP/1.1200Headers
Content-Type: application/jsonBody
{
"Id": "85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c",
"Container": "cb91e48a60d01f1e27028b4fc6819f4f290b3cf12496c8176ec714d0d390984a",
"Comment": "",
"Os": "linux",
"Architecture": "amd64",
"Parent": "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
"ContainerConfig": {
"Tty": false,
"Hostname": "e611e15f9c9d",
"Volumes": null,
"Domainname": "",
"AttachStdout": false,
"PublishService": "",
"AttachStdin": false,
"OpenStdin": false,
"StdinOnce": false,
"NetworkDisabled": false,
"OnBuild": [],
"Image": "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
"User": "",
"WorkingDir": "",
"Entrypoint": null,
"MacAddress": "",
"AttachStderr": false,
"Labels": {
"com.example.license": "GPL",
"com.example.version": "1.0",
"com.example.vendor": "Acme"
},
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"ExposedPorts": null,
"Cmd": [
"/bin/sh",
"-c",
"#(nop) LABEL com.example.vendor=Acme com.example.license=GPL com.example.version=1.0"
]
},
"DockerVersion": "1.9.0-dev",
"VirtualSize": 188359297,
"Size": 0,
"Author": "",
"Created": "2015-09-10T08:30:53.26995814Z",
"GraphDriver": {
"Name": "aufs",
"Data": null
},
"Tags": [
"example:1.0",
"example:latest",
"example:stable"
],
"Config": {
"Image": "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
"NetworkDisabled": false,
"OnBuild": [],
"StdinOnce": false,
"PublishService": "",
"AttachStdin": false,
"OpenStdin": false,
"Domainname": "",
"AttachStdout": false,
"Tty": false,
"Hostname": "e611e15f9c9d",
"Volumes": null,
"Cmd": [
"/bin/bash"
],
"ExposedPorts": null,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Labels": {
"com.example.vendor": "Acme",
"com.example.version": "1.0",
"com.example.license": "GPL"
},
"Entrypoint": null,
"MacAddress": "",
"AttachStderr": false,
"WorkingDir": "",
"User": ""
}
}Get the history of an imageGET/images/{name}/history
Return the history of the image name
Status Codes:
-
200 - no error
-
404 - no such image
-
500 - server error
- name
string(required) Example: ubuntu
Headers
Content-Type: application/json200Headers
Content-Type: application/jsonBody
[
{
"Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710",
"Created": 1398108230,
"CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /",
"Tags": [
"ubuntu:lucid",
"ubuntu:10.04"
],
"Size": 182964289,
"Comment": ""
},
{
"Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8",
"Created": 1398108222,
"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/",
"Tags": null,
"Size": 0,
"Comment": ""
},
{
"Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158",
"Created": 1371157430,
"CreatedBy": "",
"Tags": [
"scratch12:latest",
"scratch:latest"
],
"Size": 0,
"Comment": "Imported from -"
}
]Push an image on the registryPOST/images/{name}/push{?tag}
Push the image name on the registry
Status Codes:
-
200 - no error
-
404 - no such image
-
500 - server error
- name
string(required)- tag
string(required) Example: nullThe tag to associate with the image on the registry.
Headers
Content-Type: application/jsonBody
+ Headers:
X-Registry-Auth: Include a base64-encoded AuthConfig. object.200Headers
Content-Type: application/jsonBody
{"status": "Pushing..."}
{"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
{"error": "Invalid..."}
...
If you wish to push an image on to a private registry, that image must already have a tag into a repository which references that registry `hostname` and `port`. This repository name should then be used in the URL. This duplicates the command line's flow.Tag an image into a repositoryPOST/images/tag{?repo,force,tag}
Tag the image name into a repository
Status Codes:
-
201 - no error
-
400 - bad parameter
-
404 - no such image
-
409 - conflict
-
500 - server error
- repo
string(required)The repository to tag in
- force
string(required)1/True/true or 0/False/false, default false
- tag
string(required)The new tag name
Headers
Content-Type: application/jsonBody
POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1201Headers
Content-Type: application/jsonRemove an imageDELETE/images/{name}{?force,noprune}
Remove the image name from the filesystem
Status Codes:
-
200 - no error
-
404 - no such image
-
409 - conflict
-
500 - server error
- name
string(required) Example: test- force
string(required) Example: 01/True/true or 0/False/false, default false
- noprune
string(required) Example: 01/True/true or 0/False/false, default false
Headers
Content-Type: application/jsonBody
DELETE /images/test HTTP/1.1200Headers
Content-Type: application/jsonBody
[
{
"Untagged": "3e2f21a89f"
},
{
"Deleted": "3e2f21a89f"
},
{
"Deleted": "53b4f83ac9"
}
]Search imagesGET/images/search?{term}
Search for an image on Docker Hub
Status Codes:
-
200 - no error
-
500 - server error
- term
string(required) Example: sshdterm to search
Headers
Content-Type: application/json200Headers
Content-Type: application/jsonBody
[
{
"description": "",
"is_official": false,
"is_automated": false,
"name": "wma55/u1210sshd",
"star_count": 0
},
{
"description": "",
"is_official": false,
"is_automated": false,
"name": "jdswinbank/sshd",
"star_count": 0
},
{
"description": "",
"is_official": false,
"is_automated": false,
"name": "vgauthier/sshd",
"star_count": 0
}
...
]Misc¶
Check auth configurationPOST/auth{?username,password,email,serveraddress}
Get the default username and email
Status Codes:
-
200 - no error
-
204 - no error
-
500 - server error
- username
string(required) Example: "hanibal"- password
string(required) Example: "xxxx"string(required) Example: "hannibal@ateam.com" (string)
- serveraddress
string(required) Example: "https://index.docker.io/v1/"
Headers
Content-Type: application/jsonBody
{
"username":" hannibal",
"password: "xxxx",
"email": "hannibal@a-team.com",
"serveraddress": "https://index.docker.io/v1/"
}200Headers
Content-Type: application/jsonDisplay system-wide informationGET/info
Display system-wide information
Status Codes:
-
200 - no error
-
500 - server error
Headers
Content-Type: application/jsonBody
GET /info HTTP/1.1200Headers
Content-Type: application/jsonBody
{
"Containers": 11,
"CpuCfsPeriod": true,
"CpuCfsQuota": true,
"Debug": false,
"DockerRootDir": "/var/lib/docker",
"Driver": "btrfs",
"DriverStatus": [
[
""
]
],
"ExecutionDriver": "native-0.1",
"ExperimentalBuild": false,
"HttpProxy": "http://test:test@localhost:8080",
"HttpsProxy": "https://test:test@localhost:8080",
"ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
"IPv4Forwarding": true,
"Images": 16,
"IndexServerAddress": "https://index.docker.io/v1/",
"InitPath": "/usr/bin/docker",
"InitSha1": "",
"KernelVersion": "3.12.0-1-amd64",
"Labels": [
"storage=ssd"
],
"MemTotal": 2099236864,
"MemoryLimit": true,
"NCPU": 1,
"NEventsListener": 0,
"NFd": 11,
"NGoroutines": 21,
"Name": "prod-server-42",
"NoProxy": "9.81.1.160",
"OomKillDisable": true,
"OperatingSystem": "Boot2Docker",
"RegistryConfig": {
"IndexConfigs": {
"docker.io": {
"Mirrors": null,
"Name": "docker.io",
"Official": true,
"Secure": true
}
},
"InsecureRegistryCIDRs": [
"127.0.0.0/8"
]
},
"SwapLimit": false,
"SystemTime": "2015-03-10T11:11:23.730591467-07:00"
}Show the docker version informationGET/version
Show the docker version information
Status Codes:
-
200 - no error
-
500 - server error
Headers
Content-Type: application/json200Headers
Content-Type: application/jsonBody
{
"Version": "1.5.0",
"Os": "linux",
"KernelVersion": "3.18.5-tinycore64",
"GoVersion": "go1.4.1",
"GitCommit": "a8a31ef",
"Arch": "amd64",
"ApiVersion": "1.20",
"Experimental": false
}Ping the docker serverGET/_ping
Ping the docker server
Status Codes:
-
200 - no error
-
500 - server error
Headers
Content-Type: application/json200Headers
Content-Type: text/plainCreate a new image from a container's changesPOST/commit{?container,repo,tag,comment,author}
Create a new image from a container’s changes
Status Codes:
-
201 - no error
-
404 - no such container
-
500 - server error
- container
string(required)source container
- repo
string(required)repository
- tag
string(required)tag
- comment
string(required)commit message
- author
string(required)author (e.g., “John Hannibal Smith <hannibal@a-team.com>”)
Headers
Content-Type: application/jsonBody
{
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"date"
],
"Mounts": [
{
"Source": "/data",
"Destination": "/data",
"Mode": "ro,Z",
"RW": false
}
],
"Labels": {
"key1": "value1",
"key2": "value2"
},
"WorkingDir": "",
"NetworkDisabled": false,
"ExposedPorts": {
"22/tcp": {}
}
}201Headers
Content-Type: application/vnd.docker.raw-streamBody
{
"Id": "596069db4bf5"
}Monitor Docker's eventsGET/events
Get container events from docker, either in real time via streaming, or via polling (using since).
Docker containers report the following events:
- attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause
and Docker images report:
- delete, import, pull, push, tag, untag
Status Codes:
-
200 – no error
-
500 – server error
- Parameters:
-
since – Timestamp used for polling
-
until – Timestamp used for polling
-
filters – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
-
event=<string>; – event to filter -
image=<string>; – image to filter -
container=<string>; – container to filter
200Headers
Content-Type: application/jsonBody
{"status":"pull","id":"busybox:latest","time":1442421700,"timeNano":1442421700598988358}
{"status":"create","id":"5745704abe9caa5","from":"busybox","time":1442421716,"timeNano":1442421716853979870}
{"status":"attach","id":"5745704abe9caa5","from":"busybox","time":1442421716,"timeNano":1442421716894759198}
{"status":"start","id":"5745704abe9caa5","from":"busybox","time":1442421716,"timeNano":1442421716983607193}Get a tarball containing all images in a repositoryGET/images/{name}/get
Get a tarball containing all images and metadata for the repository specified
by name.
If name is a specific name and tag (e.g. ubuntu:latest), then only that image
(and its parents) are returned. If name is an image ID, similarly only that
image (and its parents) are returned, but with the exclusion of the
‘repositories’ file in the tarball, as there were no image names referenced.
See the image tarball format for more details.
Status Codes:
-
200 – no error
-
500 – server error
- name
string(required) Example: ubuntu
200Headers
Content-Type: application/x-tarBody
Binary data streamGet a tarball containing all images.GET/images/get
Get a tarball containing all images and metadata for one or more repositories.
For each value of the names parameter: if it is a specific name and tag (e.g.
ubuntu:latest), then only that image (and its parents) are returned; if it is
an image ID, similarly only that image (and its parents) are returned and there
would be no names referenced in the ‘repositories’ file for this image ID.
See the image tarball format for more details.
Status Codes:
-
200 – no error
-
500 – server error
200Headers
Content-Type: application/x-tarBody
Binary data streamLoad a tarball with a set of images and tags into dockerPOST/images/load
Load a set of images and tags into a Docker repository. See the image tarball format for more details.
Status Codes:
-
200 – no error
-
500 – server error
Image tarball format
An image tarball contains one directory per image layer (named using its long ID), each containing these files:
-
VERSION: currently1.0- the file format version -
json: detailed layer information, similar todocker inspect layer_id -
layer.tar: A tarfile containing the filesystem changes in this layer
The layer.tar file contains aufs style .wh..wh.aufs files and directories
for storing attribute changes and deletions.
If the tarball defines a repository, the tarball should also include a repositories file at
the root that contains a list of repository and tag names mapped to layer IDs.
{"hello-world":
{"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
}
Body
Tarball in body200Exec CreatePOST/containers/{id}/exec{?AttachStdin,AttachStdout,AttachStderr,Tty,Cmd}
Sets up an exec instance in a running container id
Status Codes
-
201 - no error
-
404 - no such container
- id
string(required) Example: e90e34656806- AttachStdin
string(required)Boolean value, attaches to
stdinof theexeccommand.- AttachStdout
string(required)Boolean value, attaches to
stdoutof theexeccommand.- AttachStderr
string(required)Boolean value, attaches to
stderrof theexeccommand.- Tty
string(required)Boolean value to allocate a pseudo-TTY.
- Cmd
string(required)Command to run specified as a string or an array of strings.
Headers
Content-Type: application/jsonBody
{
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"Tty": false,
"Cmd": [
"date"
]
}201Headers
Content-Type: application/jsonBody
{
"Id": "f90e34656806",
"Warnings": []
}Exec StartPOST/exec/{id}/start{?detach,tty}
Starts a previously set up exec instance id. If detach is true, this API
returns after starting the exec command. Otherwise, this API sets up an
interactive session with the exec command.
Status Codes
-
201 - no error
-
404 - no such exec instance
Stream details:
Similar to the stream behavior of POST /container/{id}/attach API
- id
string(required) Example: e90e34656806instance id
- detach
boolean(required) Example: falseDetach from the
execcommand.- tty
boolean(required) Example: falseBoolean value to allocate a pseudo-TTY.
Headers
Content-Type: application/jsonBody
{
"Detach": false,
"Tty": false
}201Headers
Content-Type: application/jsonExec ResizePOST/exec/{id}/resize{?h,w}
Resizes the tty session used by the exec command id. The unit is number of characters.
This API is valid only if tty was specified as part of creating and starting the exec command.
Status Codes:
-
201 – no error
-
404 – no such exec instance
- id
string(required) Example: e90e34656806- h
number(required) Example: 40height of
ttysession- w
number(required) Example: 80width
Headers
Content-Type: text/plain201Headers
Content-Type: text/plainExec InspectGET/exec/{id}/json
Return low-level information about the exec command id.
Status Codes:
-
200 - no error
-
404 - no such exec instance
-
500 - server error
- id
string(required) Example: 11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39
200Headers
Content-Type: plain/textBody
{
"ID": "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
"Running": false,
"ExitCode": 2,
"ProcessConfig": {
"privileged": false,
"user": "",
"tty": false,
"entrypoint": "sh",
"arguments": [
"-c",
"exit 2"
]
},
"OpenStdin": false,
"OpenStderr": false,
"OpenStdout": false,
"Container": {
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Pid": 3650,
"ExitCode": 0,
"Error": "",
"StartedAt": "2014-11-17T22:26:03.717657531Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"ID": "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
"Created": "2014-11-17T22:26:03.626304998Z",
"Path": "date",
"Args": [],
"Config": {
"Hostname": "8f177a186b97",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": null,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"date"
],
"Image": "ubuntu",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": null,
"SecurityOpt": null
},
"Image": "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
"NetworkSettings": {
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"MacAddress": "02:42:ac:11:00:02",
"Gateway": "172.17.42.1",
"Bridge": "docker0",
"Ports": {}
},
"ResolvConfPath": "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
"HostsPath": "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
"Name": "/test",
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"RestartCount": 0,
"Mounts": []
}
}Volumes¶
List volumes¶
List volumesGET/volumes{?filter}
Status Codes
-
200 - no error
-
500 - server error
- filter
string(required) Example: dangling=trueJSON encoded value of the filters (a
map[string][]string) to process on the volumes list. There is one available filter:dangling=true
200Headers
Content-Type: application/jsonBody
{
"Volumes": [
{
"Name": "tardis",
"Driver": "local",
"Mountpoint": "/var/lib/docker/volumes/tardis"
}
]
}Create a volume¶
Create a volumePOST/volumes
Status Codes:
-
201 - no error
-
500 - server error
- Name
string(required) Example: tardisThe new volume’s name. If not specified, Docker generates a name.
- Driver
string(required) Example: localName of the volume driver to use. Defaults to
localfor the name.- DriverOpts
string(required) Example: nullA mapping of driver options and values. These options are passed directly to the driver and are driver specific.
Headers
Content-Type: application/jsonBody
POST /volumes HTTP/1.1
Content-Type: application/json
{
"Name": "tardis"
}201Headers
Content-Type: application/jsonBody
{
"Name": "tardis"
"Driver": "local",
"Mountpoint": "/var/lib/docker/volumes/tardis"
}Inspect a volume¶
Inspect a volumeGET/volumes/{name}
Return low-level information on the volume name
Status Codes
-
200 - no error
-
404 - no such volume
-
500 - server error
- name
string(required) Example: tardis
200Headers
Content-Type: application/jsonBody
+ Attributes
+ Name (string)
+ Driver (string)
+ Mountpoint (string)
+ Body
{
"Name": "tardis",
"Driver": "local",
"Mountpoint": "/var/lib/docker/volumes/tardis"
}Remove a volume¶
Remove a volumeDELETE/volumes/{driver}/{name}
Instruct the driver to remove the volume (name).
Status Codes
-
204 - no error
-
404 - no such volume or volume driver
-
409 - volume is in use and cannot be removed
-
500 - server error
- driver
string(required) Example: local- name
string(required) Example: tardis
204Going further¶
Inside docker run
As an example, the docker run command line makes the following API calls:
-
If the status code is 404, it means the image doesn’t exist:
- Try to pull it.
- Then, retry to create the container.
-
Start the container.
-
If you are not in detached mode:
-
Attach to the container, using
logs=1(to havestdoutandstderrfrom the container’s start) andstream=1 -
If in detached mode or only
stdinis attached, display the container’s id.
Hijacking
In this version of the API, /attach, uses hijacking to transport stdin,
stdout, and stderr on the same socket.
To hint potential proxies about connection hijacking, Docker client sends connection upgrade headers similarly to websocket.
Upgrade: tcp
Connection: Upgrade
When Docker daemon detects the Upgrade header, it switches its status code
from 200 OK to 101 UPGRADED and resends the same headers.
CORS Requests
To set cross origin requests to the remote api please give values to
--api-cors-header when running Docker in daemon mode. Set * (asterisk) allows all,
default or blank means CORS disabled
$ docker daemon -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"