Docker Engine API (v1.37)

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.

Errors

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"
}

Versioning

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

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..."
}

Containers

Create and manage containers.

List containers

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 .

Parameters
query Parameters ?
all
boolean
false

Return all containers. By default, only running containers are shown

limit
integer

Return this number of most recently created containers, including non-running ones.

size
boolean
false

Return the size of container as fields SizeRw and SizeRootFs.

filters
string

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 ID
  • isolation=(default|process|hyperv) (Windows daemon only)
  • is-task=(true|false)
  • label=key or label="key=value" of a container label
  • name=<name> a container's name
  • network=(<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>)

Responses

200 no error

Response Schema

400 bad parameter

Response Schema

500 server error

Response Schema

Definition

get
/containers/json

Server URL

/containers/json

Response samples
  • 200 no error

  • 400 bad parameter

  • 500 server error

[
  • {
    },
  • {
    },
  • {
    },
  • {
    }
]
{
  • "message": "Something went wrong."
}
{
  • "message": "Something went wrong."
}

Create a container

Parameters
query Parameters ?
name
string /?[a-zA-Z0-9_-]+

Assign the specified name to the container. Must match /?[a-zA-Z0-9_-]+.

Request Body

Container to create


Hostname
string

The hostname to use for the container, as a valid RFC 1123 hostname.

Domainname
string

The domain name to use for the container.

User
string

The user that commands are run as inside the container.

AttachStdin
boolean
false

Whether to attach to stdin.

AttachStdout
boolean
true

Whether to attach to stdout.

AttachStderr
boolean
true

Whether to attach to stderr.

ExposedPorts
ExposedPorts

An object mapping ports to an empty object in the form:

{"<port>/<tcp|udp|sctp>": {}}

Tty
boolean
false

Attach standard streams to a TTY, including stdin if it is not closed.

OpenStdin
boolean
false

Open stdin

StdinOnce
boolean
false

Close stdin after one attached client disconnects

Env
string

A list of environment variables to set inside the container in the form ["VAR=value", ...]. A variable without = is removed from the environment, rather than to have an empty value.

Cmd
string

Command to run specified as a string or an array of strings.

Healthcheck
HealthConfig

A test to perform to check that the container is healthy.

ArgsEscaped
boolean

Command is already escaped (Windows only)

Image
string

The name of the image to use when creating the container

Volumes
Volumes

An object mapping mount point paths inside the container to empty objects.

WorkingDir
string

The working directory for commands to run in.

Entrypoint
string

The entry point for the container as a string or an array of strings.

If the array consists of exactly one empty string ([""]) then the entry point is reset to system default (i.e., the entry point used by docker when there is no ENTRYPOINT instruction in the Dockerfile).

NetworkDisabled
boolean

Disable networking for the container.

MacAddress
string

MAC address of the container.

OnBuild
string

ONBUILD metadata that were defined in the image's Dockerfile.

Labels
Labels

User-defined key/value metadata.

StopSignal
string
"SIGTERM"

Signal to stop a container as a string or unsigned integer.

StopTimeout
integer
10

Timeout to stop a container in seconds.

Shell
string

Shell for when RUN, CMD, and ENTRYPOINT uses a shell.

HostConfig
HostConfig

Container configuration that depends on the host we are running on

NetworkingConfig
NetworkingConfig

This container's networking configuration.

Responses

201 Container created successfully

Response Schema

400 bad parameter

Response Schema

404 no such container

Response Schema

409 conflict

Response Schema

500 server error

Response Schema

Definition

post
/containers/create

Server URL

/containers/create
Request samples
{
  • "Hostname": "",
  • "Domainname": "",
  • "User": "",
  • "AttachStdin": false,
  • "AttachStdout": true,
  • "AttachStderr": true,
  • "Tty": false,
  • "OpenStdin": false,
  • "StdinOnce": false,
  • "Env":
    [
    ],
  • "Cmd":
    [
    ],
  • "Entrypoint": "",
  • "Image": "ubuntu",
  • "Labels":
    {
    },
  • "Volumes":
    {
    },
  • "WorkingDir": "",
  • "NetworkDisabled": false,
  • "MacAddress": "12:34:56:78:9a:bc",
  • "ExposedPorts":
    {
    },
  • "StopSignal": "SIGTERM",
  • "StopTimeout": 10,
  • "HostConfig":
    {
    },
  • "NetworkingConfig":
    {
    }
}

