Download OpenAPI (fka Swagger) specification: Download
The Engine API is an HTTP API served by Docker Engine. It is the API the Docker client uses to communicate with the Engine, so everything the Docker client can do can be done with the API.
Most of the client's commands map directly to API endpoints (e.g. docker ps
is GET /containers/json
). The notable exception is running containers, which consists of several API calls.
The API uses standard HTTP status codes to indicate the success or failure of the API call. The body of the response will be JSON in the following format:
{
"message": "page not found"
}
The API is usually changed in each release, so API calls are versioned to
ensure that clients don't break. To lock to a specific version of the API,
you prefix the URL with its version, for example, call /v1.30/info
to use
the v1.30 version of the /info
endpoint. If the API version specified in
the URL is not supported by the daemon, a HTTP 400 Bad Request
error message
is returned.
If you omit the version-prefix, the current version of the API (v1.37) is used.
For example, calling /info
is the same as calling /v1.36/info
. Using the
API without a version-prefix is deprecated and will be removed in a future release.
Engine releases in the near future should support this version of the API, so your client will continue to work even if it is talking to a newer Engine.
The API uses an open schema model, which means server may add extra properties to responses. Likewise, the server will ignore any extra query parameters and request body properties. When you write clients, you need to ignore additional properties in responses to ensure they do not break when talking to newer daemons.
Authentication for registries is handled client side. The client has to send authentication details to various endpoints that need to communicate with registries, such as POST /images/(name)/push
. These are sent as X-Registry-Auth
header as a Base64 encoded (JSON) string with the following structure:
{
"username": "string",
"password": "string",
"email": "string",
"serveraddress": "string"
}
The serveraddress
is a domain/IP without a protocol. Throughout this structure, double quotes are required.
If you have already got an identity token from the /auth
endpoint, you can just pass this instead of credentials:
{
"identitytoken": "9cbaf023786cd7..."
}
Returns a list of containers. For details on the format, see the inspect endpoint.
Note that it uses a different, smaller representation of a container than inspecting a single container. For example, the list of linked containers is not propagated .
Return all containers. By default, only running containers are shown
Return this number of most recently created containers, including non-running ones.
Return the size of container as fields SizeRw
and SizeRootFs
.
Filters to process on the container list, encoded as JSON (a map[string][]string
). For example, {"status": ["paused"]}
will only return paused containers. Available filters:
ancestor
=(<image-name>[:<tag>]
, <image id>
, or <image@digest>
)before
=(<container id>
or <container name>
)expose
=(<port>[/<proto>]
|<startport-endport>/[<proto>]
)exited=<int>
containers with exit code of <int>
health
=(starting
|healthy
|unhealthy
|none
)id=<ID>
a container's IDisolation=
(default
|process
|hyperv
) (Windows daemon only)is-task=
(true
|false
)label=key
or label="key=value"
of a container labelname=<name>
a container's namenetwork
=(<network id>
or <network name>
)publish
=(<port>[/<proto>]
|<startport-endport>/[<proto>]
)since
=(<container id>
or <container name>
)status=
(created
|restarting
|running
|removing
|paused
|exited
|dead
)volume
=(<volume name>
or <mount point destination>
)200 no error
400 bad parameter
500 server error
200 no error
400 bad parameter
500 server error
[]
{},
"Id": "8dfafdbc3a40", "Names": [],
"/boring_feynman" "Image": "ubuntu:latest", "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", "Command": "echo 1", "Created": 1367854155, "State": "Exited", "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, "HostConfig": {},
"NetworkMode": "default" "NetworkSettings": {},
"Networks": {}
"bridge": {}
"NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", "EndpointID": "2cdc4edb1ded3631c81f57966563e5c8525b81121bb3706a9a9a3ae102711f3f", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:02" "Mounts": []
{}
"Name": "fac362...80535", "Source": "/data", "Destination": "/data", "Driver": "local", "Mode": "ro,Z", "RW": false, "Propagation": "" {},
"Id": "9cd87474be90", "Names": [],
"/coolName" "Image": "ubuntu:latest", "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", "Command": "echo 222222", "Created": 1367854155, "State": "Exited", "Status": "Exit 0", "Ports": [ ], "Labels": { }, "SizeRw": 12288, "SizeRootFs": 0, "HostConfig": {},
"NetworkMode": "default" "NetworkSettings": {},
"Networks": {}
"bridge": {}
"NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", "EndpointID": "88eaed7b37b38c2a3f0c4bc796494fdf51b270c2d22656412a2ca5d559a64d7a", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.8", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:08" "Mounts": [ ] {},
"Id": "3176a2479c92", "Names": [],
"/sleepy_dog" "Image": "ubuntu:latest", "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", "Command": "echo 3333333333333333", "Created": 1367854154, "State": "Exited", "Status": "Exit 0", "Ports": [ ], "Labels": { }, "SizeRw": 12288, "SizeRootFs": 0, "HostConfig": {},
"NetworkMode": "default" "NetworkSettings": {},
"Networks": {}
"bridge": {}
"NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", "EndpointID": "8b27c041c30326d59cd6e6f510d4f8d1d570a228466f956edf7815508f78e30d", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.6", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:06" "Mounts": [ ] {}
"Id": "4cb07b47f9fb", "Names": [],
"/running_cat" "Image": "ubuntu:latest", "ImageID": "d74508fb6632491cea586a1fd7d748dfc5274cd6fdfedee309ecdcbc2bf5cb82", "Command": "echo 444444444444444444444444444444444", "Created": 1367854152, "State": "Exited", "Status": "Exit 0", "Ports": [ ], "Labels": { }, "SizeRw": 12288, "SizeRootFs": 0, "HostConfig": {},
"NetworkMode": "default" "NetworkSettings": {},
"Networks": {}
"bridge": {}
"NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", "EndpointID": "d91c7b2f0644403d7ef3095985ea0e2370325cd2332ff3a3225c4247328e66e9", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.5", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:05" "Mounts": [ ]
{}
"message": "Something went wrong."
{}
"message": "Something went wrong."
Assign the specified name to the container. Must match /?[a-zA-Z0-9_-]+
.
Container to create
Hostname null |
string
The hostname to use for the container, as a valid RFC 1123 hostname. |
|
|
Domainname null |
string
The domain name to use for the container. |
|
|
User null |
string
The user that commands are run as inside the container. |
|
|
AttachStdin null |
boolean
false
Whether to attach to |
|
|
AttachStdout null |
boolean
true
Whether to attach to |
|
|
AttachStderr null |
boolean
true
Whether to attach to |
|
|
ExposedPorts null |
ExposedPorts
An object mapping ports to an empty object in the form:
|
|
|
Tty null |
boolean
false
Attach standard streams to a TTY, including |
|
|
OpenStdin null |
boolean
false
Open |
|
|
StdinOnce null |
boolean
false
Close |
|
|
Env null |
string
A list of environment variables to set inside the container in the form |
|
|
Cmd null |
string
Command to run specified as a string or an array of strings. |
|
|
Healthcheck null |
HealthConfig
A test to perform to check that the container is healthy. |
|
|
ArgsEscaped null |
boolean
Command is already escaped (Windows only) |
|
|
Image null |
string
The name of the image to use when creating the container |
|
|
Volumes null |
Volumes
An object mapping mount point paths inside the container to empty objects. |
|
|
WorkingDir null |
string
The working directory for commands to run in. |
|
|
Entrypoint null |
string
The entry point for the container as a string or an array of strings. If the array consists of exactly one empty string ( |
|
|
NetworkDisabled null |
boolean
Disable networking for the container. |
|
|
MacAddress null |
string
MAC address of the container. |
|
|
OnBuild null |
string
|
|
|
Labels null |
Labels
User-defined key/value metadata. |
|
|
StopSignal null |
string
"SIGTERM"
Signal to stop a container as a string or unsigned integer. |
|
|
StopTimeout null |
integer
10
Timeout to stop a container in seconds. |
|
|
Shell null |
string
Shell for when |
|
|
HostConfig null |
HostConfig
Container configuration that depends on the host we are running on |
|
|
NetworkingConfig null |
NetworkingConfig
This container's networking configuration. |
|
201 Container created successfully
400 bad parameter
404 no such container
409 conflict
500 server error
{}
"Hostname": "", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": true, "AttachStderr": true, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [],
"FOO=bar", "BAZ=quux" "Cmd": [],
"date" "Entrypoint": "", "Image": "ubuntu", "Labels": {},
"com.example.vendor": "Acme", "com.example.license": "GPL", "com.example.version": "1.0" "Volumes": {},
"/volumes/data": { } "WorkingDir": "", "NetworkDisabled": false, "MacAddress": "12:34:56:78:9a:bc", "ExposedPorts": {},
"22/tcp": { } "StopSignal": "SIGTERM", "StopTimeout": 10, "HostConfig": {},
"Binds": [],
"/tmp:/tmp" "Links": [],
"redis3:redis" "Memory": 0, "MemorySwap": 0, "MemoryReservation": 0, "KernelMemory": 0, "NanoCPUs": 500000, "CpuPercent": 80, "CpuShares": 512, "CpuPeriod": 100000, "CpuRealtimePeriod": 1000000, "CpuRealtimeRuntime": 10000, "CpuQuota": 50000, "CpusetCpus": "0,1", "CpusetMems": "0,1", "MaximumIOps": 0, "MaximumIOBps": 0, "BlkioWeight": 300, "BlkioWeightDevice": [],
{ } "BlkioDeviceReadBps": [],
{ } "BlkioDeviceReadIOps": [],
{ } "BlkioDeviceWriteBps": [],
{ } "BlkioDeviceWriteIOps": [],
{ } "MemorySwappiness": 60, "OomKillDisable": false, "OomScoreAdj": 500, "PidMode": "", "PidsLimit": -1, "PortBindings": {},
"22/tcp": []
{}
"HostPort": "11022" "PublishAllPorts": false, "Privileged": false, "ReadonlyRootfs": false, "Dns": [],
"8.8.8.8" "DnsOptions": [],
"" "DnsSearch": [],
"" "VolumesFrom": [],
"parent", "other:ro" "CapAdd": [],
"NET_ADMIN" "CapDrop": [],
"MKNOD" "GroupAdd": [],
"newgroup" "RestartPolicy": {},
"Name": "", "MaximumRetryCount": 0 "AutoRemove": true, "NetworkMode": "bridge", "Devices": [ ], "Ulimits": [],
{ } "LogConfig": {},
"Type": "json-file", "Config": { } "SecurityOpt": [ ], "StorageOpt": { }, "CgroupParent": "", "VolumeDriver": "", "ShmSize": 67108864 "NetworkingConfig": {}
"EndpointsConfig": {}
"isolated_nw": {}
"IPAMConfig": {},
"IPv4Address": "172.20.30.33", "IPv6Address": "2001:db8:abcd::3033", "LinkLocalIPs": []
"169.254.34.68", "fe80::3468" "Links": [],
"container_1", "container_2" "Aliases": []
"server_x", "server_y"
201 Container created successfully
400 bad parameter
404 no such container
409 conflict
500 server error
{}
"Id": "e90e34656806", "Warnings": [ ]
{}
"message": "Something went wrong."
{}
"message": "No such container: c2ada9df5af8"
{}
"message": "Something went wrong."
{}
"message": "Something went wrong."
Return low-level information about a container.
ID or name of the container
Return the size of container as fields SizeRw
and SizeRootFs
200 no error
404 no such container
500 server error
200 no error
404 no such container
500 server error
{}
"AppArmorProfile": "", "Args": [],
"-c", "exit 9" "Config": {},
"AttachStderr": true, "AttachStdin": false, "AttachStdout": true, "Cmd": [],
"/bin/sh", "-c", "exit 9" "Domainname": "", "Env": [],
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" "Hostname": "ba033ac44011", "Image": "ubuntu", "Labels": {},
"com.example.vendor": "Acme", "com.example.license": "GPL", "com.example.version": "1.0" "MacAddress": "", "NetworkDisabled": false, "OpenStdin": false, "StdinOnce": false, "Tty": false, "User": "", "Volumes": {},
"/volumes/data": { } "WorkingDir": "", "StopSignal": "SIGTERM", "StopTimeout": 10 "Created": "2015-01-06T15:47:31.485331387Z", "Driver": "devicemapper", "HostConfig": {},
"MaximumIOps": 0, "MaximumIOBps": 0, "BlkioWeight": 0, "BlkioWeightDevice": [],
{ } "BlkioDeviceReadBps": [],
{ } "BlkioDeviceWriteBps": [],
{ } "BlkioDeviceReadIOps": [],
{ } "BlkioDeviceWriteIOps": [],
{ } "ContainerIDFile": "", "CpusetCpus": "", "CpusetMems": "", "CpuPercent": 80, "CpuShares": 0, "CpuPeriod": 100000, "CpuRealtimePeriod": 1000000, "CpuRealtimeRuntime": 10000, "Devices": [ ], "IpcMode": "", "LxcConf": [ ], "Memory": 0, "MemorySwap": 0, "MemoryReservation": 0, "KernelMemory": 0, "OomKillDisable": false, "OomScoreAdj": 500, "NetworkMode": "bridge", "PidMode": "", "PortBindings": { }, "Privileged": false, "ReadonlyRootfs": false, "PublishAllPorts": false, "RestartPolicy": {},
"MaximumRetryCount": 2, "Name": "on-failure" "LogConfig": {},
"Type": "json-file" "Sysctls": {},
"net.ipv4.ip_forward": "1" "Ulimits": [],
{ } "VolumeDriver": "", "ShmSize": 67108864 "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": "", "SandboxID": "", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "SandboxKey": "", "EndpointID": "", "Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "", "IPPrefixLen": 0, "IPv6Gateway": "", "MacAddress": "", "Networks": {}
"bridge": {}
"NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812", "EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.2", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:12:00:02" "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, "Dead": false, "Paused": false, "Pid": 0, "Restarting": false, "Running": true, "StartedAt": "2015-01-06T15:47:32.072697474Z", "Status": "running" "Mounts": []
{}
"Name": "fac362...80535", "Source": "/data", "Destination": "/data", "Driver": "local", "Mode": "ro,Z", "RW": false, "Propagation": ""
{}
"message": "No such container: c2ada9df5af8"
{}
"message": "Something went wrong."
On Unix systems, this is done by running the ps
command. This endpoint is not supported on Windows.
ID or name of the container
The arguments to pass to ps
. For example, aux
200 no error
404 no such container
500 server error
200 no error
404 no such container
500 server error
{}
"Titles": [],
"UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD" "Processes": []
[],
"root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash" []
"root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10"
{}
"message": "No such container: c2ada9df5af8"
{}
"message": "Something went wrong."
Get stdout
and stderr
logs from a container.
Note: This endpoint works only for containers with the json-file
or journald
logging driver.
ID or name of the container
Return the logs as a stream.
This will return a 101
HTTP response with a Connection: upgrade
header, then hijack the HTTP connection to send raw output. For more information about hijacking and the stream format, see the documentation for the attach endpoint.
Return logs from stdout
Return logs from stderr
Only return logs since this time, as a UNIX timestamp
Only return logs before this time, as a UNIX timestamp
Add timestamps to every log line
Only return this number of log lines from the end of the logs. Specify as an integer or all
to output all log lines.
101 logs returned as a stream
200 logs returned as a string in response body
404 no such container
500 server error
101 logs returned as a stream
200 logs returned as a string in response body
404 no such container
500 server error
"string"
"string"
{}
"message": "No such container: c2ada9df5af8"
{}
"message": "Something went wrong."
Networks are user-defined networks that containers can be attached to. See the networking documentation for more information.
Run new commands inside running containers. See the command-line reference for more information.
To exec a command in a container, you first need to create an exec instance, then start it. These two API endpoints are wrapped up in a single command-line command, docker exec
.
Engines can be clustered together in a swarm. See the swarm mode documentation for more information.