docker.com – engine
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:
Versioning
The API is usually changed in each release of Docker, so API calls are versioned to ensure that clients don't break.
For Docker Engine 17.09, the API version is 1.32. To lock to this version, you prefix the URL with /v1.32. For example, calling /info is the same as calling /v1.32/info.
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.
In previous versions of Docker, it was possible to access the API without providing a version. This behaviour is now deprecated will be removed in a future version of Docker.
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 Docker daemons.
This documentation is for version 1.33 of the API. Use this table to find documentation for previous versions of the API:
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:
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 , you can just pass this instead of credentials:
{ "message": "page not found"}{ "username": "string", "password": "string", "email": "string", "serveraddress": "string"}{ "identitytoken": "9cbaf023786cd7..."}- Homepage
- https://api.apis.guru/v2/specs/docker.com:engine/1.33.json
- Provider
- docker.com:engine / engine
- OpenAPI version
- 3.0.0
- Spec (JSON)
- https://api.apis.guru/v2/specs/docker.com/engine/1.33/openapi.json
- Spec (YAML)
- https://api.apis.guru/v2/specs/docker.com/engine/1.33/openapi.yaml
Tools (107)
Extracted live via the executor SDK.
-
config.configCreateCreate a config
-
config.configDeleteDelete a config
-
config.configInspectInspect a config
-
config.configListList configs
-
config.configUpdateUpdate a Config
-
container.containerArchiveGet a tar archive of a resource in the filesystem of container id.
-
container.containerArchiveInfoA response header
X-Docker-Container-Path-Statis return containing a base64 - encoded JSON object with some filesystem header information about the path. -
container.containerAttachAttach to a container to read its output or send it input. You can attach to the same container multiple times and you can reattach to containers that have been detached.
Either the
streamorlogsparameter must betruefor this endpoint to do anything.See for more details.
Hijacking
This endpoint hijacks the HTTP connection to transport
stdin,stdout, andstderron the same socket.This is the response from the daemon for an attach request:
After the headers and two new lines, the TCP connection can now be used for raw, bidirectional communication between the client and server.
To hint potential proxies about connection hijacking, the Docker client can also optionally send connection upgrade headers.
For example, the client sends this request to upgrade the connection:
The Docker daemon will respond with a
101 UPGRADEDresponse, and will similarly follow with the raw stream:Stream format
When the TTY setting is disabled in , the stream over the hijacked connected is multiplexed to separate out
stdoutandstderr. The stream consists of a series of frames, each containing a header and a payload.The header contains the information which the stream writes (
stdoutorstderr). 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:
STREAM_TYPEcan be:- 0:
stdin(is written onstdout) - 1:
stdout - 2:
stderr
SIZE1, SIZE2, SIZE3, SIZE4are the four bytes of theuint32size encoded as big endian.Following the header is the payload, which is the specified number of bytes of
STREAM_TYPE.The simplest way to implement this protocol is the following:
- Read 8 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.
Stream format when using a TTY
When the TTY setting is enabled in , the stream is not multiplexed. The data exchanged over the hijacked connection is simply the raw data from the process PTY and client's
stdin.HTTP/1.1 200 OKContent-Type: application/vnd.docker.raw-stream [STREAM]POST /containers/16253994b7c4/attach?stream=1&stdout=1 HTTP/1.1Upgrade: tcpConnection: UpgradeHTTP/1.1 101 UPGRADEDContent-Type: application/vnd.docker.raw-streamConnection: UpgradeUpgrade: tcp [STREAM]header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} - 0:
-
container.containerAttachWebsocketAttach to a container via a websocket
-
container.containerChangesReturns which files in a container's filesystem have been added, deleted, or modified. The
Kindof modification can be one of:0: Modified1: Added2: Deleted
-
container.containerCreateCreate a container
-
container.containerDeleteRemove a container
-
container.containerExportExport the contents of a container as a tarball.
-
container.containerInspectReturn low-level information about a container.
-
container.containerKillSend a POSIX signal to a container, defaulting to killing to the container.
-
container.containerListReturns a list of containers. For details on the format, see .
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 .
-
container.containerLogsGet
stdoutandstderrlogs from a container.Note: This endpoint works only for containers with the
json-fileorjournaldlogging driver. -
container.containerPauseUse the cgroups freezer to suspend all processes in a container.
Traditionally, when suspending a process the
SIGSTOPsignal is used, which is observable by the process being suspended. With the cgroups freezer the process is unaware, and unable to capture, that it is being suspended, and subsequently resumed. -
container.containerPruneDelete stopped containers
-
container.containerRenameRename a container
-
container.containerResizeResize the TTY for a container. You must restart the container for the resize to take effect.
-
container.containerRestartRestart a container
-
container.containerStartStart a container
-
container.containerStatsThis endpoint returns a live stream of a container’s resource usage statistics.
The
precpu_statsis the CPU statistic of last read, which is used for calculating the CPU usage percentage. It is not the same as thecpu_statsfield.If either
precpu_stats.online_cpusorcpu_stats.online_cpusis nil then for compatibility with older daemons the length of the correspondingcpu_usage.percpu_usagearray should be used. -
container.containerStopStop a container
-
container.containerTopOn Unix systems, this is done by running the
pscommand. This endpoint is not supported on Windows. -
container.containerUnpauseResume a container which has been paused.
-
container.containerUpdateChange various configuration options of a container without having to recreate it.
-
container.containerWaitBlock until a container stops, then returns the exit code.
-
container.putContainerArchiveUpload a tar archive to be extracted to a path in the filesystem of container id.
-
distribution.distributionInspectReturn image digest and platform information by contacting the registry.
-
exec.containerExecRun a command inside a running container.
-
exec.execInspectReturn low-level information about an exec instance.
-
exec.execResizeResize the TTY session used by an exec instance. This endpoint only works if
ttywas specified as part of creating and starting the exec instance. -
exec.execStartStarts a previously set up exec instance. If detach is true, this endpoint returns immediately after starting the command. Otherwise, it sets up an interactive session with the command.
-
image.buildPruneDelete builder cache
-
image.imageBuildBuild an image from a tar archive with a
Dockerfilein it.The
Dockerfilespecifies how the image is built from the tar archive. It is typically in the archive's root, but can be at a different path or have a different name by specifying thedockerfileparameter. .The Docker daemon performs a preliminary validation of the
Dockerfilebefore starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output.The build is canceled if the client drops the connection by quitting or being killed.
-
image.imageCommitCreate a new image from a container
-
image.imageCreateCreate an image by either pulling it from a registry or importing it.
-
image.imageDeleteRemove an image, along with any untagged parent images that were referenced by that image.
Images can't be removed if they have descendant images, are being used by a running container or are being used by a build.
-
image.imageGetGet a tarball containing all images and metadata for a repository.
If
nameis a specific name and tag (e.g.ubuntu:latest), then only that image (and its parents) are returned. Ifnameis an image ID, similarly only that image (and its parents) are returned, but with the exclusion of therepositoriesfile in the tarball, as there were no image names referenced.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 versionjson: detailed layer information, similar todocker inspect layer_idlayer.tar: A tarfile containing the filesystem changes in this layer
The
layer.tarfile containsaufsstyle.wh..wh.aufsfiles and directories for storing attribute changes and deletions.If the tarball defines a repository, the tarball should also include a
repositoriesfile at the root that contains a list of repository and tag names mapped to layer IDs. -
image.imageGetAllGet a tarball containing all images and metadata for several image repositories.
For each value of the
namesparameter: 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.For details on the format, see .
-
image.imageHistoryReturn parent layers of an image.
-
image.imageInspectReturn low-level information about an image.
-
image.imageListReturns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
-
image.imageLoadLoad a set of images and tags into a repository.
For details on the format, see .
-
image.imagePruneDelete unused images
-
image.imagePushPush an image to a registry.
If you wish to push an image on to a private registry, that image must already have a tag which references the registry. For example,
registry.example.com/myimage:latest.The push is cancelled if the HTTP connection is closed.
-
image.imageSearchSearch for an image on Docker Hub.
-
image.imageTagTag an image so that it becomes part of a repository.
-
network.networkConnectConnect a container to a network
-
network.networkCreateCreate a network
-
network.networkDeleteRemove a network
-
network.networkDisconnectDisconnect a container from a network
-
network.networkInspectInspect a network
-
network.networkListReturns a list of networks. For details on the format, see .
Note that it uses a different, smaller representation of a network than inspecting a single network. For example, the list of containers attached to the network is not propagated in API versions 1.28 and up.
-
network.networkPruneDelete unused networks
-
node.nodeDeleteDelete a node
-
node.nodeInspectInspect a node
-
node.nodeListList nodes
-
node.nodeUpdateUpdate a node
-
plugin.getPluginPrivilegesGet plugin privileges
-
plugin.pluginCreateCreate a plugin
-
plugin.pluginDeleteRemove a plugin
-
plugin.pluginDisableDisable a plugin
-
plugin.pluginEnableEnable a plugin
-
plugin.pluginInspectInspect a plugin
-
plugin.pluginListReturns information about installed plugins.
-
plugin.pluginPullPulls and installs a plugin. After the plugin is installed, it can be enabled using the .
-
plugin.pluginPushPush a plugin to the registry.
-
plugin.pluginSetConfigure a plugin
-
plugin.pluginUpgradeUpgrade a plugin
-
secret.secretCreateCreate a secret
-
secret.secretDeleteDelete a secret
-
secret.secretInspectInspect a secret
-
secret.secretListList secrets
-
secret.secretUpdateUpdate a Secret
-
service.serviceCreateCreate a service
-
service.serviceDeleteDelete a service
-
service.serviceInspectInspect a service
-
service.serviceListList services
-
service.serviceLogsGet
stdoutandstderrlogs from a service.Note: This endpoint works only for services with the
json-fileorjournaldlogging drivers. -
service.serviceUpdateUpdate a service
-
sessionExperimental.sessionStart a new interactive session with a server. Session allows server to call back to the client for advanced capabilities.
Note: This endpoint is experimental and only available if the daemon is started with experimental features enabled. The specifications for this endpoint may still change in a future version of the API.
Hijacking
This endpoint hijacks the HTTP connection to HTTP2 transport that allows the client to expose gPRC services on that connection.
For example, the client sends this request to upgrade the connection:
The Docker daemon will respond with a
101 UPGRADEDresponse follow with the raw stream:HTTP/1.1 101 UPGRADEDConnection: UpgradeUpgrade: h2c -
swarm.swarmInitInitialize a new swarm
-
swarm.swarmInspectInspect swarm
-
swarm.swarmJoinJoin an existing swarm
-
swarm.swarmLeaveLeave a swarm
-
swarm.swarmUnlockUnlock a locked manager
-
swarm.swarmUnlockkeyGet the unlock key
-
swarm.swarmUpdateUpdate a swarm
-
system.systemAuthValidate credentials for a registry and, if available, get an identity token for accessing the registry without password.
-
system.systemDataUsageGet data usage information
-
system.systemEventsStream real-time events from the server.
Various objects within Docker report events when something happens to them.
Containers report these events:
attach,commit,copy,create,destroy,detach,die,exec_create,exec_detach,exec_start,export,health_status,kill,oom,pause,rename,resize,restart,start,stop,top,unpause, andupdateImages report these events:
delete,import,load,pull,push,save,tag, anduntagVolumes report these events:
create,mount,unmount, anddestroyNetworks report these events:
create,connect,disconnect,destroy,update, andremoveThe Docker daemon reports these events:
reloadServices report these events:
create,update, andremoveNodes report these events:
create,update, andremoveSecrets report these events:
create,update, andremoveConfigs report these events:
create,update, andremove -
system.systemInfoGet system information
-
system.systemPingThis is a dummy endpoint you can use to test if the server is accessible.
-
system.systemVersionReturns the version of Docker that is running and various information about the system that Docker is running on.
-
task.taskInspectInspect a task
-
task.taskListList tasks
-
tasks.taskLogsGet
stdoutandstderrlogs from a task.Note: This endpoint works only for services with the
json-fileorjournaldlogging drivers. -
volume.volumeCreateCreate a volume
-
volume.volumeDeleteInstruct the driver to remove the volume.
-
volume.volumeInspectInspect a volume
-
volume.volumeListList volumes
-
volume.volumePruneDelete unused volumes
-
openapi.previewSpecPreview an OpenAPI document before adding it as a source
-
openapi.addSourceAdd an OpenAPI source and register its operations as tools