Response samples
  • 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."
}

Inspect a container

Return low-level information about a container.

Parameters
path Parameters ?
id
string Required

ID or name of the container

query Parameters ?
size
boolean
false

Return the size of container as fields SizeRw and SizeRootFs

Responses

200 no error

Response Schema

404 no such container

Response Schema

500 server error

Response Schema

Definition

get
/containers/{id}/json

Server URL

/containers/{id}/json

Response samples
  • 200 no error

  • 404 no such container

  • 500 server error

{
  • "AppArmorProfile": "",
  • "Args":
    [
    ],
  • "Config":
    {
    },
  • "Created": "2015-01-06T15:47:31.485331387Z",
  • "Driver": "devicemapper",
  • "HostConfig":
    {
    },
  • "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":
    {
    },
  • "Path": "/bin/sh",
  • "ProcessLabel": "",
  • "ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
  • "RestartCount": 1,
  • "State":
    {
    },
  • "Mounts":
    [
    ]
}
{
  • "message": "No such container: c2ada9df5af8"
}
{
  • "message": "Something went wrong."
}

List processes running inside a container

On Unix systems, this is done by running the ps command. This endpoint is not supported on Windows.

Parameters
path Parameters ?
id
string Required

ID or name of the container

query Parameters ?
ps_args
string
"-ef"

The arguments to pass to ps. For example, aux

Responses

200 no error

Response Schema

404 no such container

Response Schema

500 server error

Response Schema

Definition

get
/containers/{id}/top

Server URL

/containers/{id}/top

Response samples
  • 200 no error

  • 404 no such container

  • 500 server error

{
  • "Titles":
    [
    ],
  • "Processes":
    [
    ]
}
{
  • "message": "No such container: c2ada9df5af8"
}
{
  • "message": "Something went wrong."
}

Get container logs

Get stdout and stderr logs from a container.

Note: This endpoint works only for containers with the json-file or journald logging driver.

Parameters
path Parameters ?
id
string Required

ID or name of the container

query Parameters ?
follow
boolean
false

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.

stdout
boolean
false

Return logs from stdout

stderr
boolean
false

Return logs from stderr

since
integer
0

Only return logs since this time, as a UNIX timestamp

until
integer
0

Only return logs before this time, as a UNIX timestamp

timestamps
boolean
false

Add timestamps to every log line

tail
string
"all"

Only return this number of log lines from the end of the logs. Specify as an integer or all to output all log lines.

Responses

101 logs returned as a stream

Response Schema

200 logs returned as a string in response body

Response Schema

404 no such container

Response Schema

500 server error

Response Schema

Definition

get
/containers/{id}/logs

Server URL

/containers/{id}/logs

Response samples
  • 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."
}

Images

Networks

Networks are user-defined networks that containers can be attached to. See the networking documentation for more information.

Volumes

Create and manage persistent storage that can be attached to containers.

Exec

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.

Swarm

Engines can be clustered together in a swarm. See the swarm mode documentation for more information.

Nodes

Nodes are instances of the Engine participating in a swarm. Swarm mode must be enabled for these endpoints to work.

Services

Services are the definitions of tasks to run on a swarm. Swarm mode must be enabled for these endpoints to work.

Tasks

A task is a container running on a swarm. It is the atomic scheduling unit of swarm. Swarm mode must be enabled for these endpoints to work.

Secrets

Secrets are sensitive data that can be used by services. Swarm mode must be enabled for these endpoints to work.

Configs

Configs are application configurations that can be used by services. Swarm mode must be enabled for these endpoints to work.

Plugins

System

Distribution

Session (experimental)