mirror of https://github.com/docker/docs.git
18255 lines
795 KiB
XML
18255 lines
795 KiB
XML
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
|
||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||
<channel>
|
||
<title>References on Docker Docs</title>
|
||
<link>http://localhost/reference/</link>
|
||
<description>Recent content in References on Docker Docs</description>
|
||
<generator>Hugo -- gohugo.io</generator>
|
||
<language>en-us</language>
|
||
<atom:link href="http://localhost/reference/index.xml" rel="self" type="application/rss+xml" />
|
||
|
||
<item>
|
||
<title></title>
|
||
<link>http://localhost/reference/api/README/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/README/</guid>
|
||
<description><p>This directory holds the authoritative specifications of APIs defined and implemented by Docker. Currently this includes:</p>
|
||
|
||
<ul>
|
||
<li>The remote API by which a docker node can be queried over HTTP</li>
|
||
<li>The registry API by which a docker node can download and upload
|
||
images for storage and sharing</li>
|
||
<li>The index search API by which a docker node can search the public
|
||
index for images to download</li>
|
||
<li>The docker.io OAuth and accounts API which 3rd party services can
|
||
use to access account information</li>
|
||
</ul>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title></title>
|
||
<link>http://localhost/reference/logging/journald/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/logging/journald/</guid>
|
||
<description>
|
||
|
||
<h1 id="journald-logging-driver">Journald logging driver</h1>
|
||
|
||
<p>The <code>journald</code> logging driver sends container logs to the <a href="http://www.freedesktop.org/software/systemd/man/systemd-journald.service.html">systemd
|
||
journal</a>. Log entries can be retrieved using the <code>journalctl</code>
|
||
command or through use of the journal API.</p>
|
||
|
||
<p>In addition to the text of the log message itself, the <code>journald</code> log
|
||
driver stores the following metadata in the journal with each message:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Field</th>
|
||
<th>Description</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody>
|
||
<tr>
|
||
<td><code>CONTAINER_ID</code></td>
|
||
<td>The container ID truncated to 12 characters.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>CONTAINER_ID_FULL</code></td>
|
||
<td>The full 64-character container ID.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>CONTAINER_NAME</code></td>
|
||
<td>The container name at the time it was started. If you use <code>docker rename</code> to rename a container, the new name is not reflected in the journal entries.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h2 id="usage">Usage</h2>
|
||
|
||
<p>You can configure the default logging driver by passing the
|
||
<code>--log-driver</code> option to the Docker daemon:</p>
|
||
|
||
<pre><code>docker --log-driver=journald
|
||
</code></pre>
|
||
|
||
<p>You can set the logging driver for a specific container by using the
|
||
<code>--log-driver</code> option to <code>docker run</code>:</p>
|
||
|
||
<pre><code>docker run --log-driver=journald ...
|
||
</code></pre>
|
||
|
||
<h2 id="note-regarding-container-names">Note regarding container names</h2>
|
||
|
||
<p>The value logged in the <code>CONTAINER_NAME</code> field is the container name
|
||
that was set at startup. If you use <code>docker rename</code> to rename a
|
||
container, the new name will not be reflected in the journal entries.
|
||
Journal entries will continue to use the original name.</p>
|
||
|
||
<h2 id="retrieving-log-messages-with-journalctl">Retrieving log messages with journalctl</h2>
|
||
|
||
<p>You can use the <code>journalctl</code> command to retrieve log messages. You
|
||
can apply filter expressions to limit the retrieved messages to a
|
||
specific container. For example, to retrieve all log messages from a
|
||
container referenced by name:</p>
|
||
|
||
<pre><code># journalctl CONTAINER_NAME=webserver
|
||
</code></pre>
|
||
|
||
<p>You can make use of additional filters to further limit the messages
|
||
retrieved. For example, to see just those messages generated since
|
||
the system last booted:</p>
|
||
|
||
<pre><code># journalctl -b CONTAINER_NAME=webserver
|
||
</code></pre>
|
||
|
||
<p>Or to retrieve log messages in JSON format with complete metadata:</p>
|
||
|
||
<pre><code># journalctl -o json CONTAINER_NAME=webserver
|
||
</code></pre>
|
||
|
||
<h2 id="retrieving-log-messages-with-the-journal-api">Retrieving log messages with the journal API</h2>
|
||
|
||
<p>This example uses the <code>systemd</code> Python module to retrieve container
|
||
logs:</p>
|
||
|
||
<pre><code>import systemd.journal
|
||
|
||
reader = systemd.journal.Reader()
|
||
reader.add_match('CONTAINER_NAME=web')
|
||
|
||
for msg in reader:
|
||
print '{CONTAINER_ID_FULL}: {MESSAGE}'.format(**msg)
|
||
</code></pre>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Docker Glossary</title>
|
||
<link>http://localhost/reference/glossary/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/glossary/</guid>
|
||
<description>
|
||
|
||
<h1 id="glossary">Glossary</h1>
|
||
|
||
<p>A list of terms used around the Docker project.</p>
|
||
|
||
<h2 id="aufs">aufs</h2>
|
||
|
||
<p>aufs (advanced multi layered unification filesystem) is a Linux <a href="#filesystem">filesystem</a> that
|
||
Docker supports as a storage backend. It implements the
|
||
<a href="http://en.wikipedia.org/wiki/Union_mount">union mount</a> for Linux file systems.</p>
|
||
|
||
<h2 id="boot2docker">boot2docker</h2>
|
||
|
||
<p><a href="http://boot2docker.io/">boot2docker</a> is a lightweight Linux distribution made
|
||
specifically to run Docker containers. It is a common choice for a <a href="#virtual-machine">VM</a>
|
||
to run Docker on Windows and Mac OS X.</p>
|
||
|
||
<p>boot2docker can also refer to the boot2docker management tool on Windows and
|
||
Mac OS X which manages the boot2docker VM.</p>
|
||
|
||
<h2 id="btrfs">btrfs</h2>
|
||
|
||
<p>btrfs (B-tree file system) is a Linux <a href="#filesystem">filesystem</a> that Docker
|
||
supports as a storage backend. It is a <a href="http://en.wikipedia.org/wiki/Copy-on-write">copy-on-write</a>
|
||
filesystem.</p>
|
||
|
||
<h2 id="build">build</h2>
|
||
|
||
<p>build is the process of building Docker images using a <a href="#dockerfile">Dockerfile</a>.
|
||
The build uses a Dockerfile and a &ldquo;context&rdquo;. The context is the set of files in the
|
||
directory in which the image is built.</p>
|
||
|
||
<h2 id="cgroups">cgroups</h2>
|
||
|
||
<p>cgroups is a Linux kernel feature that limits, accounts for, and isolates
|
||
the resource usage (CPU, memory, disk I/O, network, etc.) of a collection
|
||
of processes. Docker relies on cgroups to control and isolate resource limits.</p>
|
||
|
||
<p><em>Also known as : control groups</em></p>
|
||
|
||
<h2 id="compose">Compose</h2>
|
||
|
||
<p><a href="https://github.com/docker/compose">Compose</a> is a tool for defining and
|
||
running complex applications with Docker. With compose, you define a
|
||
multi-container application in a single file, then spin your
|
||
application up in a single command which does everything that needs to
|
||
be done to get it running.</p>
|
||
|
||
<p><em>Also known as : docker-compose, fig</em></p>
|
||
|
||
<h2 id="container">container</h2>
|
||
|
||
<p>A container is a runtime instance of a <a href="#image">docker image</a>.</p>
|
||
|
||
<p>A Docker container consists of</p>
|
||
|
||
<ul>
|
||
<li>A Docker image</li>
|
||
<li>Execution environment</li>
|
||
<li>A standard set of instructions</li>
|
||
</ul>
|
||
|
||
<p>The concept is borrowed from Shipping Containers, which define a standard to ship
|
||
goods globally. Docker defines a standard to ship software.</p>
|
||
|
||
<h2 id="data-volume">data volume</h2>
|
||
|
||
<p>A data volume is a specially-designated directory within one or more containers
|
||
that bypasses the Union File System. Data volumes are designed to persist data,
|
||
independent of the container&rsquo;s life cycle. Docker therefore never automatically
|
||
delete volumes when you remove a container, nor will it &ldquo;garbage collect&rdquo;
|
||
volumes that are no longer referenced by a container.</p>
|
||
|
||
<h2 id="docker">Docker</h2>
|
||
|
||
<p>The term Docker can refer to</p>
|
||
|
||
<ul>
|
||
<li>The Docker project as a whole, which is a platform for developers and sysadmins to
|
||
develop, ship, and run applications</li>
|
||
<li>The docker daemon process running on the host which manages images and containers</li>
|
||
</ul>
|
||
|
||
<h2 id="docker-hub">Docker Hub</h2>
|
||
|
||
<p>The <a href="https://hub.docker.com/">Docker Hub</a> is a centralized resource for working with
|
||
Docker and its components. It provides the following services:</p>
|
||
|
||
<ul>
|
||
<li>Docker image hosting</li>
|
||
<li>User authentication</li>
|
||
<li>Automated image builds and work-flow tools such as build triggers and web hooks</li>
|
||
<li>Integration with GitHub and BitBucket</li>
|
||
</ul>
|
||
|
||
<h2 id="dockerfile">Dockerfile</h2>
|
||
|
||
<p>A Dockerfile is a text document that contains all the commands you would
|
||
normally execute manually in order to build a Docker image. Docker can
|
||
build images automatically by reading the instructions from a Dockerfile.</p>
|
||
|
||
<h2 id="filesystem">filesystem</h2>
|
||
|
||
<p>A file system is the method an operating system uses to name files
|
||
and assign them locations for efficient storage and retrieval.</p>
|
||
|
||
<p>Examples :</p>
|
||
|
||
<ul>
|
||
<li>Linux : ext4, aufs, btrfs, zfs</li>
|
||
<li>Windows : NTFS</li>
|
||
<li>OS X : HFS+</li>
|
||
</ul>
|
||
|
||
<h2 id="image">image</h2>
|
||
|
||
<p>Docker images are the basis of <a href="#container">containers</a>. An Image is an
|
||
ordered collection of root filesystem changes and the corresponding
|
||
execution parameters for use within a container runtime. An image typically
|
||
contains a union of layered filesystems stacked on top of each other. An image
|
||
does not have state and it never changes.</p>
|
||
|
||
<h2 id="libcontainer">libcontainer</h2>
|
||
|
||
<p>libcontainer provides a native Go implementation for creating containers with
|
||
namespaces, cgroups, capabilities, and filesystem access controls. It allows
|
||
you to manage the lifecycle of the container performing additional operations
|
||
after the container is created.</p>
|
||
|
||
<h2 id="link">link</h2>
|
||
|
||
<p>links provide an interface to connect Docker containers running on the same host
|
||
to each other without exposing the hosts&rsquo; network ports. When you set up a link,
|
||
you create a conduit between a source container and a recipient container.
|
||
The recipient can then access select data about the source. To create a link,
|
||
you can use the <code>--link</code> flag.</p>
|
||
|
||
<h2 id="machine">Machine</h2>
|
||
|
||
<p><a href="https://github.com/docker/machine">Machine</a> is a Docker tool which
|
||
makes it really easy to create Docker hosts on your computer, on
|
||
cloud providers and inside your own data center. It creates servers,
|
||
installs Docker on them, then configures the Docker client to talk to them.</p>
|
||
|
||
<p><em>Also known as : docker-machine</em></p>
|
||
|
||
<h2 id="overlay">overlay</h2>
|
||
|
||
<p>OverlayFS is a <a href="#filesystem">filesystem</a> service for Linux which implements a
|
||
<a href="http://en.wikipedia.org/wiki/Union_mount">union mount</a> for other file systems.
|
||
It is supported by the Docker daemon as a storage driver.</p>
|
||
|
||
<h2 id="registry">registry</h2>
|
||
|
||
<p>A Registry is a hosted service containing <a href="#repository">repositories</a> of <a href="#image">images</a>
|
||
which responds to the Registry API.</p>
|
||
|
||
<p>The default registry can be accessed using a browser at <a href="#docker-hub">Docker Hub</a>
|
||
or using the <code>docker search</code> command.</p>
|
||
|
||
<h2 id="repository">repository</h2>
|
||
|
||
<p>A repository is a set of Docker images. A repository can be shared by pushing it
|
||
to a <a href="#registry">registry</a> server. The different images in the repository can be
|
||
labeled using <a href="#tag">tags</a>.</p>
|
||
|
||
<p>Here is an example of the shared <a href="https://registry.hub.docker.com/_/nginx/">nginx repository</a>
|
||
and its <a href="https://registry.hub.docker.com/_/nginx/tags/manage/">tags</a></p>
|
||
|
||
<h2 id="swarm">Swarm</h2>
|
||
|
||
<p><a href="https://github.com/docker/swarm">Swarm</a> is a native clustering tool for Docker.
|
||
Swarm pools together several Docker hosts and exposes them as a single virtual
|
||
Docker host. It serves the standard Docker API, so any tool that already works
|
||
with Docker can now transparently scale up to multiple hosts.</p>
|
||
|
||
<p><em>Also known as : docker-swarm</em></p>
|
||
|
||
<h2 id="tag">tag</h2>
|
||
|
||
<p>A tag is a label applied to a Docker image in a <a href="#repository">repository</a>.
|
||
tags are how various images in a repository are distinguished from each other.</p>
|
||
|
||
<p><em>Note : This label is not related to the key=value labels set for docker daemon</em></p>
|
||
|
||
<h2 id="union-file-system">Union file system</h2>
|
||
|
||
<p>Union file systems, or UnionFS, are file systems that operate by creating layers, making them
|
||
very lightweight and fast. Docker uses union file systems to provide the building
|
||
blocks for containers.</p>
|
||
|
||
<h2 id="virtual-machine">Virtual Machine</h2>
|
||
|
||
<p>A Virtual Machine is a program that emulates a complete computer and imitates dedicated hardware.
|
||
It shares physical hardware resources with other users but isolates the operating system. The
|
||
end user has the same experience on a Virtual Machine as they would have on dedicated hardware.</p>
|
||
|
||
<p>Compared to to containers, a Virtual Machine is heavier to run, provides more isolation,
|
||
gets its own set of resources and does minimal sharing.</p>
|
||
|
||
<p><em>Also known as : VM</em></p>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Docker Hub API</title>
|
||
<link>http://localhost/reference/api/docker-io_api/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/docker-io_api/</guid>
|
||
<description>
|
||
|
||
<h1 id="docker-hub-api">Docker Hub API</h1>
|
||
|
||
<ul>
|
||
<li>This is the REST API for <a href="https://hub.docker.com">Docker Hub</a>.</li>
|
||
<li>Authorization is done with basic auth over SSL</li>
|
||
<li>Not all commands require authentication, only those noted as such.</li>
|
||
</ul>
|
||
|
||
<h1 id="repositories">Repositories</h1>
|
||
|
||
<h2 id="user-repository">User repository</h2>
|
||
|
||
<h3 id="create-a-user-repository">Create a user repository</h3>
|
||
|
||
<p><code>PUT /v1/repositories/(namespace)/(repo_name)/</code></p>
|
||
|
||
<p>Create a user repository with the given <code>namespace</code> and <code>repo_name</code>.</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> PUT /v1/repositories/foo/bar/ HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Basic akmklmasadalkm==
|
||
X-Docker-Token: true
|
||
|
||
[{&quot;id&quot;: &quot;9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f&quot;}]
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>namespace</strong> – the namespace for the repo</li>
|
||
<li><strong>repo_name</strong> – the name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
WWW-Authenticate: Token signature=123abc,repository=&quot;foo/bar&quot;,access=write
|
||
X-Docker-Token: signature=123abc,repository=&quot;foo/bar&quot;,access=write
|
||
X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
|
||
|
||
&quot;&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – Created</li>
|
||
<li><strong>400</strong> – Errors (invalid json, missing or invalid fields, etc)</li>
|
||
<li><strong>401</strong> – Unauthorized</li>
|
||
<li><strong>403</strong> – Account is not Active</li>
|
||
</ul>
|
||
|
||
<h3 id="delete-a-user-repository">Delete a user repository</h3>
|
||
|
||
<p><code>DELETE /v1/repositories/(namespace)/(repo_name)/</code></p>
|
||
|
||
<p>Delete a user repository with the given <code>namespace</code> and <code>repo_name</code>.</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> DELETE /v1/repositories/foo/bar/ HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Basic akmklmasadalkm==
|
||
X-Docker-Token: true
|
||
|
||
&quot;&quot;
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>namespace</strong> – the namespace for the repo</li>
|
||
<li><strong>repo_name</strong> – the name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 202
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
WWW-Authenticate: Token signature=123abc,repository=&quot;foo/bar&quot;,access=delete
|
||
X-Docker-Token: signature=123abc,repository=&quot;foo/bar&quot;,access=delete
|
||
X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
|
||
|
||
&quot;&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – Deleted</li>
|
||
<li><strong>202</strong> – Accepted</li>
|
||
<li><strong>400</strong> – Errors (invalid json, missing or invalid fields, etc)</li>
|
||
<li><strong>401</strong> – Unauthorized</li>
|
||
<li><strong>403</strong> – Account is not Active</li>
|
||
</ul>
|
||
|
||
<h2 id="library-repository">Library repository</h2>
|
||
|
||
<h3 id="create-a-library-repository">Create a library repository</h3>
|
||
|
||
<p><code>PUT /v1/repositories/(repo_name)/</code></p>
|
||
|
||
<p>Create a library repository with the given <code>repo_name</code>.
|
||
This is a restricted feature only available to docker admins.</p>
|
||
|
||
<blockquote>
|
||
<p>When namespace is missing, it is assumed to be <code>library</code></p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> PUT /v1/repositories/foobar/ HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Basic akmklmasadalkm==
|
||
X-Docker-Token: true
|
||
|
||
[{&quot;id&quot;: &quot;9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f&quot;}]
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo_name</strong> – the library name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
WWW-Authenticate: Token signature=123abc,repository=&quot;library/foobar&quot;,access=write
|
||
X-Docker-Token: signature=123abc,repository=&quot;foo/bar&quot;,access=write
|
||
X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
|
||
|
||
&quot;&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – Created</li>
|
||
<li><strong>400</strong> – Errors (invalid json, missing or invalid fields, etc)</li>
|
||
<li><strong>401</strong> – Unauthorized</li>
|
||
<li><strong>403</strong> – Account is not Active</li>
|
||
</ul>
|
||
|
||
<h3 id="delete-a-library-repository">Delete a library repository</h3>
|
||
|
||
<p><code>DELETE /v1/repositories/(repo_name)/</code></p>
|
||
|
||
<p>Delete a library repository with the given <code>repo_name</code>.
|
||
This is a restricted feature only available to docker admins.</p>
|
||
|
||
<blockquote>
|
||
<p>When namespace is missing, it is assumed to be <code>library</code></p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> DELETE /v1/repositories/foobar/ HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Basic akmklmasadalkm==
|
||
X-Docker-Token: true
|
||
|
||
&quot;&quot;
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo_name</strong> – the library name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 202
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
WWW-Authenticate: Token signature=123abc,repository=&quot;library/foobar&quot;,access=delete
|
||
X-Docker-Token: signature=123abc,repository=&quot;foo/bar&quot;,access=delete
|
||
X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
|
||
|
||
&quot;&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – Deleted</li>
|
||
<li><strong>202</strong> – Accepted</li>
|
||
<li><strong>400</strong> – Errors (invalid json, missing or invalid fields, etc)</li>
|
||
<li><strong>401</strong> – Unauthorized</li>
|
||
<li><strong>403</strong> – Account is not Active</li>
|
||
</ul>
|
||
|
||
<h1 id="repository-images">Repository images</h1>
|
||
|
||
<h2 id="user-repository-images">User repository images</h2>
|
||
|
||
<h3 id="update-user-repository-images">Update user repository images</h3>
|
||
|
||
<p><code>PUT /v1/repositories/(namespace)/(repo_name)/images</code></p>
|
||
|
||
<p>Update the images for a user repo.</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> PUT /v1/repositories/foo/bar/images HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Basic akmklmasadalkm==
|
||
|
||
[{&quot;id&quot;: &quot;9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f&quot;,
|
||
&quot;checksum&quot;: &quot;b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087&quot;}]
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>namespace</strong> – the namespace for the repo</li>
|
||
<li><strong>repo_name</strong> – the name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
|
||
&quot;&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – Created</li>
|
||
<li><strong>400</strong> – Errors (invalid json, missing or invalid fields, etc)</li>
|
||
<li><strong>401</strong> – Unauthorized</li>
|
||
<li><strong>403</strong> – Account is not Active or permission denied</li>
|
||
</ul>
|
||
|
||
<h3 id="list-user-repository-images">List user repository images</h3>
|
||
|
||
<p><code>GET /v1/repositories/(namespace)/(repo_name)/images</code></p>
|
||
|
||
<p>Get the images for a user repo.</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> GET /v1/repositories/foo/bar/images HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>namespace</strong> – the namespace for the repo</li>
|
||
<li><strong>repo_name</strong> – the name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
|
||
[{&quot;id&quot;: &quot;9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f&quot;,
|
||
&quot;checksum&quot;: &quot;b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087&quot;},
|
||
{&quot;id&quot;: &quot;ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds&quot;,
|
||
&quot;checksum&quot;: &quot;34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew&quot;}]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – OK</li>
|
||
<li><strong>404</strong> – Not found</li>
|
||
</ul>
|
||
|
||
<h2 id="library-repository-images">Library repository images</h2>
|
||
|
||
<h3 id="update-library-repository-images">Update library repository images</h3>
|
||
|
||
<p><code>PUT /v1/repositories/(repo_name)/images</code></p>
|
||
|
||
<p>Update the images for a library repo.</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> PUT /v1/repositories/foobar/images HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Basic akmklmasadalkm==
|
||
|
||
[{&quot;id&quot;: &quot;9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f&quot;,
|
||
&quot;checksum&quot;: &quot;b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087&quot;}]
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo_name</strong> – the library name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
|
||
&quot;&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – Created</li>
|
||
<li><strong>400</strong> – Errors (invalid json, missing or invalid fields, etc)</li>
|
||
<li><strong>401</strong> – Unauthorized</li>
|
||
<li><strong>403</strong> – Account is not Active or permission denied</li>
|
||
</ul>
|
||
|
||
<h3 id="list-library-repository-images">List library repository images</h3>
|
||
|
||
<p><code>GET /v1/repositories/(repo_name)/images</code></p>
|
||
|
||
<p>Get the images for a library repo.</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> GET /v1/repositories/foobar/images HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo_name</strong> – the library name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
|
||
[{&quot;id&quot;: &quot;9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f&quot;,
|
||
&quot;checksum&quot;: &quot;b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087&quot;},
|
||
{&quot;id&quot;: &quot;ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds&quot;,
|
||
&quot;checksum&quot;: &quot;34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew&quot;}]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – OK</li>
|
||
<li><strong>404</strong> – Not found</li>
|
||
</ul>
|
||
|
||
<h1 id="repository-authorization">Repository authorization</h1>
|
||
|
||
<h2 id="library-repository-1">Library repository</h2>
|
||
|
||
<h3 id="authorize-a-token-for-a-library">Authorize a token for a library</h3>
|
||
|
||
<p><code>PUT /v1/repositories/(repo_name)/auth</code></p>
|
||
|
||
<p>Authorize a token for a library repo</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> PUT /v1/repositories/foobar/auth HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Authorization: Token signature=123abc,repository=&quot;library/foobar&quot;,access=write
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo_name</strong> – the library name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
|
||
&quot;OK&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – OK</li>
|
||
<li><strong>403</strong> – Permission denied</li>
|
||
<li><strong>404</strong> – Not found</li>
|
||
</ul>
|
||
|
||
<h2 id="user-repository-1">User repository</h2>
|
||
|
||
<h3 id="authorize-a-token-for-a-user-repository">Authorize a token for a user repository</h3>
|
||
|
||
<p><code>PUT /v1/repositories/(namespace)/(repo_name)/auth</code></p>
|
||
|
||
<p>Authorize a token for a user repo</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> PUT /v1/repositories/foo/bar/auth HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Authorization: Token signature=123abc,repository=&quot;foo/bar&quot;,access=write
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>namespace</strong> – the namespace for the repo</li>
|
||
<li><strong>repo_name</strong> – the name for the repo</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
|
||
&quot;OK&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – OK</li>
|
||
<li><strong>403</strong> – Permission denied</li>
|
||
<li><strong>404</strong> – Not found</li>
|
||
</ul>
|
||
|
||
<h2 id="users">Users</h2>
|
||
|
||
<h3 id="user-login">User login</h3>
|
||
|
||
<p><code>GET /v1/users/</code></p>
|
||
|
||
<p>If you want to check your login, you can try this endpoint</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> GET /v1/users/ HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Authorization: Basic akmklmasadalkm==
|
||
</code></pre>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
|
||
OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>401</strong> – Unauthorized</li>
|
||
<li><strong>403</strong> – Account is not Active</li>
|
||
</ul>
|
||
|
||
<h3 id="user-register">User register</h3>
|
||
|
||
<p><code>POST /v1/users/</code></p>
|
||
|
||
<p>Registering a new account.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /v1/users/ HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
|
||
{&quot;email&quot;: &quot;sam@docker.com&quot;,
|
||
&quot;password&quot;: &quot;toto42&quot;,
|
||
&quot;username&quot;: &quot;foobar&quot;}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>email</strong> – valid email address, that needs to be confirmed</li>
|
||
<li><strong>username</strong> – min 4 character, max 30 characters, must match
|
||
the regular expression [a-z0-9_].</li>
|
||
<li><strong>password</strong> – min 5 characters</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
|
||
&quot;User Created&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – User Created</li>
|
||
<li><strong>400</strong> – Errors (invalid json, missing or invalid fields, etc)</li>
|
||
</ul>
|
||
|
||
<h3 id="update-user">Update user</h3>
|
||
|
||
<p><code>PUT /v1/users/(username)/</code></p>
|
||
|
||
<p>Change a password or email address for given user. If you pass in an
|
||
email, it will add it to your account, it will not remove the old
|
||
one. Passwords will be updated.</p>
|
||
|
||
<p>It is up to the client to verify that that password that is sent is
|
||
the one that they want. Common approach is to have them type it
|
||
twice.</p>
|
||
|
||
<p><strong>Example Request</strong>:</p>
|
||
|
||
<pre><code> PUT /v1/users/fakeuser/ HTTP/1.1
|
||
Host: index.docker.io
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Basic akmklmasadalkm==
|
||
|
||
{&quot;email&quot;: &quot;sam@docker.com&quot;,
|
||
&quot;password&quot;: &quot;toto42&quot;}
|
||
</code></pre>
|
||
|
||
<p>Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>username</strong> – username for the person you want to update</li>
|
||
</ul>
|
||
|
||
<p><strong>Example Response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204
|
||
Vary: Accept
|
||
Content-Type: application/json
|
||
|
||
&quot;&quot;
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – User Updated</li>
|
||
<li><strong>400</strong> – Errors (invalid json, missing or invalid fields, etc)</li>
|
||
<li><strong>401</strong> – Unauthorized</li>
|
||
<li><strong>403</strong> – Account is not Active</li>
|
||
<li><strong>404</strong> – User not found</li>
|
||
</ul>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Docker run reference</title>
|
||
<link>http://localhost/reference/run/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/run/</guid>
|
||
<description>
|
||
|
||
<!-- TODO (@thaJeztah) define more flexible table/td classes -->
|
||
|
||
<p><style>
|
||
.content-body table .no-wrap {
|
||
white-space: nowrap;
|
||
}
|
||
</style></p>
|
||
|
||
<h1 id="docker-run-reference">Docker run reference</h1>
|
||
|
||
<p><strong>Docker runs processes in isolated containers</strong>. When an operator
|
||
executes <code>docker run</code>, she starts a process with its own file system,
|
||
its own networking, and its own isolated process tree. The
|
||
<a href="http://localhost/docker/reference/glossary/#image"><em>Image</em></a> which starts the process may define
|
||
defaults related to the binary to run, the networking to expose, and
|
||
more, but <code>docker run</code> gives final control to the operator who starts
|
||
the container from the image. That&rsquo;s the main reason
|
||
<a href="http://localhost/docker/reference/commandline/cli/#run"><em>run</em></a> has more options than any
|
||
other <code>docker</code> command.</p>
|
||
|
||
<h2 id="general-form">General form</h2>
|
||
|
||
<p>The basic <code>docker run</code> command takes this form:</p>
|
||
|
||
<pre><code>$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
|
||
</code></pre>
|
||
|
||
<p>To learn how to interpret the types of <code>[OPTIONS]</code>,
|
||
see <a href="http://localhost/docker/reference/commandline/cli/#option-types"><em>Option types</em></a>.</p>
|
||
|
||
<p>The <code>run</code> options control the image&rsquo;s runtime behavior in a container. These
|
||
settings affect:</p>
|
||
|
||
<ul>
|
||
<li>detached or foreground running</li>
|
||
<li>container identification</li>
|
||
<li>network settings</li>
|
||
<li>runtime constraints on CPU and memory</li>
|
||
<li>privileges and LXC configuration</li>
|
||
</ul>
|
||
|
||
<p>An image developer may set defaults for these same settings when they create the
|
||
image using the <code>docker build</code> command. Operators, however, can override all
|
||
defaults set by the developer using the <code>run</code> options. And, operators can also
|
||
override nearly all the defaults set by the Docker runtime itself.</p>
|
||
|
||
<p>Finally, depending on your Docker system configuration, you may be required to
|
||
preface each <code>docker</code> command with <code>sudo</code>. To avoid having to use <code>sudo</code> with
|
||
the <code>docker</code> command, your system administrator can create a Unix group called
|
||
<code>docker</code> and add users to it. For more information about this configuration,
|
||
refer to the Docker installation documentation for your operating system.</p>
|
||
|
||
<h2 id="operator-exclusive-options">Operator exclusive options</h2>
|
||
|
||
<p>Only the operator (the person executing <code>docker run</code>) can set the
|
||
following options.</p>
|
||
|
||
<ul>
|
||
<li><a href="#detached-vs-foreground">Detached vs Foreground</a>
|
||
|
||
<ul>
|
||
<li><a href="#detached-d">Detached (-d)</a></li>
|
||
<li><a href="#foreground">Foreground</a></li>
|
||
</ul></li>
|
||
<li><a href="#container-identification">Container Identification</a>
|
||
|
||
<ul>
|
||
<li><a href="#name-name">Name (&ndash;name)</a></li>
|
||
<li><a href="#pid-equivalent">PID Equivalent</a></li>
|
||
</ul></li>
|
||
<li><a href="#ipc-settings-ipc">IPC Settings (&ndash;ipc)</a></li>
|
||
<li><a href="#network-settings">Network Settings</a></li>
|
||
<li><a href="#restart-policies-restart">Restart Policies (&ndash;restart)</a></li>
|
||
<li><a href="#clean-up-rm">Clean Up (&ndash;rm)</a></li>
|
||
<li><a href="#runtime-constraints-on-cpu-and-memory">Runtime Constraints on CPU and Memory</a></li>
|
||
<li><a href="#runtime-privilege-linux-capabilities-and-lxc-configuration">Runtime Privilege, Linux Capabilities, and LXC Configuration</a></li>
|
||
</ul>
|
||
|
||
<h2 id="detached-vs-foreground">Detached vs foreground</h2>
|
||
|
||
<p>When starting a Docker container, you must first decide if you want to
|
||
run the container in the background in a &ldquo;detached&rdquo; mode or in the
|
||
default foreground mode:</p>
|
||
|
||
<pre><code>-d=false: Detached mode: Run container in the background, print new container id
|
||
</code></pre>
|
||
|
||
<h3 id="detached-d">Detached (-d)</h3>
|
||
|
||
<p>In detached mode (<code>-d=true</code> or just <code>-d</code>), all I/O should be done
|
||
through network connections or shared volumes because the container is
|
||
no longer listening to the command line where you executed <code>docker run</code>.
|
||
You can reattach to a detached container with <code>docker</code>
|
||
<a href="http://localhost/docker/reference/commandline/cli/#attach"><em>attach</em></a>. If you choose to run a
|
||
container in the detached mode, then you cannot use the <code>--rm</code> option.</p>
|
||
|
||
<h3 id="foreground">Foreground</h3>
|
||
|
||
<p>In foreground mode (the default when <code>-d</code> is not specified), <code>docker
|
||
run</code> can start the process in the container and attach the console to
|
||
the process&rsquo;s standard input, output, and standard error. It can even
|
||
pretend to be a TTY (this is what most command line executables expect)
|
||
and pass along signals. All of that is configurable:</p>
|
||
|
||
<pre><code>-a=[] : Attach to `STDIN`, `STDOUT` and/or `STDERR`
|
||
-t=false : Allocate a pseudo-tty
|
||
--sig-proxy=true: Proxify all received signal to the process (non-TTY mode only)
|
||
-i=false : Keep STDIN open even if not attached
|
||
</code></pre>
|
||
|
||
<p>If you do not specify <code>-a</code> then Docker will <a href="https://github.com/docker/docker/blob/
|
||
75a7f4d90cde0295bcfb7213004abce8d4779b75/commands.go#L1797">attach all standard
|
||
streams</a>. You can
|
||
specify to which of the three standard streams (<code>STDIN</code>, <code>STDOUT</code>,
|
||
<code>STDERR</code>) you&rsquo;d like to connect instead, as in:</p>
|
||
|
||
<pre><code>$ docker run -a stdin -a stdout -i -t ubuntu /bin/bash
|
||
</code></pre>
|
||
|
||
<p>For interactive processes (like a shell), you must use <code>-i -t</code> together in
|
||
order to allocate a tty for the container process. <code>-i -t</code> is often written <code>-it</code>
|
||
as you&rsquo;ll see in later examples. Specifying <code>-t</code> is forbidden when the client
|
||
standard output is redirected or piped, such as in:
|
||
<code>echo test | docker run -i busybox cat</code>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: A process running as PID 1 inside a container is treated
|
||
specially by Linux: it ignores any signal with the default action.
|
||
So, the process will not terminate on <code>SIGINT</code> or <code>SIGTERM</code> unless it is
|
||
coded to do so.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="container-identification">Container identification</h2>
|
||
|
||
<h3 id="name-name">Name (&ndash;name)</h3>
|
||
|
||
<p>The operator can identify a container in three ways:</p>
|
||
|
||
<ul>
|
||
<li>UUID long identifier
|
||
(&ldquo;f78375b1c487e03c9438c729345e54db9d20cfa2ac1fc3494b6eb60872e74778&rdquo;)</li>
|
||
<li>UUID short identifier (&ldquo;f78375b1c487&rdquo;)</li>
|
||
<li>Name (&ldquo;evil_ptolemy&rdquo;)</li>
|
||
</ul>
|
||
|
||
<p>The UUID identifiers come from the Docker daemon, and if you do not
|
||
assign a name to the container with <code>--name</code> then the daemon will also
|
||
generate a random string name too. The name can become a handy way to
|
||
add meaning to a container since you can use this name when defining
|
||
<a href="http://localhost/userguide/dockerlinks"><em>links</em></a> (or any
|
||
other place you need to identify a container). This works for both
|
||
background and foreground Docker containers.</p>
|
||
|
||
<h3 id="pid-equivalent">PID equivalent</h3>
|
||
|
||
<p>Finally, to help with automation, you can have Docker write the
|
||
container ID out to a file of your choosing. This is similar to how some
|
||
programs might write out their process ID to a file (you&rsquo;ve seen them as
|
||
PID files):</p>
|
||
|
||
<pre><code>--cidfile=&quot;&quot;: Write the container ID to the file
|
||
</code></pre>
|
||
|
||
<h3 id="image-tag">Image[:tag]</h3>
|
||
|
||
<p>While not strictly a means of identifying a container, you can specify a version of an
|
||
image you&rsquo;d like to run the container with by adding <code>image[:tag]</code> to the command. For
|
||
example, <code>docker run ubuntu:14.04</code>.</p>
|
||
|
||
<h3 id="image-digest">Image[@digest]</h3>
|
||
|
||
<p>Images using the v2 or later image format have a content-addressable identifier
|
||
called a digest. As long as the input used to generate the image is unchanged,
|
||
the digest value is predictable and referenceable.</p>
|
||
|
||
<h2 id="pid-settings-pid">PID settings (&ndash;pid)</h2>
|
||
|
||
<pre><code>--pid=&quot;&quot; : Set the PID (Process) Namespace mode for the container,
|
||
'host': use the host's PID namespace inside the container
|
||
</code></pre>
|
||
|
||
<p>By default, all containers have the PID namespace enabled.</p>
|
||
|
||
<p>PID namespace provides separation of processes. The PID Namespace removes the
|
||
view of the system processes, and allows process ids to be reused including
|
||
pid 1.</p>
|
||
|
||
<p>In certain cases you want your container to share the host&rsquo;s process namespace,
|
||
basically allowing processes within the container to see all of the processes
|
||
on the system. For example, you could build a container with debugging tools
|
||
like <code>strace</code> or <code>gdb</code>, but want to use these tools when debugging processes
|
||
within the container.</p>
|
||
|
||
<pre><code>$ docker run --pid=host rhel7 strace -p 1234
|
||
</code></pre>
|
||
|
||
<p>This command would allow you to use <code>strace</code> inside the container on pid 1234 on
|
||
the host.</p>
|
||
|
||
<h2 id="uts-settings-uts">UTS settings (&ndash;uts)</h2>
|
||
|
||
<pre><code>--uts=&quot;&quot; : Set the UTS namespace mode for the container,
|
||
'host': use the host's UTS namespace inside the container
|
||
</code></pre>
|
||
|
||
<p>The UTS namespace is for setting the hostname and the domain that is visible
|
||
to running processes in that namespace. By default, all containers, including
|
||
those with <code>--net=host</code>, have their own UTS namespace. The <code>host</code> setting will
|
||
result in the container using the same UTS namespace as the host.</p>
|
||
|
||
<p>You may wish to share the UTS namespace with the host if you would like the
|
||
hostname of the container to change as the hostname of the host changes. A
|
||
more advanced use case would be changing the host&rsquo;s hostname from a container.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: <code>--uts=&quot;host&quot;</code> gives the container full access to change the
|
||
hostname of the host and is therefore considered insecure.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="ipc-settings-ipc">IPC settings (&ndash;ipc)</h2>
|
||
|
||
<pre><code>--ipc=&quot;&quot; : Set the IPC mode for the container,
|
||
'container:&lt;name|id&gt;': reuses another container's IPC namespace
|
||
'host': use the host's IPC namespace inside the container
|
||
</code></pre>
|
||
|
||
<p>By default, all containers have the IPC namespace enabled.</p>
|
||
|
||
<p>IPC (POSIX/SysV IPC) namespace provides separation of named shared memory
|
||
segments, semaphores and message queues.</p>
|
||
|
||
<p>Shared memory segments are used to accelerate inter-process communication at
|
||
memory speed, rather than through pipes or through the network stack. Shared
|
||
memory is commonly used by databases and custom-built (typically C/OpenMPI,
|
||
C++/using boost libraries) high performance applications for scientific
|
||
computing and financial services industries. If these types of applications
|
||
are broken into multiple containers, you might need to share the IPC mechanisms
|
||
of the containers.</p>
|
||
|
||
<h2 id="network-settings">Network settings</h2>
|
||
|
||
<pre><code>--dns=[] : Set custom dns servers for the container
|
||
--net=&quot;bridge&quot; : Set the Network mode for the container
|
||
'bridge': creates a new network stack for the container on the docker bridge
|
||
'none': no networking for this container
|
||
'container:&lt;name|id&gt;': reuses another container network stack
|
||
'host': use the host network stack inside the container
|
||
--add-host=&quot;&quot; : Add a line to /etc/hosts (host:IP)
|
||
--mac-address=&quot;&quot; : Sets the container's Ethernet device's MAC address
|
||
</code></pre>
|
||
|
||
<p>By default, all containers have networking enabled and they can make any
|
||
outgoing connections. The operator can completely disable networking
|
||
with <code>docker run --net none</code> which disables all incoming and outgoing
|
||
networking. In cases like this, you would perform I/O through files or
|
||
<code>STDIN</code> and <code>STDOUT</code> only.</p>
|
||
|
||
<p>Your container will use the same DNS servers as the host by default, but
|
||
you can override this with <code>--dns</code>.</p>
|
||
|
||
<p>By default, the MAC address is generated using the IP address allocated to the
|
||
container. You can set the container&rsquo;s MAC address explicitly by providing a
|
||
MAC address via the <code>--mac-address</code> parameter (format:<code>12:34:56:78:9a:bc</code>).</p>
|
||
|
||
<p>Supported networking modes are:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th class="no-wrap">Mode</th>
|
||
<th>Description</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="no-wrap"><strong>none</strong></td>
|
||
<td>
|
||
No networking in the container.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>bridge</strong> (default)</td>
|
||
<td>
|
||
Connect the container to the bridge via veth interfaces.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>host</strong></td>
|
||
<td>
|
||
Use the host's network stack inside the container.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>container</strong>:&lt;name|id&gt;</td>
|
||
<td>
|
||
Use the network stack of another container, specified via
|
||
its *name* or *id*.
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h4 id="mode-none">Mode: none</h4>
|
||
|
||
<p>With the networking mode set to <code>none</code> a container will not have a
|
||
access to any external routes. The container will still have a
|
||
<code>loopback</code> interface enabled in the container but it does not have any
|
||
routes to external traffic.</p>
|
||
|
||
<h4 id="mode-bridge">Mode: bridge</h4>
|
||
|
||
<p>With the networking mode set to <code>bridge</code> a container will use docker&rsquo;s
|
||
default networking setup. A bridge is setup on the host, commonly named
|
||
<code>docker0</code>, and a pair of <code>veth</code> interfaces will be created for the
|
||
container. One side of the <code>veth</code> pair will remain on the host attached
|
||
to the bridge while the other side of the pair will be placed inside the
|
||
container&rsquo;s namespaces in addition to the <code>loopback</code> interface. An IP
|
||
address will be allocated for containers on the bridge&rsquo;s network and
|
||
traffic will be routed though this bridge to the container.</p>
|
||
|
||
<h4 id="mode-host">Mode: host</h4>
|
||
|
||
<p>With the networking mode set to <code>host</code> a container will share the host&rsquo;s
|
||
network stack and all interfaces from the host will be available to the
|
||
container. The container&rsquo;s hostname will match the hostname on the host
|
||
system. Publishing ports and linking to other containers will not work
|
||
when sharing the host&rsquo;s network stack. Note that <code>--add-host</code> <code>--hostname</code>
|
||
<code>--dns</code> <code>--dns-search</code> and <code>--mac-address</code> is invalid in <code>host</code> netmode.</p>
|
||
|
||
<p>Compared to the default <code>bridge</code> mode, the <code>host</code> mode gives <em>significantly</em>
|
||
better networking performance since it uses the host&rsquo;s native networking stack
|
||
whereas the bridge has to go through one level of virtualization through the
|
||
docker daemon. It is recommended to run containers in this mode when their
|
||
networking performance is critical, for example, a production Load Balancer
|
||
or a High Performance Web Server.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: <code>--net=&quot;host&quot;</code> gives the container full access to local system
|
||
services such as D-bus and is therefore considered insecure.</p>
|
||
</blockquote>
|
||
|
||
<h4 id="mode-container">Mode: container</h4>
|
||
|
||
<p>With the networking mode set to <code>container</code> a container will share the
|
||
network stack of another container. The other container&rsquo;s name must be
|
||
provided in the format of <code>--net container:&lt;name|id&gt;</code>. Note that <code>--add-host</code>
|
||
<code>--hostname</code> <code>--dns</code> <code>--dns-search</code> and <code>--mac-address</code> is invalid
|
||
in <code>container</code> netmode.</p>
|
||
|
||
<p>Example running a Redis container with Redis binding to <code>localhost</code> then
|
||
running the <code>redis-cli</code> command and connecting to the Redis server over the
|
||
<code>localhost</code> interface.</p>
|
||
|
||
<pre><code>$ docker run -d --name redis example/redis --bind 127.0.0.1
|
||
$ # use the redis container's network stack to access localhost
|
||
$ docker run --rm -it --net container:redis example/redis-cli -h 127.0.0.1
|
||
</code></pre>
|
||
|
||
<h3 id="managing-etc-hosts">Managing /etc/hosts</h3>
|
||
|
||
<p>Your container will have lines in <code>/etc/hosts</code> which define the hostname of the
|
||
container itself as well as <code>localhost</code> and a few other common things. The
|
||
<code>--add-host</code> flag can be used to add additional lines to <code>/etc/hosts</code>.</p>
|
||
|
||
<pre><code>$ docker run -it --add-host db-static:86.75.30.9 ubuntu cat /etc/hosts
|
||
172.17.0.22 09d03f76bf2c
|
||
fe00::0 ip6-localnet
|
||
ff00::0 ip6-mcastprefix
|
||
ff02::1 ip6-allnodes
|
||
ff02::2 ip6-allrouters
|
||
127.0.0.1 localhost
|
||
::1 localhost ip6-localhost ip6-loopback
|
||
86.75.30.9 db-static
|
||
</code></pre>
|
||
|
||
<h2 id="restart-policies-restart">Restart policies (&ndash;restart)</h2>
|
||
|
||
<p>Using the <code>--restart</code> flag on Docker run you can specify a restart policy for
|
||
how a container should or should not be restarted on exit.</p>
|
||
|
||
<p>When a restart policy is active on a container, it will be shown as either <code>Up</code>
|
||
or <code>Restarting</code> in <a href="http://localhost/docker/reference/commandline/cli/#ps"><code>docker ps</code></a>. It can also be
|
||
useful to use <a href="http://localhost/docker/reference/commandline/cli/#events"><code>docker events</code></a> to see the
|
||
restart policy in effect.</p>
|
||
|
||
<p>Docker supports the following restart policies:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Policy</th>
|
||
<th>Result</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><strong>no</strong></td>
|
||
<td>
|
||
Do not automatically restart the container when it exits. This is the
|
||
default.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<span style="white-space: nowrap">
|
||
<strong>on-failure</strong>[:max-retries]
|
||
</span>
|
||
</td>
|
||
<td>
|
||
Restart only if the container exits with a non-zero exit status.
|
||
Optionally, limit the number of restart retries the Docker
|
||
daemon attempts.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong>always</strong></td>
|
||
<td>
|
||
Always restart the container regardless of the exit status.
|
||
When you specify always, the Docker daemon will try to restart
|
||
the container indefinitely.
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<p>An ever increasing delay (double the previous delay, starting at 100
|
||
milliseconds) is added before each restart to prevent flooding the server.
|
||
This means the daemon will wait for 100 ms, then 200 ms, 400, 800, 1600,
|
||
and so on until either the <code>on-failure</code> limit is hit, or when you <code>docker stop</code>
|
||
or <code>docker rm -f</code> the container.</p>
|
||
|
||
<p>If a container is successfully restarted (the container is started and runs
|
||
for at least 10 seconds), the delay is reset to its default value of 100 ms.</p>
|
||
|
||
<p>You can specify the maximum amount of times Docker will try to restart the
|
||
container when using the <strong>on-failure</strong> policy. The default is that Docker
|
||
will try forever to restart the container. The number of (attempted) restarts
|
||
for a container can be obtained via <a href="http://localhost/reference/commandline/cli/#inspect"><code>docker inspect</code></a>. For example, to get the number of restarts
|
||
for container &ldquo;my-container&rdquo;;</p>
|
||
|
||
<pre><code>$ docker inspect -f &quot;{{ .RestartCount }}&quot; my-container
|
||
# 2
|
||
</code></pre>
|
||
|
||
<p>Or, to get the last time the container was (re)started;</p>
|
||
|
||
<pre><code>$ docker inspect -f &quot;{{ .State.StartedAt }}&quot; my-container
|
||
# 2015-03-04T23:47:07.691840179Z
|
||
</code></pre>
|
||
|
||
<p>You cannot set any restart policy in combination with
|
||
<a href="#clean-up-rm">&ldquo;clean up (&ndash;rm)&rdquo;</a>. Setting both <code>--restart</code> and <code>--rm</code>
|
||
results in an error.</p>
|
||
|
||
<p>###Examples</p>
|
||
|
||
<pre><code>$ docker run --restart=always redis
|
||
</code></pre>
|
||
|
||
<p>This will run the <code>redis</code> container with a restart policy of <strong>always</strong>
|
||
so that if the container exits, Docker will restart it.</p>
|
||
|
||
<pre><code>$ docker run --restart=on-failure:10 redis
|
||
</code></pre>
|
||
|
||
<p>This will run the <code>redis</code> container with a restart policy of <strong>on-failure</strong>
|
||
and a maximum restart count of 10. If the <code>redis</code> container exits with a
|
||
non-zero exit status more than 10 times in a row Docker will abort trying to
|
||
restart the container. Providing a maximum restart limit is only valid for the
|
||
<strong>on-failure</strong> policy.</p>
|
||
|
||
<h2 id="clean-up-rm">Clean up (&ndash;rm)</h2>
|
||
|
||
<p>By default a container&rsquo;s file system persists even after the container
|
||
exits. This makes debugging a lot easier (since you can inspect the
|
||
final state) and you retain all your data by default. But if you are
|
||
running short-term <strong>foreground</strong> processes, these container file
|
||
systems can really pile up. If instead you&rsquo;d like Docker to
|
||
<strong>automatically clean up the container and remove the file system when
|
||
the container exits</strong>, you can add the <code>--rm</code> flag:</p>
|
||
|
||
<pre><code>--rm=false: Automatically remove the container when it exits (incompatible with -d)
|
||
</code></pre>
|
||
|
||
<h2 id="security-configuration">Security configuration</h2>
|
||
|
||
<pre><code>--security-opt=&quot;label:user:USER&quot; : Set the label user for the container
|
||
--security-opt=&quot;label:role:ROLE&quot; : Set the label role for the container
|
||
--security-opt=&quot;label:type:TYPE&quot; : Set the label type for the container
|
||
--security-opt=&quot;label:level:LEVEL&quot; : Set the label level for the container
|
||
--security-opt=&quot;label:disable&quot; : Turn off label confinement for the container
|
||
--security-opt=&quot;apparmor:PROFILE&quot; : Set the apparmor profile to be applied
|
||
to the container
|
||
</code></pre>
|
||
|
||
<p>You can override the default labeling scheme for each container by specifying
|
||
the <code>--security-opt</code> flag. For example, you can specify the MCS/MLS level, a
|
||
requirement for MLS systems. Specifying the level in the following command
|
||
allows you to share the same content between containers.</p>
|
||
|
||
<pre><code>$ docker run --security-opt label:level:s0:c100,c200 -i -t fedora bash
|
||
</code></pre>
|
||
|
||
<p>An MLS example might be:</p>
|
||
|
||
<pre><code>$ docker run --security-opt label:level:TopSecret -i -t rhel7 bash
|
||
</code></pre>
|
||
|
||
<p>To disable the security labeling for this container versus running with the
|
||
<code>--permissive</code> flag, use the following command:</p>
|
||
|
||
<pre><code>$ docker run --security-opt label:disable -i -t fedora bash
|
||
</code></pre>
|
||
|
||
<p>If you want a tighter security policy on the processes within a container,
|
||
you can specify an alternate type for the container. You could run a container
|
||
that is only allowed to listen on Apache ports by executing the following
|
||
command:</p>
|
||
|
||
<pre><code>$ docker run --security-opt label:type:svirt_apache_t -i -t centos bash
|
||
</code></pre>
|
||
|
||
<p>Note:</p>
|
||
|
||
<p>You would have to write policy defining a <code>svirt_apache_t</code> type.</p>
|
||
|
||
<h2 id="specifying-custom-cgroups">Specifying custom cgroups</h2>
|
||
|
||
<p>Using the <code>--cgroup-parent</code> flag, you can pass a specific cgroup to run a
|
||
container in. This allows you to create and manage cgroups on their own. You can
|
||
define custom resources for those cgroups and put containers under a common
|
||
parent group.</p>
|
||
|
||
<h2 id="runtime-constraints-on-resources">Runtime constraints on resources</h2>
|
||
|
||
<p>The operator can also adjust the performance parameters of the
|
||
container:</p>
|
||
|
||
<pre><code>-m, --memory=&quot;&quot;: Memory limit (format: &lt;number&gt;&lt;optional unit&gt;, where unit = b, k, m or g)
|
||
--memory-swap=&quot;&quot;: Total memory limit (memory + swap, format: &lt;number&gt;&lt;optional unit&gt;, where unit = b, k, m or g)
|
||
-c, --cpu-shares=0: CPU shares (relative weight)
|
||
--cpu-period=0: Limit the CPU CFS (Completely Fair Scheduler) period
|
||
--cpuset-cpus=&quot;&quot;: CPUs in which to allow execution (0-3, 0,1)
|
||
--cpuset-mems=&quot;&quot;: Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
|
||
--cpu-quota=0: Limit the CPU CFS (Completely Fair Scheduler) quota
|
||
--blkio-weight=0: Block IO weight (relative weight) accepts a weight value between 10 and 1000.
|
||
--oom-kill-disable=true|false: Whether to disable OOM Killer for the container or not.
|
||
</code></pre>
|
||
|
||
<h3 id="memory-constraints">Memory constraints</h3>
|
||
|
||
<p>We have four ways to set memory usage:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Option</th>
|
||
<th>Result</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="no-wrap">
|
||
<strong>memory=inf, memory-swap=inf</strong> (default)
|
||
</td>
|
||
<td>
|
||
There is no memory limit for the container. The container can use
|
||
as much memory as needed.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>memory=L&lt;inf, memory-swap=inf</strong></td>
|
||
<td>
|
||
(specify memory and set memory-swap as <code>-1</code>) The container is
|
||
not allowed to use more than L bytes of memory, but can use as much swap
|
||
as is needed (if the host supports swap memory).
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap"><strong>memory=L&lt;inf, memory-swap=2*L</strong></td>
|
||
<td>
|
||
(specify memory without memory-swap) The container is not allowed to
|
||
use more than L bytes of memory, swap *plus* memory usage is double
|
||
of that.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td class="no-wrap">
|
||
<strong>memory=L&lt;inf, memory-swap=S&lt;inf, L&lt;=S</strong>
|
||
</td>
|
||
<td>
|
||
(specify both memory and memory-swap) The container is not allowed to
|
||
use more than L bytes of memory, swap *plus* memory usage is limited
|
||
by S.
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<pre><code>$ docker run -ti ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set nothing about memory, this means the processes in the container can use
|
||
as much memory and swap memory as they need.</p>
|
||
|
||
<pre><code>$ docker run -ti -m 300M --memory-swap -1 ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set memory limit and disabled swap memory limit, this means the processes in
|
||
the container can use 300M memory and as much swap memory as they need (if the
|
||
host supports swap memory).</p>
|
||
|
||
<pre><code>$ docker run -ti -m 300M ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set memory limit only, this means the processes in the container can use
|
||
300M memory and 300M swap memory, by default, the total virtual memory size
|
||
(&ndash;memory-swap) will be set as double of memory, in this case, memory + swap
|
||
would be 2*300M, so processes can use 300M swap memory as well.</p>
|
||
|
||
<pre><code>$ docker run -ti -m 300M --memory-swap 1G ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>We set both memory and swap memory, so the processes in the container can use
|
||
300M memory and 700M swap memory.</p>
|
||
|
||
<p>By default, Docker kills processes in a container if an out-of-memory (OOM)
|
||
error occurs. To change this behaviour, use the <code>--oom-kill-disable</code> option.
|
||
Only disable the OOM killer on containers where you have also set the
|
||
<code>-m/--memory</code> option. If the <code>-m</code> flag is not set, this can result in the host
|
||
running out of memory and require killing the host&rsquo;s system processes to free
|
||
memory.</p>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<p>The following example limits the memory to 100M and disables the OOM killer for
|
||
this container:</p>
|
||
|
||
<pre><code>$ docker run -ti -m 100M --oom-kill-disable ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>The following example, illustrates a dangerous way to use the flag:</p>
|
||
|
||
<pre><code>$ docker run -ti --oom-kill-disable ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>The container has unlimited memory which can cause the host to run out memory
|
||
and require killing system processes to free memory.</p>
|
||
|
||
<h3 id="cpu-share-constraint">CPU share constraint</h3>
|
||
|
||
<p>By default, all containers get the same proportion of CPU cycles. This proportion
|
||
can be modified by changing the container&rsquo;s CPU share weighting relative
|
||
to the weighting of all other running containers.</p>
|
||
|
||
<p>To modify the proportion from the default of 1024, use the <code>-c</code> or <code>--cpu-shares</code>
|
||
flag to set the weighting to 2 or higher.</p>
|
||
|
||
<p>The proportion will only apply when CPU-intensive processes are running.
|
||
When tasks in one container are idle, other containers can use the
|
||
left-over CPU time. The actual amount of CPU time will vary depending on
|
||
the number of containers running on the system.</p>
|
||
|
||
<p>For example, consider three containers, one has a cpu-share of 1024 and
|
||
two others have a cpu-share setting of 512. When processes in all three
|
||
containers attempt to use 100% of CPU, the first container would receive
|
||
50% of the total CPU time. If you add a fourth container with a cpu-share
|
||
of 1024, the first container only gets 33% of the CPU. The remaining containers
|
||
receive 16.5%, 16.5% and 33% of the CPU.</p>
|
||
|
||
<p>On a multi-core system, the shares of CPU time are distributed over all CPU
|
||
cores. Even if a container is limited to less than 100% of CPU time, it can
|
||
use 100% of each individual CPU core.</p>
|
||
|
||
<p>For example, consider a system with more than three cores. If you start one
|
||
container <code>{C0}</code> with <code>-c=512</code> running one process, and another container
|
||
<code>{C1}</code> with <code>-c=1024</code> running two processes, this can result in the following
|
||
division of CPU shares:</p>
|
||
|
||
<pre><code>PID container CPU CPU share
|
||
100 {C0} 0 100% of CPU0
|
||
101 {C1} 1 100% of CPU1
|
||
102 {C1} 2 100% of CPU2
|
||
</code></pre>
|
||
|
||
<h3 id="cpu-period-constraint">CPU period constraint</h3>
|
||
|
||
<p>The default CPU CFS (Completely Fair Scheduler) period is 100ms. We can use
|
||
<code>--cpu-period</code> to set the period of CPUs to limit the container&rsquo;s CPU usage.
|
||
And usually <code>--cpu-period</code> should work with <code>--cpu-quota</code>.</p>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<pre><code>$ docker run -ti --cpu-period=50000 --cpu-quota=25000 ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>If there is 1 CPU, this means the container can get 50% CPU worth of run-time every 50ms.</p>
|
||
|
||
<p>For more information, see the <a href="https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt">CFS documentation on bandwidth limiting</a>.</p>
|
||
|
||
<h3 id="cpuset-constraint">Cpuset constraint</h3>
|
||
|
||
<p>We can set cpus in which to allow execution for containers.</p>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<pre><code>$ docker run -ti --cpuset-cpus=&quot;1,3&quot; ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>This means processes in container can be executed on cpu 1 and cpu 3.</p>
|
||
|
||
<pre><code>$ docker run -ti --cpuset-cpus=&quot;0-2&quot; ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>This means processes in container can be executed on cpu 0, cpu 1 and cpu 2.</p>
|
||
|
||
<p>We can set mems in which to allow execution for containers. Only effective
|
||
on NUMA systems.</p>
|
||
|
||
<p>Examples:</p>
|
||
|
||
<pre><code>$ docker run -ti --cpuset-mems=&quot;1,3&quot; ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>This example restricts the processes in the container to only use memory from
|
||
memory nodes 1 and 3.</p>
|
||
|
||
<pre><code>$ docker run -ti --cpuset-mems=&quot;0-2&quot; ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>This example restricts the processes in the container to only use memory from
|
||
memory nodes 0, 1 and 2.</p>
|
||
|
||
<h3 id="cpu-quota-constraint">CPU quota constraint</h3>
|
||
|
||
<p>The <code>--cpu-quota</code> flag limits the container&rsquo;s CPU usage. The default 0 value
|
||
allows the container to take 100% of a CPU resource (1 CPU). The CFS (Completely Fair
|
||
Scheduler) handles resource allocation for executing processes and is default
|
||
Linux Scheduler used by the kernel. Set this value to 50000 to limit the container
|
||
to 50% of a CPU resource. For multiple CPUs, adjust the <code>--cpu-quota</code> as necessary.
|
||
For more information, see the <a href="https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt">CFS documentation on bandwidth limiting</a>.</p>
|
||
|
||
<h3 id="block-io-bandwidth-blkio-constraint">Block IO bandwidth (Blkio) constraint</h3>
|
||
|
||
<p>By default, all containers get the same proportion of block IO bandwidth
|
||
(blkio). This proportion is 500. To modify this proportion, change the
|
||
container&rsquo;s blkio weight relative to the weighting of all other running
|
||
containers using the <code>--blkio-weight</code> flag.</p>
|
||
|
||
<p>The <code>--blkio-weight</code> flag can set the weighting to a value between 10 to 1000.
|
||
For example, the commands below create two containers with different blkio
|
||
weight:</p>
|
||
|
||
<pre><code>$ docker run -ti --name c1 --blkio-weight 300 ubuntu:14.04 /bin/bash
|
||
$ docker run -ti --name c2 --blkio-weight 600 ubuntu:14.04 /bin/bash
|
||
</code></pre>
|
||
|
||
<p>If you do block IO in the two containers at the same time, by, for example:</p>
|
||
|
||
<pre><code>$ time dd if=/mnt/zerofile of=test.out bs=1M count=1024 oflag=direct
|
||
</code></pre>
|
||
|
||
<p>You&rsquo;ll find that the proportion of time is the same as the proportion of blkio
|
||
weights of the two containers.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong> The blkio weight setting is only available for direct IO. Buffered IO
|
||
is not currently supported.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="runtime-privilege-linux-capabilities-and-lxc-configuration">Runtime privilege, Linux capabilities, and LXC configuration</h2>
|
||
|
||
<pre><code>--cap-add: Add Linux capabilities
|
||
--cap-drop: Drop Linux capabilities
|
||
--privileged=false: Give extended privileges to this container
|
||
--device=[]: Allows you to run devices inside the container without the --privileged flag.
|
||
--lxc-conf=[]: Add custom lxc options
|
||
</code></pre>
|
||
|
||
<p>By default, Docker containers are &ldquo;unprivileged&rdquo; and cannot, for
|
||
example, run a Docker daemon inside a Docker container. This is because
|
||
by default a container is not allowed to access any devices, but a
|
||
&ldquo;privileged&rdquo; container is given access to all devices (see <a href="https://github.com/docker/docker/blob/master/daemon/execdriver/lxc/lxc_template.go">lxc-template.go</a>
|
||
and documentation on <a href="https://www.kernel.org/doc/Documentation/cgroups/devices.txt">cgroups devices</a>).</p>
|
||
|
||
<p>When the operator executes <code>docker run --privileged</code>, Docker will enable
|
||
to access to all devices on the host as well as set some configuration
|
||
in AppArmor or SELinux to allow the container nearly all the same access to the
|
||
host as processes running outside containers on the host. Additional
|
||
information about running with <code>--privileged</code> is available on the
|
||
<a href="http://blog.docker.com/2013/09/docker-can-now-run-within-docker/">Docker Blog</a>.</p>
|
||
|
||
<p>If you want to limit access to a specific device or devices you can use
|
||
the <code>--device</code> flag. It allows you to specify one or more devices that
|
||
will be accessible within the container.</p>
|
||
|
||
<pre><code>$ docker run --device=/dev/snd:/dev/snd ...
|
||
</code></pre>
|
||
|
||
<p>By default, the container will be able to <code>read</code>, <code>write</code>, and <code>mknod</code> these devices.
|
||
This can be overridden using a third <code>:rwm</code> set of options to each <code>--device</code> flag:</p>
|
||
|
||
<pre><code>$ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc
|
||
|
||
Command (m for help): q
|
||
$ docker run --device=/dev/sda:/dev/xvdc:r --rm -it ubuntu fdisk /dev/xvdc
|
||
You will not be able to write the partition table.
|
||
|
||
Command (m for help): q
|
||
|
||
$ docker run --device=/dev/sda:/dev/xvdc:w --rm -it ubuntu fdisk /dev/xvdc
|
||
crash....
|
||
|
||
$ docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk /dev/xvdc
|
||
fdisk: unable to open /dev/xvdc: Operation not permitted
|
||
</code></pre>
|
||
|
||
<p>In addition to <code>--privileged</code>, the operator can have fine grain control over the
|
||
capabilities using <code>--cap-add</code> and <code>--cap-drop</code>. By default, Docker has a default
|
||
list of capabilities that are kept. The following table lists the Linux capability options which can be added or dropped.</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Capability Key</th>
|
||
<th>Capability Description</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody>
|
||
<tr>
|
||
<td>SETPCAP</td>
|
||
<td>Modify process capabilities.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_MODULE</td>
|
||
<td>Load and unload kernel modules.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_RAWIO</td>
|
||
<td>Perform I/O port operations (iopl(2) and ioperm(2)).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_PACCT</td>
|
||
<td>Use acct(2), switch process accounting on or off.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_ADMIN</td>
|
||
<td>Perform a range of system administration operations.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_NICE</td>
|
||
<td>Raise process nice value (nice(2), setpriority(2)) and change the nice value for arbitrary processes.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_RESOURCE</td>
|
||
<td>Override resource Limits.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_TIME</td>
|
||
<td>Set system clock (settimeofday(2), stime(2), adjtimex(2)); set real-time (hardware) clock.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_TTY_CONFIG</td>
|
||
<td>Use vhangup(2); employ various privileged ioctl(2) operations on virtual terminals.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>MKNOD</td>
|
||
<td>Create special files using mknod(2).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>AUDIT_WRITE</td>
|
||
<td>Write records to kernel auditing log.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>AUDIT_CONTROL</td>
|
||
<td>Enable and disable kernel auditing; change auditing filter rules; retrieve auditing status and filtering rules.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>MAC_OVERRIDE</td>
|
||
<td>Allow MAC configuration or state changes. Implemented for the Smack LSM.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>MAC_ADMIN</td>
|
||
<td>Override Mandatory Access Control (MAC). Implemented for the Smack Linux Security Module (LSM).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>NET_ADMIN</td>
|
||
<td>Perform various network-related operations.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYSLOG</td>
|
||
<td>Perform privileged syslog(2) operations.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>CHOWN</td>
|
||
<td>Make arbitrary changes to file UIDs and GIDs (see chown(2)).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>NET_RAW</td>
|
||
<td>Use RAW and PACKET sockets.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>DAC_OVERRIDE</td>
|
||
<td>Bypass file read, write, and execute permission checks.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>FOWNER</td>
|
||
<td>Bypass permission checks on operations that normally require the file system UID of the process to match the UID of the file.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>DAC_READ_SEARCH</td>
|
||
<td>Bypass file read permission checks and directory read and execute permission checks.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>FSETID</td>
|
||
<td>Don&rsquo;t clear set-user-ID and set-group-ID permission bits when a file is modified.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>KILL</td>
|
||
<td>Bypass permission checks for sending signals.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SETGID</td>
|
||
<td>Make arbitrary manipulations of process GIDs and supplementary GID list.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SETUID</td>
|
||
<td>Make arbitrary manipulations of process UIDs.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>LINUX_IMMUTABLE</td>
|
||
<td>Set the FS_APPEND_FL and FS_IMMUTABLE_FL i-node flags.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>NET_BIND_SERVICE</td>
|
||
<td>Bind a socket to internet domain privileged ports (port numbers less than 1024).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>NET_BROADCAST</td>
|
||
<td>Make socket broadcasts, and listen to multicasts.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>IPC_LOCK</td>
|
||
<td>Lock memory (mlock(2), mlockall(2), mmap(2), shmctl(2)).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>IPC_OWNER</td>
|
||
<td>Bypass permission checks for operations on System V IPC objects.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_CHROOT</td>
|
||
<td>Use chroot(2), change root directory.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_PTRACE</td>
|
||
<td>Trace arbitrary processes using ptrace(2).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SYS_BOOT</td>
|
||
<td>Use reboot(2) and kexec_load(2), reboot and load a new kernel for later execution.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>LEASE</td>
|
||
<td>Establish leases on arbitrary files (see fcntl(2)).</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>SETFCAP</td>
|
||
<td>Set file capabilities.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>WAKE_ALARM</td>
|
||
<td>Trigger something that will wake up the system.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>BLOCK_SUSPEND</td>
|
||
<td>Employ features that can block system suspend.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<p>Further reference information is available on the <a href="http://linux.die.net/man/7/capabilities">capabilities(7) - Linux man page</a></p>
|
||
|
||
<p>Both flags support the value <code>all</code>, so if the
|
||
operator wants to have all capabilities but <code>MKNOD</code> they could use:</p>
|
||
|
||
<pre><code>$ docker run --cap-add=ALL --cap-drop=MKNOD ...
|
||
</code></pre>
|
||
|
||
<p>For interacting with the network stack, instead of using <code>--privileged</code> they
|
||
should use <code>--cap-add=NET_ADMIN</code> to modify the network interfaces.</p>
|
||
|
||
<pre><code>$ docker run -t -i --rm ubuntu:14.04 ip link add dummy0 type dummy
|
||
RTNETLINK answers: Operation not permitted
|
||
$ docker run -t -i --rm --cap-add=NET_ADMIN ubuntu:14.04 ip link add dummy0 type dummy
|
||
</code></pre>
|
||
|
||
<p>To mount a FUSE based filesystem, you need to combine both <code>--cap-add</code> and
|
||
<code>--device</code>:</p>
|
||
|
||
<pre><code>$ docker run --rm -it --cap-add SYS_ADMIN sshfs sshfs sven@10.10.10.20:/home/sven /mnt
|
||
fuse: failed to open /dev/fuse: Operation not permitted
|
||
$ docker run --rm -it --device /dev/fuse sshfs sshfs sven@10.10.10.20:/home/sven /mnt
|
||
fusermount: mount failed: Operation not permitted
|
||
$ docker run --rm -it --cap-add SYS_ADMIN --device /dev/fuse sshfs
|
||
# sshfs sven@10.10.10.20:/home/sven /mnt
|
||
The authenticity of host '10.10.10.20 (10.10.10.20)' can't be established.
|
||
ECDSA key fingerprint is 25:34:85:75:25:b0:17:46:05:19:04:93:b5:dd:5f:c6.
|
||
Are you sure you want to continue connecting (yes/no)? yes
|
||
sven@10.10.10.20's password:
|
||
root@30aa0cfaf1b5:/# ls -la /mnt/src/docker
|
||
total 1516
|
||
drwxrwxr-x 1 1000 1000 4096 Dec 4 06:08 .
|
||
drwxrwxr-x 1 1000 1000 4096 Dec 4 11:46 ..
|
||
-rw-rw-r-- 1 1000 1000 16 Oct 8 00:09 .dockerignore
|
||
-rwxrwxr-x 1 1000 1000 464 Oct 8 00:09 .drone.yml
|
||
drwxrwxr-x 1 1000 1000 4096 Dec 4 06:11 .git
|
||
-rw-rw-r-- 1 1000 1000 461 Dec 4 06:08 .gitignore
|
||
....
|
||
</code></pre>
|
||
|
||
<p>If the Docker daemon was started using the <code>lxc</code> exec-driver
|
||
(<code>docker -d --exec-driver=lxc</code>) then the operator can also specify LXC options
|
||
using one or more <code>--lxc-conf</code> parameters. These can be new parameters or
|
||
override existing parameters from the <a href="https://github.com/docker/docker/blob/master/daemon/execdriver/lxc/lxc_template.go">lxc-template.go</a>.
|
||
Note that in the future, a given host&rsquo;s docker daemon may not use LXC, so this
|
||
is an implementation-specific configuration meant for operators already
|
||
familiar with using LXC directly.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong>
|
||
If you use <code>--lxc-conf</code> to modify a container&rsquo;s configuration which is also
|
||
managed by the Docker daemon, then the Docker daemon will not know about this
|
||
modification, and you will need to manage any conflicts yourself. For example,
|
||
you can use <code>--lxc-conf</code> to set a container&rsquo;s IP address, but this will not be
|
||
reflected in the <code>/etc/hosts</code> file.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="logging-drivers-log-driver">Logging drivers (&ndash;log-driver)</h2>
|
||
|
||
<p>You can specify a different logging driver for the container than for the daemon.</p>
|
||
|
||
<h4 id="logging-driver-none">Logging driver: none</h4>
|
||
|
||
<p>Disables any logging for the container. <code>docker logs</code> won&rsquo;t be available with
|
||
this driver.</p>
|
||
|
||
<h4 id="logging-driver-json-file">Logging driver: json-file</h4>
|
||
|
||
<p>Default logging driver for Docker. Writes JSON messages to file. <code>docker logs</code>
|
||
command is available only for this logging driver</p>
|
||
|
||
<p>The following logging options are supported for this logging driver: [none]</p>
|
||
|
||
<h4 id="logging-driver-syslog">Logging driver: syslog</h4>
|
||
|
||
<p>Syslog logging driver for Docker. Writes log messages to syslog. <code>docker logs</code>
|
||
command is not available for this logging driver</p>
|
||
|
||
<p>The following logging options are supported for this logging driver:</p>
|
||
|
||
<pre><code>--log-opt address=[tcp|udp]://host:port
|
||
--log-opt address=unix://path
|
||
</code></pre>
|
||
|
||
<p><code>address</code> specifies the remote syslog server address where the driver connects to.
|
||
If not specified it defaults to the local unix socket of the running system.
|
||
If transport is either <code>tcp</code> or <code>udp</code> and <code>port</code> is not specified it defaults to <code>514</code>
|
||
The following example shows how to have the <code>syslog</code> driver connect to a <code>syslog</code>
|
||
remote server at <code>192.168.0.42</code> on port <code>123</code></p>
|
||
|
||
<pre><code>$ docker run --log-driver=syslog --log-opt address=tcp://192.168.0.42:123
|
||
</code></pre>
|
||
|
||
<h4 id="logging-driver-journald">Logging driver: journald</h4>
|
||
|
||
<p>Journald logging driver for Docker. Writes log messages to journald; the container id will be stored in the journal&rsquo;s <code>CONTAINER_ID</code> field. <code>docker logs</code> command is not available for this logging driver. For detailed information on working with this logging driver, see <a href="reference/logging/journald">the journald logging driver</a> reference documentation.</p>
|
||
|
||
<p>The following logging options are supported for this logging driver: [none]</p>
|
||
|
||
<h2 id="overriding-dockerfile-image-defaults">Overriding Dockerfile image defaults</h2>
|
||
|
||
<p>When a developer builds an image from a <a href="http://localhost/docker/reference/builder"><em>Dockerfile</em></a>
|
||
or when she commits it, the developer can set a number of default parameters
|
||
that take effect when the image starts up as a container.</p>
|
||
|
||
<p>Four of the Dockerfile commands cannot be overridden at runtime: <code>FROM</code>,
|
||
<code>MAINTAINER</code>, <code>RUN</code>, and <code>ADD</code>. Everything else has a corresponding override
|
||
in <code>docker run</code>. We&rsquo;ll go through what the developer might have set in each
|
||
Dockerfile instruction and how the operator can override that setting.</p>
|
||
|
||
<ul>
|
||
<li><a href="#cmd-default-command-or-options">CMD (Default Command or Options)</a></li>
|
||
<li><a href="#entrypoint-default-command-to-execute-at-runtime">ENTRYPOINT (Default Command to Execute at Runtime)</a></li>
|
||
<li><a href="#expose-incoming-ports">EXPOSE (Incoming Ports)</a></li>
|
||
<li><a href="#env-environment-variables">ENV (Environment Variables)</a></li>
|
||
<li><a href="#volume-shared-filesystems">VOLUME (Shared Filesystems)</a></li>
|
||
<li><a href="#user">USER</a></li>
|
||
<li><a href="#workdir">WORKDIR</a></li>
|
||
</ul>
|
||
|
||
<h2 id="cmd-default-command-or-options">CMD (default command or options)</h2>
|
||
|
||
<p>Recall the optional <code>COMMAND</code> in the Docker
|
||
commandline:</p>
|
||
|
||
<pre><code>$ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
|
||
</code></pre>
|
||
|
||
<p>This command is optional because the person who created the <code>IMAGE</code> may
|
||
have already provided a default <code>COMMAND</code> using the Dockerfile <code>CMD</code>
|
||
instruction. As the operator (the person running a container from the
|
||
image), you can override that <code>CMD</code> instruction just by specifying a new
|
||
<code>COMMAND</code>.</p>
|
||
|
||
<p>If the image also specifies an <code>ENTRYPOINT</code> then the <code>CMD</code> or <code>COMMAND</code>
|
||
get appended as arguments to the <code>ENTRYPOINT</code>.</p>
|
||
|
||
<h2 id="entrypoint-default-command-to-execute-at-runtime">ENTRYPOINT (default command to execute at runtime)</h2>
|
||
|
||
<pre><code>--entrypoint=&quot;&quot;: Overwrite the default entrypoint set by the image
|
||
</code></pre>
|
||
|
||
<p>The <code>ENTRYPOINT</code> of an image is similar to a <code>COMMAND</code> because it
|
||
specifies what executable to run when the container starts, but it is
|
||
(purposely) more difficult to override. The <code>ENTRYPOINT</code> gives a
|
||
container its default nature or behavior, so that when you set an
|
||
<code>ENTRYPOINT</code> you can run the container <em>as if it were that binary</em>,
|
||
complete with default options, and you can pass in more options via the
|
||
<code>COMMAND</code>. But, sometimes an operator may want to run something else
|
||
inside the container, so you can override the default <code>ENTRYPOINT</code> at
|
||
runtime by using a string to specify the new <code>ENTRYPOINT</code>. Here is an
|
||
example of how to run a shell in a container that has been set up to
|
||
automatically run something else (like <code>/usr/bin/redis-server</code>):</p>
|
||
|
||
<pre><code>$ docker run -i -t --entrypoint /bin/bash example/redis
|
||
</code></pre>
|
||
|
||
<p>or two examples of how to pass more parameters to that ENTRYPOINT:</p>
|
||
|
||
<pre><code>$ docker run -i -t --entrypoint /bin/bash example/redis -c ls -l
|
||
$ docker run -i -t --entrypoint /usr/bin/redis-cli example/redis --help
|
||
</code></pre>
|
||
|
||
<h2 id="expose-incoming-ports">EXPOSE (incoming ports)</h2>
|
||
|
||
<p>The Dockerfile doesn&rsquo;t give much control over networking, only providing
|
||
the <code>EXPOSE</code> instruction to give a hint to the operator about what
|
||
incoming ports might provide services. The following options work with
|
||
or override the Dockerfile&rsquo;s exposed defaults:</p>
|
||
|
||
<pre><code>--expose=[]: Expose a port or a range of ports from the container
|
||
without publishing it to your host
|
||
-P=false : Publish all exposed ports to the host interfaces
|
||
-p=[] : Publish a container᾿s port or a range of ports to the host
|
||
format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort
|
||
Both hostPort and containerPort can be specified as a range of ports.
|
||
When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range. (e.g., `-p 1234-1236:1234-1236/tcp`)
|
||
(use 'docker port' to see the actual mapping)
|
||
--link=&quot;&quot; : Add link to another container (&lt;name or id&gt;:alias or &lt;name or id&gt;)
|
||
</code></pre>
|
||
|
||
<p>As mentioned previously, <code>EXPOSE</code> (and <code>--expose</code>) makes ports available
|
||
<strong>in</strong> a container for incoming connections. The port number on the
|
||
inside of the container (where the service listens) does not need to be
|
||
the same number as the port exposed on the outside of the container
|
||
(where clients connect), so inside the container you might have an HTTP
|
||
service listening on port 80 (and so you <code>EXPOSE 80</code> in the Dockerfile),
|
||
but outside the container the port might be 42800.</p>
|
||
|
||
<p>To help a new client container reach the server container&rsquo;s internal
|
||
port operator <code>--expose</code>&rsquo;d by the operator or <code>EXPOSE</code>&rsquo;d by the
|
||
developer, the operator has three choices: start the server container
|
||
with <code>-P</code> or <code>-p,</code> or start the client container with <code>--link</code>.</p>
|
||
|
||
<p>If the operator uses <code>-P</code> or <code>-p</code> then Docker will make the exposed port
|
||
accessible on the host and the ports will be available to any client that can
|
||
reach the host. When using <code>-P</code>, Docker will bind the exposed port to a random
|
||
port on the host within an <em>ephemeral port range</em> defined by
|
||
<code>/proc/sys/net/ipv4/ip_local_port_range</code>. To find the mapping between the host
|
||
ports and the exposed ports, use <code>docker port</code>.</p>
|
||
|
||
<p>If the operator uses <code>--link</code> when starting the new client container,
|
||
then the client container can access the exposed port via a private
|
||
networking interface. Docker will set some environment variables in the
|
||
client container to help indicate which interface and port to use.</p>
|
||
|
||
<h2 id="env-environment-variables">ENV (environment variables)</h2>
|
||
|
||
<p>When a new container is created, Docker will set the following environment
|
||
variables automatically:</p>
|
||
|
||
<table>
|
||
<tr>
|
||
<th>Variable</th>
|
||
<th>Value</th>
|
||
</tr>
|
||
<tr>
|
||
<td><code>HOME</code></td>
|
||
<td>
|
||
Set based on the value of <code>USER</code>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>HOSTNAME</code></td>
|
||
<td>
|
||
The hostname associated with the container
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td><code>PATH</code></td>
|
||
<td>
|
||
Includes popular directories, such as :<br>
|
||
<code>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</code>
|
||
</td>
|
||
<tr>
|
||
<td><code>TERM</code></td>
|
||
<td><code>xterm</code> if the container is allocated a psuedo-TTY</td>
|
||
</tr>
|
||
</table>
|
||
|
||
<p>The container may also include environment variables defined
|
||
as a result of the container being linked with another container. See
|
||
the <a href="http://localhost/userguide/dockerlinks/#container-linking"><em>Container Links</em></a>
|
||
section for more details.</p>
|
||
|
||
<p>Additionally, the operator can <strong>set any environment variable</strong> in the
|
||
container by using one or more <code>-e</code> flags, even overriding those mentioned
|
||
above, or already defined by the developer with a Dockerfile <code>ENV</code>:</p>
|
||
|
||
<pre><code>$ docker run -e &quot;deep=purple&quot; --rm ubuntu /bin/bash -c export
|
||
declare -x HOME=&quot;/&quot;
|
||
declare -x HOSTNAME=&quot;85bc26a0e200&quot;
|
||
declare -x OLDPWD
|
||
declare -x PATH=&quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;
|
||
declare -x PWD=&quot;/&quot;
|
||
declare -x SHLVL=&quot;1&quot;
|
||
declare -x container=&quot;lxc&quot;
|
||
declare -x deep=&quot;purple&quot;
|
||
</code></pre>
|
||
|
||
<p>Similarly the operator can set the <strong>hostname</strong> with <code>-h</code>.</p>
|
||
|
||
<p><code>--link &lt;name or id&gt;:alias</code> also sets environment variables, using the <em>alias</em> string to
|
||
define environment variables within the container that give the IP and PORT
|
||
information for connecting to the service container. Let&rsquo;s imagine we have a
|
||
container running Redis:</p>
|
||
|
||
<pre><code># Start the service container, named redis-name
|
||
$ docker run -d --name redis-name dockerfiles/redis
|
||
4241164edf6f5aca5b0e9e4c9eccd899b0b8080c64c0cd26efe02166c73208f3
|
||
|
||
# The redis-name container exposed port 6379
|
||
$ docker ps
|
||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||
4241164edf6f $ dockerfiles/redis:latest /redis-stable/src/re 5 seconds ago Up 4 seconds 6379/tcp redis-name
|
||
|
||
# Note that there are no public ports exposed since we didn᾿t use -p or -P
|
||
$ docker port 4241164edf6f 6379
|
||
2014/01/25 00:55:38 Error: No public port '6379' published for 4241164edf6f
|
||
</code></pre>
|
||
|
||
<p>Yet we can get information about the Redis container&rsquo;s exposed ports
|
||
with <code>--link</code>. Choose an alias that will form a
|
||
valid environment variable!</p>
|
||
|
||
<pre><code>$ docker run --rm --link redis-name:redis_alias --entrypoint /bin/bash dockerfiles/redis -c export
|
||
declare -x HOME=&quot;/&quot;
|
||
declare -x HOSTNAME=&quot;acda7f7b1cdc&quot;
|
||
declare -x OLDPWD
|
||
declare -x PATH=&quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;
|
||
declare -x PWD=&quot;/&quot;
|
||
declare -x REDIS_ALIAS_NAME=&quot;/distracted_wright/redis&quot;
|
||
declare -x REDIS_ALIAS_PORT=&quot;tcp://172.17.0.32:6379&quot;
|
||
declare -x REDIS_ALIAS_PORT_6379_TCP=&quot;tcp://172.17.0.32:6379&quot;
|
||
declare -x REDIS_ALIAS_PORT_6379_TCP_ADDR=&quot;172.17.0.32&quot;
|
||
declare -x REDIS_ALIAS_PORT_6379_TCP_PORT=&quot;6379&quot;
|
||
declare -x REDIS_ALIAS_PORT_6379_TCP_PROTO=&quot;tcp&quot;
|
||
declare -x SHLVL=&quot;1&quot;
|
||
declare -x container=&quot;lxc&quot;
|
||
</code></pre>
|
||
|
||
<p>And we can use that information to connect from another container as a client:</p>
|
||
|
||
<pre><code>$ docker run -i -t --rm --link redis-name:redis_alias --entrypoint /bin/bash dockerfiles/redis -c '/redis-stable/src/redis-cli -h $REDIS_ALIAS_PORT_6379_TCP_ADDR -p $REDIS_ALIAS_PORT_6379_TCP_PORT'
|
||
172.17.0.32:6379&gt;
|
||
</code></pre>
|
||
|
||
<p>Docker will also map the private IP address to the alias of a linked
|
||
container by inserting an entry into <code>/etc/hosts</code>. You can use this
|
||
mechanism to communicate with a linked container by its alias:</p>
|
||
|
||
<pre><code>$ docker run -d --name servicename busybox sleep 30
|
||
$ docker run -i -t --link servicename:servicealias busybox ping -c 1 servicealias
|
||
</code></pre>
|
||
|
||
<p>If you restart the source container (<code>servicename</code> in this case), the recipient
|
||
container&rsquo;s <code>/etc/hosts</code> entry will be automatically updated.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
Unlike host entries in the <code>/etc/hosts</code> file, IP addresses stored in the
|
||
environment variables are not automatically updated if the source container is
|
||
restarted. We recommend using the host entries in <code>/etc/hosts</code> to resolve the
|
||
IP address of linked containers.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="volume-shared-filesystems">VOLUME (shared filesystems)</h2>
|
||
|
||
<pre><code>-v=[]: Create a bind mount with: [host-dir:]container-dir[:rw|ro].
|
||
If 'host-dir' is missing, then docker creates a new volume.
|
||
If neither 'rw' or 'ro' is specified then the volume is mounted
|
||
in read-write mode.
|
||
--volumes-from=&quot;&quot;: Mount all volumes from the given container(s)
|
||
</code></pre>
|
||
|
||
<p>The volumes commands are complex enough to have their own documentation
|
||
in section <a href="http://localhost/userguide/dockervolumes"><em>Managing data in
|
||
containers</em></a>. A developer can define
|
||
one or more <code>VOLUME</code>&rsquo;s associated with an image, but only the operator
|
||
can give access from one container to another (or from a container to a
|
||
volume mounted on the host).</p>
|
||
|
||
<h2 id="user">USER</h2>
|
||
|
||
<p>The default user within a container is <code>root</code> (id = 0), but if the
|
||
developer created additional users, those are accessible too. The
|
||
developer can set a default user to run the first process with the
|
||
Dockerfile <code>USER</code> instruction, but the operator can override it:</p>
|
||
|
||
<pre><code>-u=&quot;&quot;: Username or UID
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong> if you pass numeric uid, it must be in range 0-2147483647.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="workdir">WORKDIR</h2>
|
||
|
||
<p>The default working directory for running binaries within a container is the
|
||
root directory (<code>/</code>), but the developer can set a different default with the
|
||
Dockerfile <code>WORKDIR</code> command. The operator can override this with:</p>
|
||
|
||
<pre><code>-w=&quot;&quot;: Working directory inside the container
|
||
</code></pre>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Dockerfile reference</title>
|
||
<link>http://localhost/reference/builder/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/builder/</guid>
|
||
<description>
|
||
|
||
<h1 id="dockerfile-reference">Dockerfile reference</h1>
|
||
|
||
<p><strong>Docker can build images automatically</strong> by reading the instructions
|
||
from a <code>Dockerfile</code>. A <code>Dockerfile</code> is a text document that contains all
|
||
the commands you would normally execute manually in order to build a
|
||
Docker image. By calling <code>docker build</code> from your terminal, you can have
|
||
Docker build your image step by step, executing the instructions
|
||
successively.</p>
|
||
|
||
<p>This page discusses the specifics of all the instructions you can use in your
|
||
<code>Dockerfile</code>. To further help you write a clear, readable, maintainable
|
||
<code>Dockerfile</code>, we&rsquo;ve also written a <a href="http://localhost/articles/dockerfile_best-practices"><code>Dockerfile</code> Best Practices
|
||
guide</a>. Lastly, you can test your
|
||
Dockerfile knowledge with the <a href="http://localhost/userguide/level1">Dockerfile tutorial</a>.</p>
|
||
|
||
<h2 id="usage">Usage</h2>
|
||
|
||
<p>To <a href="http://localhost/docker/reference/commandline/cli/#build"><em>build</em></a> an image from a source repository,
|
||
create a description file called <code>Dockerfile</code> at the root of your repository.
|
||
This file will describe the steps to assemble the image.</p>
|
||
|
||
<p>Then call <code>docker build</code> with the path of your source repository as the argument
|
||
(for example, <code>.</code>):</p>
|
||
|
||
<pre><code>$ docker build .
|
||
</code></pre>
|
||
|
||
<p>The path to the source repository defines where to find the <em>context</em> of
|
||
the build. The build is run by the Docker daemon, not by the CLI, so the
|
||
whole context must be transferred to the daemon. The Docker CLI reports
|
||
&ldquo;Sending build context to Docker daemon&rdquo; when the context is sent to the daemon.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Warning</strong>
|
||
Avoid using your root directory, <code>/</code>, as the root of the source repository. The
|
||
<code>docker build</code> command will use whatever directory contains the Dockerfile as the build
|
||
context (including all of its subdirectories). The build context will be sent to the
|
||
Docker daemon before building the image, which means if you use <code>/</code> as the source
|
||
repository, the entire contents of your hard drive will get sent to the daemon (and
|
||
thus to the machine running the daemon). You probably don&rsquo;t want that.</p>
|
||
</blockquote>
|
||
|
||
<p>In most cases, it&rsquo;s best to put each Dockerfile in an empty directory. Then,
|
||
only add the files needed for building the Dockerfile to the directory. To
|
||
increase the build&rsquo;s performance, you can exclude files and directories by
|
||
adding a <code>.dockerignore</code> file to the directory. For information about how to
|
||
<a href="#dockerignore-file">create a <code>.dockerignore</code> file</a> on this page.</p>
|
||
|
||
<p>You can specify a repository and tag at which to save the new image if
|
||
the build succeeds:</p>
|
||
|
||
<pre><code>$ docker build -t shykes/myapp .
|
||
</code></pre>
|
||
|
||
<p>The Docker daemon will run your steps one-by-one, committing the result
|
||
to a new image if necessary, before finally outputting the ID of your
|
||
new image. The Docker daemon will automatically clean up the context you
|
||
sent.</p>
|
||
|
||
<p>Note that each instruction is run independently, and causes a new image
|
||
to be created - so <code>RUN cd /tmp</code> will not have any effect on the next
|
||
instructions.</p>
|
||
|
||
<p>Whenever possible, Docker will re-use the intermediate images,
|
||
accelerating <code>docker build</code> significantly (indicated by <code>Using cache</code> -
|
||
see the <a href="http://localhost/articles/dockerfile_best-practices/#build-cache"><code>Dockerfile</code> Best Practices
|
||
guide</a> for more information):</p>
|
||
|
||
<pre><code>$ docker build -t SvenDowideit/ambassador .
|
||
Uploading context 10.24 kB
|
||
Uploading context
|
||
Step 1 : FROM docker-ut
|
||
---&gt; cbba202fe96b
|
||
Step 2 : MAINTAINER SvenDowideit@home.org.au
|
||
---&gt; Using cache
|
||
---&gt; 51182097be13
|
||
Step 3 : CMD env | grep _TCP= | sed 's/.*_PORT_\([0-9]*\)_TCP=tcp:\/\/\(.*\):\(.*\)/socat TCP4-LISTEN:\1,fork,reuseaddr TCP4:\2:\3 \&amp;/' | sh &amp;&amp; top
|
||
---&gt; Using cache
|
||
---&gt; 1a5ffc17324d
|
||
Successfully built 1a5ffc17324d
|
||
</code></pre>
|
||
|
||
<p>When you&rsquo;re done with your build, you&rsquo;re ready to look into <a href="http://localhost/userguide/dockerrepos/#contributing-to-docker-hub"><em>Pushing a
|
||
repository to its registry</em></a>.</p>
|
||
|
||
<h2 id="format">Format</h2>
|
||
|
||
<p>Here is the format of the <code>Dockerfile</code>:</p>
|
||
|
||
<pre><code># Comment
|
||
INSTRUCTION arguments
|
||
</code></pre>
|
||
|
||
<p>The Instruction is not case-sensitive, however convention is for them to
|
||
be UPPERCASE in order to distinguish them from arguments more easily.</p>
|
||
|
||
<p>Docker runs the instructions in a <code>Dockerfile</code> in order. <strong>The
|
||
first instruction must be `FROM`</strong> in order to specify the <a href="http://localhost/docker/reference/glossary/#base-image"><em>Base
|
||
Image</em></a> from which you are building.</p>
|
||
|
||
<p>Docker will treat lines that <em>begin</em> with <code>#</code> as a
|
||
comment. A <code>#</code> marker anywhere else in the line will
|
||
be treated as an argument. This allows statements like:</p>
|
||
|
||
<pre><code># Comment
|
||
RUN echo 'we are running some # of cool things'
|
||
</code></pre>
|
||
|
||
<p>Here is the set of instructions you can use in a <code>Dockerfile</code> for building
|
||
images.</p>
|
||
|
||
<h3 id="environment-replacement">Environment replacement</h3>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: prior to 1.3, <code>Dockerfile</code> environment variables were handled
|
||
similarly, in that they would be replaced as described below. However, there
|
||
was no formal definition on as to which instructions handled environment
|
||
replacement at the time. After 1.3 this behavior will be preserved and
|
||
canonical.</p>
|
||
</blockquote>
|
||
|
||
<p>Environment variables (declared with <a href="#env">the <code>ENV</code> statement</a>) can also be
|
||
used in certain instructions as variables to be interpreted by the
|
||
<code>Dockerfile</code>. Escapes are also handled for including variable-like syntax
|
||
into a statement literally.</p>
|
||
|
||
<p>Environment variables are notated in the <code>Dockerfile</code> either with
|
||
<code>$variable_name</code> or <code>${variable_name}</code>. They are treated equivalently and the
|
||
brace syntax is typically used to address issues with variable names with no
|
||
whitespace, like <code>${foo}_bar</code>.</p>
|
||
|
||
<p>The <code>${variable_name}</code> syntax also supports a few of the standard <code>bash</code>
|
||
modifiers as specified below:</p>
|
||
|
||
<ul>
|
||
<li><code>${variable:-word}</code> indicates that if <code>variable</code> is set then the result
|
||
will be that value. If <code>variable</code> is not set then <code>word</code> will be the result.</li>
|
||
<li><code>${variable:+word}</code> indicates that if <code>variable</code> is set then <code>word</code> will be
|
||
the result, otherwise the result is the empty string.</li>
|
||
</ul>
|
||
|
||
<p>In all cases, <code>word</code> can be any string, including additional environment
|
||
variables.</p>
|
||
|
||
<p>Escaping is possible by adding a <code>\</code> before the variable: <code>\$foo</code> or <code>\${foo}</code>,
|
||
for example, will translate to <code>$foo</code> and <code>${foo}</code> literals respectively.</p>
|
||
|
||
<p>Example (parsed representation is displayed after the <code>#</code>):</p>
|
||
|
||
<pre><code>FROM busybox
|
||
ENV foo /bar
|
||
WORKDIR ${foo} # WORKDIR /bar
|
||
ADD . $foo # ADD . /bar
|
||
COPY \$foo /quux # COPY $foo /quux
|
||
</code></pre>
|
||
|
||
<p>The instructions that handle environment variables in the <code>Dockerfile</code> are:</p>
|
||
|
||
<ul>
|
||
<li><code>ENV</code></li>
|
||
<li><code>ADD</code></li>
|
||
<li><code>COPY</code></li>
|
||
<li><code>WORKDIR</code></li>
|
||
<li><code>EXPOSE</code></li>
|
||
<li><code>VOLUME</code></li>
|
||
<li><code>USER</code></li>
|
||
</ul>
|
||
|
||
<p><code>ONBUILD</code> instructions are <strong>NOT</strong> supported for environment replacement, even
|
||
the instructions above.</p>
|
||
|
||
<p>Environment variable substitution will use the same value for each variable
|
||
throughout the entire command. In other words, in this example:</p>
|
||
|
||
<pre><code>ENV abc=hello
|
||
ENV abc=bye def=$abc
|
||
ENV ghi=$abc
|
||
</code></pre>
|
||
|
||
<p>will result in <code>def</code> having a value of <code>hello</code>, not <code>bye</code>. However,
|
||
<code>ghi</code> will have a value of <code>bye</code> because it is not part of the same command
|
||
that set <code>abc</code> to <code>bye</code>.</p>
|
||
|
||
<h3 id="dockerignore-file">.dockerignore file</h3>
|
||
|
||
<p>If a file named <code>.dockerignore</code> exists in the root of <code>PATH</code>, then Docker
|
||
interprets it as a newline-separated list of exclusion patterns. Docker excludes
|
||
files or directories relative to <code>PATH</code> that match these exclusion patterns. If
|
||
there are any <code>.dockerignore</code> files in <code>PATH</code> subdirectories, Docker treats
|
||
them as normal files.</p>
|
||
|
||
<p>Filepaths in <code>.dockerignore</code> are absolute with the current directory as the
|
||
root. Wildcards are allowed but the search is not recursive. Globbing (file name
|
||
expansion) is done using Go&rsquo;s
|
||
<a href="http://golang.org/pkg/path/filepath#Match">filepath.Match</a> rules.</p>
|
||
|
||
<p>You can specify exceptions to exclusion rules. To do this, simply prefix a
|
||
pattern with an <code>!</code> (exclamation mark) in the same way you would in a
|
||
<code>.gitignore</code> file. Currently there is no support for regular expressions.
|
||
Formats like <code>[^temp*]</code> are ignored.</p>
|
||
|
||
<p>The following is an example <code>.dockerignore</code> file:</p>
|
||
|
||
<pre><code> */temp*
|
||
*/*/temp*
|
||
temp?
|
||
*.md
|
||
!LICENCSE.md
|
||
</code></pre>
|
||
|
||
<p>This file causes the following build behavior:</p>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>Rule</th>
|
||
<th>Behavior</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody>
|
||
<tr>
|
||
<td><code>*/temp*</code></td>
|
||
<td>Exclude all files with names starting with<code>temp</code> in any subdirectory below the root directory. For example, a file named<code>/somedir/temporary.txt</code> is ignored.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>*/*/temp*</code></td>
|
||
<td>Exclude files starting with name <code>temp</code> from any subdirectory that is two levels below the root directory. For example, the file <code>/somedir/subdir/temporary.txt</code> is ignored.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>temp?</code></td>
|
||
<td>Exclude the files that match the pattern in the root directory. For example, the files <code>tempa</code>, <code>tempb</code> in the root directory are ignored.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>*.md</code></td>
|
||
<td>Exclude all markdown files in the root directory.</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td><code>!LICENSE.md</code></td>
|
||
<td>Exception to the Markdown files exclusion is this file, <code>LICENSE.md</code>, Include this file in the build.</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<p>The placement of <code>!</code> exception rules influences the matching algorithm; the
|
||
last line of the <code>.dockerignore</code> that matches a particular file determines
|
||
whether it is included or excluded. In the above example, the <code>LICENSE.md</code> file
|
||
matches both the <code>*.md</code> and <code>!LICENSE.md</code> rule. If you reverse the lines in the
|
||
example:</p>
|
||
|
||
<pre><code> */temp*
|
||
*/*/temp*
|
||
temp?
|
||
!LICENCSE.md
|
||
*.md
|
||
</code></pre>
|
||
|
||
<p>The build would exclude <code>LICENSE.md</code> because the last <code>*.md</code> rule adds all
|
||
Markdown files in the root directory back onto the ignore list. The
|
||
<code>!LICENSE.md</code> rule has no effect because the subsequent <code>*.md</code> rule overrides
|
||
it.</p>
|
||
|
||
<p>You can even use the <code>.dockerignore</code> file to ignore the <code>Dockerfile</code> and
|
||
<code>.dockerignore</code> files. This is useful if you are copying files from the root of
|
||
the build context into your new container but do not want to include the
|
||
<code>Dockerfile</code> or <code>.dockerignore</code> files (e.g. <code>ADD . /someDir/</code>).</p>
|
||
|
||
<h2 id="from">FROM</h2>
|
||
|
||
<pre><code>FROM &lt;image&gt;
|
||
</code></pre>
|
||
|
||
<p>Or</p>
|
||
|
||
<pre><code>FROM &lt;image&gt;:&lt;tag&gt;
|
||
</code></pre>
|
||
|
||
<p>Or</p>
|
||
|
||
<pre><code>FROM &lt;image&gt;@&lt;digest&gt;
|
||
</code></pre>
|
||
|
||
<p>The <code>FROM</code> instruction sets the <a href="http://localhost/docker/reference/glossary/#base-image"><em>Base Image</em></a>
|
||
for subsequent instructions. As such, a valid <code>Dockerfile</code> must have <code>FROM</code> as
|
||
its first instruction. The image can be any valid image – it is especially easy
|
||
to start by <strong>pulling an image</strong> from the <a href="http://localhost/userguide/dockerrepos"><em>Public Repositories</em></a>.</p>
|
||
|
||
<p><code>FROM</code> must be the first non-comment instruction in the <code>Dockerfile</code>.</p>
|
||
|
||
<p><code>FROM</code> can appear multiple times within a single <code>Dockerfile</code> in order to create
|
||
multiple images. Simply make a note of the last image ID output by the commit
|
||
before each new <code>FROM</code> command.</p>
|
||
|
||
<p>The <code>tag</code> or <code>digest</code> values are optional. If you omit either of them, the builder
|
||
assumes a <code>latest</code> by default. The builder returns an error if it cannot match
|
||
the <code>tag</code> value.</p>
|
||
|
||
<h2 id="maintainer">MAINTAINER</h2>
|
||
|
||
<pre><code>MAINTAINER &lt;name&gt;
|
||
</code></pre>
|
||
|
||
<p>The <code>MAINTAINER</code> instruction allows you to set the <em>Author</em> field of the
|
||
generated images.</p>
|
||
|
||
<h2 id="run">RUN</h2>
|
||
|
||
<p>RUN has 2 forms:</p>
|
||
|
||
<ul>
|
||
<li><code>RUN &lt;command&gt;</code> (the command is run in a shell - <code>/bin/sh -c</code> - <em>shell</em> form)</li>
|
||
<li><code>RUN [&quot;executable&quot;, &quot;param1&quot;, &quot;param2&quot;]</code> (<em>exec</em> form)</li>
|
||
</ul>
|
||
|
||
<p>The <code>RUN</code> instruction will execute any commands in a new layer on top of the
|
||
current image and commit the results. The resulting committed image will be
|
||
used for the next step in the <code>Dockerfile</code>.</p>
|
||
|
||
<p>Layering <code>RUN</code> instructions and generating commits conforms to the core
|
||
concepts of Docker where commits are cheap and containers can be created from
|
||
any point in an image&rsquo;s history, much like source control.</p>
|
||
|
||
<p>The <em>exec</em> form makes it possible to avoid shell string munging, and to <code>RUN</code>
|
||
commands using a base image that does not contain <code>/bin/sh</code>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
To use a different shell, other than &lsquo;/bin/sh&rsquo;, use the <em>exec</em> form
|
||
passing in the desired shell. For example,
|
||
<code>RUN [&quot;/bin/bash&quot;, &quot;-c&quot;, &quot;echo hello&quot;]</code></p>
|
||
|
||
<p><strong>Note</strong>:
|
||
The <em>exec</em> form is parsed as a JSON array, which means that
|
||
you must use double-quotes (&ldquo;) around words not single-quotes (&lsquo;).</p>
|
||
|
||
<p><strong>Note</strong>:
|
||
Unlike the <em>shell</em> form, the <em>exec</em> form does not invoke a command shell.
|
||
This means that normal shell processing does not happen. For example,
|
||
<code>RUN [ &quot;echo&quot;, &quot;$HOME&quot; ]</code> will not do variable substitution on <code>$HOME</code>.
|
||
If you want shell processing then either use the <em>shell</em> form or execute
|
||
a shell directly, for example: <code>RUN [ &quot;sh&quot;, &quot;-c&quot;, &quot;echo&quot;, &quot;$HOME&quot; ]</code>.</p>
|
||
</blockquote>
|
||
|
||
<p>The cache for <code>RUN</code> instructions isn&rsquo;t invalidated automatically during
|
||
the next build. The cache for an instruction like
|
||
<code>RUN apt-get dist-upgrade -y</code> will be reused during the next build. The
|
||
cache for <code>RUN</code> instructions can be invalidated by using the <code>--no-cache</code>
|
||
flag, for example <code>docker build --no-cache</code>.</p>
|
||
|
||
<p>See the <a href="http://localhost/articles/dockerfile_best-practices/#build-cache"><code>Dockerfile</code> Best Practices
|
||
guide</a> for more information.</p>
|
||
|
||
<p>The cache for <code>RUN</code> instructions can be invalidated by <code>ADD</code> instructions. See
|
||
<a href="#add">below</a> for details.</p>
|
||
|
||
<h3 id="known-issues-run">Known issues (RUN)</h3>
|
||
|
||
<ul>
|
||
<li><a href="https://github.com/docker/docker/issues/783">Issue 783</a> is about file
|
||
permissions problems that can occur when using the AUFS file system. You
|
||
might notice it during an attempt to <code>rm</code> a file, for example.</li>
|
||
</ul>
|
||
|
||
<p>For systems that have recent aufs version (i.e., <code>dirperm1</code> mount option can
|
||
be set), docker will attempt to fix the issue automatically by mounting
|
||
the layers with <code>dirperm1</code> option. More details on <code>dirperm1</code> option can be
|
||
found at <a href="http://aufs.sourceforge.net/aufs3/man.html"><code>aufs</code> man page</a></p>
|
||
|
||
<p>If your system doesn&rsquo;t have support for <code>dirperm1</code>, the issue describes a workaround.</p>
|
||
|
||
<h2 id="cmd">CMD</h2>
|
||
|
||
<p>The <code>CMD</code> instruction has three forms:</p>
|
||
|
||
<ul>
|
||
<li><code>CMD [&quot;executable&quot;,&quot;param1&quot;,&quot;param2&quot;]</code> (<em>exec</em> form, this is the preferred form)</li>
|
||
<li><code>CMD [&quot;param1&quot;,&quot;param2&quot;]</code> (as <em>default parameters to ENTRYPOINT</em>)</li>
|
||
<li><code>CMD command param1 param2</code> (<em>shell</em> form)</li>
|
||
</ul>
|
||
|
||
<p>There can only be one <code>CMD</code> instruction in a <code>Dockerfile</code>. If you list more than one <code>CMD</code>
|
||
then only the last <code>CMD</code> will take effect.</p>
|
||
|
||
<p><strong>The main purpose of a <code>CMD</code> is to provide defaults for an executing
|
||
container.</strong> These defaults can include an executable, or they can omit
|
||
the executable, in which case you must specify an <code>ENTRYPOINT</code>
|
||
instruction as well.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
If <code>CMD</code> is used to provide default arguments for the <code>ENTRYPOINT</code>
|
||
instruction, both the <code>CMD</code> and <code>ENTRYPOINT</code> instructions should be specified
|
||
with the JSON array format.</p>
|
||
|
||
<p><strong>Note</strong>:
|
||
The <em>exec</em> form is parsed as a JSON array, which means that
|
||
you must use double-quotes (&ldquo;) around words not single-quotes (&lsquo;).</p>
|
||
|
||
<p><strong>Note</strong>:
|
||
Unlike the <em>shell</em> form, the <em>exec</em> form does not invoke a command shell.
|
||
This means that normal shell processing does not happen. For example,
|
||
<code>CMD [ &quot;echo&quot;, &quot;$HOME&quot; ]</code> will not do variable substitution on <code>$HOME</code>.
|
||
If you want shell processing then either use the <em>shell</em> form or execute
|
||
a shell directly, for example: <code>CMD [ &quot;sh&quot;, &quot;-c&quot;, &quot;echo&quot;, &quot;$HOME&quot; ]</code>.</p>
|
||
</blockquote>
|
||
|
||
<p>When used in the shell or exec formats, the <code>CMD</code> instruction sets the command
|
||
to be executed when running the image.</p>
|
||
|
||
<p>If you use the <em>shell</em> form of the <code>CMD</code>, then the <code>&lt;command&gt;</code> will execute in
|
||
<code>/bin/sh -c</code>:</p>
|
||
|
||
<pre><code>FROM ubuntu
|
||
CMD echo &quot;This is a test.&quot; | wc -
|
||
</code></pre>
|
||
|
||
<p>If you want to <strong>run your</strong> <code>&lt;command&gt;</code> <strong>without a shell</strong> then you must
|
||
express the command as a JSON array and give the full path to the executable.
|
||
<strong>This array form is the preferred format of <code>CMD</code>.</strong> Any additional parameters
|
||
must be individually expressed as strings in the array:</p>
|
||
|
||
<pre><code>FROM ubuntu
|
||
CMD [&quot;/usr/bin/wc&quot;,&quot;--help&quot;]
|
||
</code></pre>
|
||
|
||
<p>If you would like your container to run the same executable every time, then
|
||
you should consider using <code>ENTRYPOINT</code> in combination with <code>CMD</code>. See
|
||
<a href="#entrypoint"><em>ENTRYPOINT</em></a>.</p>
|
||
|
||
<p>If the user specifies arguments to <code>docker run</code> then they will override the
|
||
default specified in <code>CMD</code>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
don&rsquo;t confuse <code>RUN</code> with <code>CMD</code>. <code>RUN</code> actually runs a command and commits
|
||
the result; <code>CMD</code> does not execute anything at build time, but specifies
|
||
the intended command for the image.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="label">LABEL</h2>
|
||
|
||
<pre><code>LABEL &lt;key&gt;=&lt;value&gt; &lt;key&gt;=&lt;value&gt; &lt;key&gt;=&lt;value&gt; ...
|
||
</code></pre>
|
||
|
||
<p>The <code>LABEL</code> instruction adds metadata to an image. A <code>LABEL</code> is a
|
||
key-value pair. To include spaces within a <code>LABEL</code> value, use quotes and
|
||
backslashes as you would in command-line parsing.</p>
|
||
|
||
<pre><code>LABEL &quot;com.example.vendor&quot;=&quot;ACME Incorporated&quot;
|
||
</code></pre>
|
||
|
||
<p>An image can have more than one label. To specify multiple labels, separate each
|
||
key-value pair with whitespace.</p>
|
||
|
||
<pre><code>LABEL com.example.label-with-value=&quot;foo&quot;
|
||
LABEL version=&quot;1.0&quot;
|
||
LABEL description=&quot;This text illustrates \
|
||
that label-values can span multiple lines.&quot;
|
||
</code></pre>
|
||
|
||
<p>Docker recommends combining labels in a single <code>LABEL</code> instruction where
|
||
possible. Each <code>LABEL</code> instruction produces a new layer which can result in an
|
||
inefficient image if you use many labels. This example results in four image
|
||
layers.</p>
|
||
|
||
<pre><code>LABEL multi.label1=&quot;value1&quot; multi.label2=&quot;value2&quot; other=&quot;value3&quot;
|
||
</code></pre>
|
||
|
||
<p>Labels are additive including <code>LABEL</code>s in <code>FROM</code> images. As the system
|
||
encounters and then applies a new label, new <code>key</code>s override any previous labels
|
||
with identical keys.</p>
|
||
|
||
<p>To view an image&rsquo;s labels, use the <code>docker inspect</code> command.</p>
|
||
|
||
<pre><code>&quot;Labels&quot;: {
|
||
&quot;com.example.vendor&quot;: &quot;ACME Incorporated&quot;
|
||
&quot;com.example.label-with-value&quot;: &quot;foo&quot;,
|
||
&quot;version&quot;: &quot;1.0&quot;,
|
||
&quot;description&quot;: &quot;This text illustrates that label-values can span multiple lines.&quot;,
|
||
&quot;multi.label1&quot;: &quot;value1&quot;,
|
||
&quot;multi.label2&quot;: &quot;value2&quot;,
|
||
&quot;other&quot;: &quot;value3&quot;
|
||
},
|
||
</code></pre>
|
||
|
||
<h2 id="expose">EXPOSE</h2>
|
||
|
||
<pre><code>EXPOSE &lt;port&gt; [&lt;port&gt;...]
|
||
</code></pre>
|
||
|
||
<p>The <code>EXPOSE</code> instructions informs Docker that the container will listen on the
|
||
specified network ports at runtime. Docker uses this information to interconnect
|
||
containers using links (see the <a href="http://localhost/userguide/dockerlinks">Docker User
|
||
Guide</a>) and to determine which ports to expose to the
|
||
host when <a href="http://localhost/docker/reference/run/#expose-incoming-ports">using the -P flag</a>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
<code>EXPOSE</code> doesn&rsquo;t define which ports can be exposed to the host or make ports
|
||
accessible from the host by default. To expose ports to the host, at runtime,
|
||
<a href="http://localhost/userguide/dockerlinks">use the <code>-p</code> flag</a> or
|
||
<a href="http://localhost/docker/reference/run/#expose-incoming-ports">the -P flag</a>.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="env">ENV</h2>
|
||
|
||
<pre><code>ENV &lt;key&gt; &lt;value&gt;
|
||
ENV &lt;key&gt;=&lt;value&gt; ...
|
||
</code></pre>
|
||
|
||
<p>The <code>ENV</code> instruction sets the environment variable <code>&lt;key&gt;</code> to the value
|
||
<code>&lt;value&gt;</code>. This value will be in the environment of all &ldquo;descendent&rdquo; <code>Dockerfile</code>
|
||
commands and can be <a href="#environment-replacement">replaced inline</a> in many as well.</p>
|
||
|
||
<p>The <code>ENV</code> instruction has two forms. The first form, <code>ENV &lt;key&gt; &lt;value&gt;</code>,
|
||
will set a single variable to a value. The entire string after the first
|
||
space will be treated as the <code>&lt;value&gt;</code> - including characters such as
|
||
spaces and quotes.</p>
|
||
|
||
<p>The second form, <code>ENV &lt;key&gt;=&lt;value&gt; ...</code>, allows for multiple variables to
|
||
be set at one time. Notice that the second form uses the equals sign (=)
|
||
in the syntax, while the first form does not. Like command line parsing,
|
||
quotes and backslashes can be used to include spaces within values.</p>
|
||
|
||
<p>For example:</p>
|
||
|
||
<pre><code>ENV myName=&quot;John Doe&quot; myDog=Rex\ The\ Dog \
|
||
myCat=fluffy
|
||
</code></pre>
|
||
|
||
<p>and</p>
|
||
|
||
<pre><code>ENV myName John Doe
|
||
ENV myDog Rex The Dog
|
||
ENV myCat fluffy
|
||
</code></pre>
|
||
|
||
<p>will yield the same net results in the final container, but the first form
|
||
does it all in one layer.</p>
|
||
|
||
<p>The environment variables set using <code>ENV</code> will persist when a container is run
|
||
from the resulting image. You can view the values using <code>docker inspect</code>, and
|
||
change them using <code>docker run --env &lt;key&gt;=&lt;value&gt;</code>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
Environment persistence can cause unexpected effects. For example,
|
||
setting <code>ENV DEBIAN_FRONTEND noninteractive</code> may confuse apt-get
|
||
users on a Debian-based image. To set a value for a single command, use
|
||
<code>RUN &lt;key&gt;=&lt;value&gt; &lt;command&gt;</code>.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="add">ADD</h2>
|
||
|
||
<p>ADD has two forms:</p>
|
||
|
||
<ul>
|
||
<li><code>ADD &lt;src&gt;... &lt;dest&gt;</code></li>
|
||
<li><code>ADD [&quot;&lt;src&gt;&quot;,... &quot;&lt;dest&gt;&quot;]</code> (this form is required for paths containing
|
||
whitespace)</li>
|
||
</ul>
|
||
|
||
<p>The <code>ADD</code> instruction copies new files, directories or remote file URLs from <code>&lt;src&gt;</code>
|
||
and adds them to the filesystem of the container at the path <code>&lt;dest&gt;</code>.</p>
|
||
|
||
<p>Multiple <code>&lt;src&gt;</code> resource may be specified but if they are files or
|
||
directories then they must be relative to the source directory that is
|
||
being built (the context of the build).</p>
|
||
|
||
<p>Each <code>&lt;src&gt;</code> may contain wildcards and matching will be done using Go&rsquo;s
|
||
<a href="http://golang.org/pkg/path/filepath#Match">filepath.Match</a> rules.
|
||
For most command line uses this should act as expected, for example:</p>
|
||
|
||
<pre><code>ADD hom* /mydir/ # adds all files starting with &quot;hom&quot;
|
||
ADD hom?.txt /mydir/ # ? is replaced with any single character
|
||
</code></pre>
|
||
|
||
<p>The <code>&lt;dest&gt;</code> is an absolute path, or a path relative to <code>WORKDIR</code>, into which
|
||
the source will be copied inside the destination container.</p>
|
||
|
||
<pre><code>ADD test aDir/ # adds &quot;test&quot; to `WORKDIR`/aDir/
|
||
</code></pre>
|
||
|
||
<p>All new files and directories are created with a UID and GID of 0.</p>
|
||
|
||
<p>In the case where <code>&lt;src&gt;</code> is a remote file URL, the destination will
|
||
have permissions of 600. If the remote file being retrieved has an HTTP
|
||
<code>Last-Modified</code> header, the timestamp from that header will be used
|
||
to set the <code>mtime</code> on the destination file. Then, like any other file
|
||
processed during an <code>ADD</code>, <code>mtime</code> will be included in the determination
|
||
of whether or not the file has changed and the cache should be updated.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
If you build by passing a <code>Dockerfile</code> through STDIN (<code>docker
|
||
build - &lt; somefile</code>), there is no build context, so the <code>Dockerfile</code>
|
||
can only contain a URL based <code>ADD</code> instruction. You can also pass a
|
||
compressed archive through STDIN: (<code>docker build - &lt; archive.tar.gz</code>),
|
||
the <code>Dockerfile</code> at the root of the archive and the rest of the
|
||
archive will get used at the context of the build.</p>
|
||
|
||
<p><strong>Note</strong>:
|
||
If your URL files are protected using authentication, you
|
||
will need to use <code>RUN wget</code>, <code>RUN curl</code> or use another tool from
|
||
within the container as the <code>ADD</code> instruction does not support
|
||
authentication.</p>
|
||
|
||
<p><strong>Note</strong>:
|
||
The first encountered <code>ADD</code> instruction will invalidate the cache for all
|
||
following instructions from the Dockerfile if the contents of <code>&lt;src&gt;</code> have
|
||
changed. This includes invalidating the cache for <code>RUN</code> instructions.
|
||
See the <a href="http://localhost/articles/dockerfile_best-practices/#build-cache"><code>Dockerfile</code> Best Practices
|
||
guide</a> for more information.</p>
|
||
</blockquote>
|
||
|
||
<p>The copy obeys the following rules:</p>
|
||
|
||
<ul>
|
||
<li><p>The <code>&lt;src&gt;</code> path must be inside the <em>context</em> of the build;
|
||
you cannot <code>ADD ../something /something</code>, because the first step of a
|
||
<code>docker build</code> is to send the context directory (and subdirectories) to the
|
||
docker daemon.</p></li>
|
||
|
||
<li><p>If <code>&lt;src&gt;</code> is a URL and <code>&lt;dest&gt;</code> does not end with a trailing slash, then a
|
||
file is downloaded from the URL and copied to <code>&lt;dest&gt;</code>.</p></li>
|
||
|
||
<li><p>If <code>&lt;src&gt;</code> is a URL and <code>&lt;dest&gt;</code> does end with a trailing slash, then the
|
||
filename is inferred from the URL and the file is downloaded to
|
||
<code>&lt;dest&gt;/&lt;filename&gt;</code>. For instance, <code>ADD http://example.com/foobar /</code> would
|
||
create the file <code>/foobar</code>. The URL must have a nontrivial path so that an
|
||
appropriate filename can be discovered in this case (<code>http://example.com</code>
|
||
will not work).</p></li>
|
||
|
||
<li><p>If <code>&lt;src&gt;</code> is a directory, the entire contents of the directory are copied,
|
||
including filesystem metadata.
|
||
&gt; <strong>Note</strong>:
|
||
&gt; The directory itself is not copied, just its contents.</p></li>
|
||
|
||
<li><p>If <code>&lt;src&gt;</code> is a <em>local</em> tar archive in a recognized compression format
|
||
(identity, gzip, bzip2 or xz) then it is unpacked as a directory. Resources
|
||
from <em>remote</em> URLs are <strong>not</strong> decompressed. When a directory is copied or
|
||
unpacked, it has the same behavior as <code>tar -x</code>: the result is the union of:</p>
|
||
|
||
<ol>
|
||
<li>Whatever existed at the destination path and</li>
|
||
<li>The contents of the source tree, with conflicts resolved in favor
|
||
of &ldquo;2.&rdquo; on a file-by-file basis.</li>
|
||
</ol></li>
|
||
|
||
<li><p>If <code>&lt;src&gt;</code> is any other kind of file, it is copied individually along with
|
||
its metadata. In this case, if <code>&lt;dest&gt;</code> ends with a trailing slash <code>/</code>, it
|
||
will be considered a directory and the contents of <code>&lt;src&gt;</code> will be written
|
||
at <code>&lt;dest&gt;/base(&lt;src&gt;)</code>.</p></li>
|
||
|
||
<li><p>If multiple <code>&lt;src&gt;</code> resources are specified, either directly or due to the
|
||
use of a wildcard, then <code>&lt;dest&gt;</code> must be a directory, and it must end with
|
||
a slash <code>/</code>.</p></li>
|
||
|
||
<li><p>If <code>&lt;dest&gt;</code> does not end with a trailing slash, it will be considered a
|
||
regular file and the contents of <code>&lt;src&gt;</code> will be written at <code>&lt;dest&gt;</code>.</p></li>
|
||
|
||
<li><p>If <code>&lt;dest&gt;</code> doesn&rsquo;t exist, it is created along with all missing directories
|
||
in its path.</p></li>
|
||
</ul>
|
||
|
||
<h2 id="copy">COPY</h2>
|
||
|
||
<p>COPY has two forms:</p>
|
||
|
||
<ul>
|
||
<li><code>COPY &lt;src&gt;... &lt;dest&gt;</code></li>
|
||
<li><code>COPY [&quot;&lt;src&gt;&quot;,... &quot;&lt;dest&gt;&quot;]</code> (this form is required for paths containing
|
||
whitespace)</li>
|
||
</ul>
|
||
|
||
<p>The <code>COPY</code> instruction copies new files or directories from <code>&lt;src&gt;</code>
|
||
and adds them to the filesystem of the container at the path <code>&lt;dest&gt;</code>.</p>
|
||
|
||
<p>Multiple <code>&lt;src&gt;</code> resource may be specified but they must be relative
|
||
to the source directory that is being built (the context of the build).</p>
|
||
|
||
<p>Each <code>&lt;src&gt;</code> may contain wildcards and matching will be done using Go&rsquo;s
|
||
<a href="http://golang.org/pkg/path/filepath#Match">filepath.Match</a> rules.
|
||
For most command line uses this should act as expected, for example:</p>
|
||
|
||
<pre><code>COPY hom* /mydir/ # adds all files starting with &quot;hom&quot;
|
||
COPY hom?.txt /mydir/ # ? is replaced with any single character
|
||
</code></pre>
|
||
|
||
<p>The <code>&lt;dest&gt;</code> is an absolute path, or a path relative to <code>WORKDIR</code>, into which
|
||
the source will be copied inside the destination container.</p>
|
||
|
||
<pre><code>COPY test aDir/ # adds &quot;test&quot; to `WORKDIR`/aDir/
|
||
</code></pre>
|
||
|
||
<p>All new files and directories are created with a UID and GID of 0.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
If you build using STDIN (<code>docker build - &lt; somefile</code>), there is no
|
||
build context, so <code>COPY</code> can&rsquo;t be used.</p>
|
||
</blockquote>
|
||
|
||
<p>The copy obeys the following rules:</p>
|
||
|
||
<ul>
|
||
<li><p>The <code>&lt;src&gt;</code> path must be inside the <em>context</em> of the build;
|
||
you cannot <code>COPY ../something /something</code>, because the first step of a
|
||
<code>docker build</code> is to send the context directory (and subdirectories) to the
|
||
docker daemon.</p></li>
|
||
|
||
<li><p>If <code>&lt;src&gt;</code> is a directory, the entire contents of the directory are copied,
|
||
including filesystem metadata.
|
||
&gt; <strong>Note</strong>:
|
||
&gt; The directory itself is not copied, just its contents.</p></li>
|
||
|
||
<li><p>If <code>&lt;src&gt;</code> is any other kind of file, it is copied individually along with
|
||
its metadata. In this case, if <code>&lt;dest&gt;</code> ends with a trailing slash <code>/</code>, it
|
||
will be considered a directory and the contents of <code>&lt;src&gt;</code> will be written
|
||
at <code>&lt;dest&gt;/base(&lt;src&gt;)</code>.</p></li>
|
||
|
||
<li><p>If multiple <code>&lt;src&gt;</code> resources are specified, either directly or due to the
|
||
use of a wildcard, then <code>&lt;dest&gt;</code> must be a directory, and it must end with
|
||
a slash <code>/</code>.</p></li>
|
||
|
||
<li><p>If <code>&lt;dest&gt;</code> does not end with a trailing slash, it will be considered a
|
||
regular file and the contents of <code>&lt;src&gt;</code> will be written at <code>&lt;dest&gt;</code>.</p></li>
|
||
|
||
<li><p>If <code>&lt;dest&gt;</code> doesn&rsquo;t exist, it is created along with all missing directories
|
||
in its path.</p></li>
|
||
</ul>
|
||
|
||
<h2 id="entrypoint">ENTRYPOINT</h2>
|
||
|
||
<p>ENTRYPOINT has two forms:</p>
|
||
|
||
<ul>
|
||
<li><code>ENTRYPOINT [&quot;executable&quot;, &quot;param1&quot;, &quot;param2&quot;]</code>
|
||
(the preferred <em>exec</em> form)</li>
|
||
<li><code>ENTRYPOINT command param1 param2</code>
|
||
(<em>shell</em> form)</li>
|
||
</ul>
|
||
|
||
<p>An <code>ENTRYPOINT</code> allows you to configure a container that will run as an executable.</p>
|
||
|
||
<p>For example, the following will start nginx with its default content, listening
|
||
on port 80:</p>
|
||
|
||
<pre><code>docker run -i -t --rm -p 80:80 nginx
|
||
</code></pre>
|
||
|
||
<p>Command line arguments to <code>docker run &lt;image&gt;</code> will be appended after all
|
||
elements in an <em>exec</em> form <code>ENTRYPOINT</code>, and will override all elements specified
|
||
using <code>CMD</code>.
|
||
This allows arguments to be passed to the entry point, i.e., <code>docker run &lt;image&gt; -d</code>
|
||
will pass the <code>-d</code> argument to the entry point.
|
||
You can override the <code>ENTRYPOINT</code> instruction using the <code>docker run --entrypoint</code>
|
||
flag.</p>
|
||
|
||
<p>The <em>shell</em> form prevents any <code>CMD</code> or <code>run</code> command line arguments from being
|
||
used, but has the disadvantage that your <code>ENTRYPOINT</code> will be started as a
|
||
subcommand of <code>/bin/sh -c</code>, which does not pass signals.
|
||
This means that the executable will not be the container&rsquo;s <code>PID 1</code> - and
|
||
will <em>not</em> receive Unix signals - so your executable will not receive a
|
||
<code>SIGTERM</code> from <code>docker stop &lt;container&gt;</code>.</p>
|
||
|
||
<p>Only the last <code>ENTRYPOINT</code> instruction in the <code>Dockerfile</code> will have an effect.</p>
|
||
|
||
<h3 id="exec-form-entrypoint-example">Exec form ENTRYPOINT example</h3>
|
||
|
||
<p>You can use the <em>exec</em> form of <code>ENTRYPOINT</code> to set fairly stable default commands
|
||
and arguments and then use either form of <code>CMD</code> to set additional defaults that
|
||
are more likely to be changed.</p>
|
||
|
||
<pre><code>FROM ubuntu
|
||
ENTRYPOINT [&quot;top&quot;, &quot;-b&quot;]
|
||
CMD [&quot;-c&quot;]
|
||
</code></pre>
|
||
|
||
<p>When you run the container, you can see that <code>top</code> is the only process:</p>
|
||
|
||
<pre><code>$ docker run -it --rm --name test top -H
|
||
top - 08:25:00 up 7:27, 0 users, load average: 0.00, 0.01, 0.05
|
||
Threads: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||
%Cpu(s): 0.1 us, 0.1 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
|
||
KiB Mem: 2056668 total, 1616832 used, 439836 free, 99352 buffers
|
||
KiB Swap: 1441840 total, 0 used, 1441840 free. 1324440 cached Mem
|
||
|
||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||
1 root 20 0 19744 2336 2080 R 0.0 0.1 0:00.04 top
|
||
</code></pre>
|
||
|
||
<p>To examine the result further, you can use <code>docker exec</code>:</p>
|
||
|
||
<pre><code>$ docker exec -it test ps aux
|
||
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
|
||
root 1 2.6 0.1 19752 2352 ? Ss+ 08:24 0:00 top -b -H
|
||
root 7 0.0 0.1 15572 2164 ? R+ 08:25 0:00 ps aux
|
||
</code></pre>
|
||
|
||
<p>And you can gracefully request <code>top</code> to shut down using <code>docker stop test</code>.</p>
|
||
|
||
<p>The following <code>Dockerfile</code> shows using the <code>ENTRYPOINT</code> to run Apache in the
|
||
foreground (i.e., as <code>PID 1</code>):</p>
|
||
|
||
<pre><code>FROM debian:stable
|
||
RUN apt-get update &amp;&amp; apt-get install -y --force-yes apache2
|
||
EXPOSE 80 443
|
||
VOLUME [&quot;/var/www&quot;, &quot;/var/log/apache2&quot;, &quot;/etc/apache2&quot;]
|
||
ENTRYPOINT [&quot;/usr/sbin/apache2ctl&quot;, &quot;-D&quot;, &quot;FOREGROUND&quot;]
|
||
</code></pre>
|
||
|
||
<p>If you need to write a starter script for a single executable, you can ensure that
|
||
the final executable receives the Unix signals by using <code>exec</code> and <code>gosu</code>
|
||
commands:</p>
|
||
|
||
<pre><code class="language-bash">#!/bin/bash
|
||
set -e
|
||
|
||
if [ &quot;$1&quot; = 'postgres' ]; then
|
||
chown -R postgres &quot;$PGDATA&quot;
|
||
|
||
if [ -z &quot;$(ls -A &quot;$PGDATA&quot;)&quot; ]; then
|
||
gosu postgres initdb
|
||
fi
|
||
|
||
exec gosu postgres &quot;$@&quot;
|
||
fi
|
||
|
||
exec &quot;$@&quot;
|
||
</code></pre>
|
||
|
||
<p>Lastly, if you need to do some extra cleanup (or communicate with other containers)
|
||
on shutdown, or are co-ordinating more than one executable, you may need to ensure
|
||
that the <code>ENTRYPOINT</code> script receives the Unix signals, passes them on, and then
|
||
does some more work:</p>
|
||
|
||
<pre><code>#!/bin/sh
|
||
# Note: I've written this using sh so it works in the busybox container too
|
||
|
||
# USE the trap if you need to also do manual cleanup after the service is stopped,
|
||
# or need to start multiple services in the one container
|
||
trap &quot;echo TRAPed signal&quot; HUP INT QUIT KILL TERM
|
||
|
||
# start service in background here
|
||
/usr/sbin/apachectl start
|
||
|
||
echo &quot;[hit enter key to exit] or run 'docker stop &lt;container&gt;'&quot;
|
||
read
|
||
|
||
# stop service and clean up here
|
||
echo &quot;stopping apache&quot;
|
||
/usr/sbin/apachectl stop
|
||
|
||
echo &quot;exited $0&quot;
|
||
</code></pre>
|
||
|
||
<p>If you run this image with <code>docker run -it --rm -p 80:80 --name test apache</code>,
|
||
you can then examine the container&rsquo;s processes with <code>docker exec</code>, or <code>docker top</code>,
|
||
and then ask the script to stop Apache:</p>
|
||
|
||
<pre><code class="language-bash">$ docker exec -it test ps aux
|
||
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
|
||
root 1 0.1 0.0 4448 692 ? Ss+ 00:42 0:00 /bin/sh /run.sh 123 cmd cmd2
|
||
root 19 0.0 0.2 71304 4440 ? Ss 00:42 0:00 /usr/sbin/apache2 -k start
|
||
www-data 20 0.2 0.2 360468 6004 ? Sl 00:42 0:00 /usr/sbin/apache2 -k start
|
||
www-data 21 0.2 0.2 360468 6000 ? Sl 00:42 0:00 /usr/sbin/apache2 -k start
|
||
root 81 0.0 0.1 15572 2140 ? R+ 00:44 0:00 ps aux
|
||
$ docker top test
|
||
PID USER COMMAND
|
||
10035 root {run.sh} /bin/sh /run.sh 123 cmd cmd2
|
||
10054 root /usr/sbin/apache2 -k start
|
||
10055 33 /usr/sbin/apache2 -k start
|
||
10056 33 /usr/sbin/apache2 -k start
|
||
$ /usr/bin/time docker stop test
|
||
test
|
||
real 0m 0.27s
|
||
user 0m 0.03s
|
||
sys 0m 0.03s
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong> you can over ride the <code>ENTRYPOINT</code> setting using <code>--entrypoint</code>,
|
||
but this can only set the binary to <em>exec</em> (no <code>sh -c</code> will be used).</p>
|
||
|
||
<p><strong>Note</strong>:
|
||
The <em>exec</em> form is parsed as a JSON array, which means that
|
||
you must use double-quotes (&ldquo;) around words not single-quotes (&lsquo;).</p>
|
||
|
||
<p><strong>Note</strong>:
|
||
Unlike the <em>shell</em> form, the <em>exec</em> form does not invoke a command shell.
|
||
This means that normal shell processing does not happen. For example,
|
||
<code>ENTRYPOINT [ &quot;echo&quot;, &quot;$HOME&quot; ]</code> will not do variable substitution on <code>$HOME</code>.
|
||
If you want shell processing then either use the <em>shell</em> form or execute
|
||
a shell directly, for example: <code>ENTRYPOINT [ &quot;sh&quot;, &quot;-c&quot;, &quot;echo&quot;, &quot;$HOME&quot; ]</code>.
|
||
Variables that are defined in the <code>Dockerfile</code>using <code>ENV</code>, will be substituted by
|
||
the <code>Dockerfile</code> parser.</p>
|
||
</blockquote>
|
||
|
||
<h3 id="shell-form-entrypoint-example">Shell form ENTRYPOINT example</h3>
|
||
|
||
<p>You can specify a plain string for the <code>ENTRYPOINT</code> and it will execute in <code>/bin/sh -c</code>.
|
||
This form will use shell processing to substitute shell environment variables,
|
||
and will ignore any <code>CMD</code> or <code>docker run</code> command line arguments.
|
||
To ensure that <code>docker stop</code> will signal any long running <code>ENTRYPOINT</code> executable
|
||
correctly, you need to remember to start it with <code>exec</code>:</p>
|
||
|
||
<pre><code>FROM ubuntu
|
||
ENTRYPOINT exec top -b
|
||
</code></pre>
|
||
|
||
<p>When you run this image, you&rsquo;ll see the single <code>PID 1</code> process:</p>
|
||
|
||
<pre><code>$ docker run -it --rm --name test top
|
||
Mem: 1704520K used, 352148K free, 0K shrd, 0K buff, 140368121167873K cached
|
||
CPU: 5% usr 0% sys 0% nic 94% idle 0% io 0% irq 0% sirq
|
||
Load average: 0.08 0.03 0.05 2/98 6
|
||
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
|
||
1 0 root R 3164 0% 0% top -b
|
||
</code></pre>
|
||
|
||
<p>Which will exit cleanly on <code>docker stop</code>:</p>
|
||
|
||
<pre><code>$ /usr/bin/time docker stop test
|
||
test
|
||
real 0m 0.20s
|
||
user 0m 0.02s
|
||
sys 0m 0.04s
|
||
</code></pre>
|
||
|
||
<p>If you forget to add <code>exec</code> to the beginning of your <code>ENTRYPOINT</code>:</p>
|
||
|
||
<pre><code>FROM ubuntu
|
||
ENTRYPOINT top -b
|
||
CMD --ignored-param1
|
||
</code></pre>
|
||
|
||
<p>You can then run it (giving it a name for the next step):</p>
|
||
|
||
<pre><code>$ docker run -it --name test top --ignored-param2
|
||
Mem: 1704184K used, 352484K free, 0K shrd, 0K buff, 140621524238337K cached
|
||
CPU: 9% usr 2% sys 0% nic 88% idle 0% io 0% irq 0% sirq
|
||
Load average: 0.01 0.02 0.05 2/101 7
|
||
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
|
||
1 0 root S 3168 0% 0% /bin/sh -c top -b cmd cmd2
|
||
7 1 root R 3164 0% 0% top -b
|
||
</code></pre>
|
||
|
||
<p>You can see from the output of <code>top</code> that the specified <code>ENTRYPOINT</code> is not <code>PID 1</code>.</p>
|
||
|
||
<p>If you then run <code>docker stop test</code>, the container will not exit cleanly - the
|
||
<code>stop</code> command will be forced to send a <code>SIGKILL</code> after the timeout:</p>
|
||
|
||
<pre><code>$ docker exec -it test ps aux
|
||
PID USER COMMAND
|
||
1 root /bin/sh -c top -b cmd cmd2
|
||
7 root top -b
|
||
8 root ps aux
|
||
$ /usr/bin/time docker stop test
|
||
test
|
||
real 0m 10.19s
|
||
user 0m 0.04s
|
||
sys 0m 0.03s
|
||
</code></pre>
|
||
|
||
<h2 id="volume">VOLUME</h2>
|
||
|
||
<pre><code>VOLUME [&quot;/data&quot;]
|
||
</code></pre>
|
||
|
||
<p>The <code>VOLUME</code> instruction creates a mount point with the specified name
|
||
and marks it as holding externally mounted volumes from native host or other
|
||
containers. The value can be a JSON array, <code>VOLUME [&quot;/var/log/&quot;]</code>, or a plain
|
||
string with multiple arguments, such as <code>VOLUME /var/log</code> or <code>VOLUME /var/log
|
||
/var/db</code>. For more information/examples and mounting instructions via the
|
||
Docker client, refer to
|
||
<a href="http://localhost/userguide/dockervolumes/#volume"><em>Share Directories via Volumes</em></a>
|
||
documentation.</p>
|
||
|
||
<p>The <code>docker run</code> command initializes the newly created volume with any data
|
||
that exists at the specified location within the base image. For example,
|
||
consider the following Dockerfile snippet:</p>
|
||
|
||
<pre><code>FROM ubuntu
|
||
RUN mkdir /myvol
|
||
RUN echo &quot;hello world&quot; &gt; /myvol/greeting
|
||
VOLUME /myvol
|
||
</code></pre>
|
||
|
||
<p>This Dockerfile results in an image that causes <code>docker run</code>, to
|
||
create a new mount point at <code>/myvol</code> and copy the <code>greeting</code> file
|
||
into the newly created volume.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
The list is parsed as a JSON array, which means that
|
||
you must use double-quotes (&ldquo;) around words not single-quotes (&lsquo;).</p>
|
||
</blockquote>
|
||
|
||
<h2 id="user">USER</h2>
|
||
|
||
<pre><code>USER daemon
|
||
</code></pre>
|
||
|
||
<p>The <code>USER</code> instruction sets the user name or UID to use when running the image
|
||
and for any <code>RUN</code>, <code>CMD</code> and <code>ENTRYPOINT</code> instructions that follow it in the
|
||
<code>Dockerfile</code>.</p>
|
||
|
||
<h2 id="workdir">WORKDIR</h2>
|
||
|
||
<pre><code>WORKDIR /path/to/workdir
|
||
</code></pre>
|
||
|
||
<p>The <code>WORKDIR</code> instruction sets the working directory for any <code>RUN</code>, <code>CMD</code>,
|
||
<code>ENTRYPOINT</code>, <code>COPY</code> and <code>ADD</code> instructions that follow it in the <code>Dockerfile</code>.</p>
|
||
|
||
<p>It can be used multiple times in the one <code>Dockerfile</code>. If a relative path
|
||
is provided, it will be relative to the path of the previous <code>WORKDIR</code>
|
||
instruction. For example:</p>
|
||
|
||
<pre><code>WORKDIR /a
|
||
WORKDIR b
|
||
WORKDIR c
|
||
RUN pwd
|
||
</code></pre>
|
||
|
||
<p>The output of the final <code>pwd</code> command in this <code>Dockerfile</code> would be
|
||
<code>/a/b/c</code>.</p>
|
||
|
||
<p>The <code>WORKDIR</code> instruction can resolve environment variables previously set using
|
||
<code>ENV</code>. You can only use environment variables explicitly set in the <code>Dockerfile</code>.
|
||
For example:</p>
|
||
|
||
<pre><code>ENV DIRPATH /path
|
||
WORKDIR $DIRPATH/$DIRNAME
|
||
</code></pre>
|
||
|
||
<p>The output of the final <code>pwd</code> command in this <code>Dockerfile</code> would be
|
||
<code>/path/$DIRNAME</code></p>
|
||
|
||
<h2 id="onbuild">ONBUILD</h2>
|
||
|
||
<pre><code>ONBUILD [INSTRUCTION]
|
||
</code></pre>
|
||
|
||
<p>The <code>ONBUILD</code> instruction adds to the image a <em>trigger</em> instruction to
|
||
be executed at a later time, when the image is used as the base for
|
||
another build. The trigger will be executed in the context of the
|
||
downstream build, as if it had been inserted immediately after the
|
||
<code>FROM</code> instruction in the downstream <code>Dockerfile</code>.</p>
|
||
|
||
<p>Any build instruction can be registered as a trigger.</p>
|
||
|
||
<p>This is useful if you are building an image which will be used as a base
|
||
to build other images, for example an application build environment or a
|
||
daemon which may be customized with user-specific configuration.</p>
|
||
|
||
<p>For example, if your image is a reusable Python application builder, it
|
||
will require application source code to be added in a particular
|
||
directory, and it might require a build script to be called <em>after</em>
|
||
that. You can&rsquo;t just call <code>ADD</code> and <code>RUN</code> now, because you don&rsquo;t yet
|
||
have access to the application source code, and it will be different for
|
||
each application build. You could simply provide application developers
|
||
with a boilerplate <code>Dockerfile</code> to copy-paste into their application, but
|
||
that is inefficient, error-prone and difficult to update because it
|
||
mixes with application-specific code.</p>
|
||
|
||
<p>The solution is to use <code>ONBUILD</code> to register advance instructions to
|
||
run later, during the next build stage.</p>
|
||
|
||
<p>Here&rsquo;s how it works:</p>
|
||
|
||
<ol>
|
||
<li>When it encounters an <code>ONBUILD</code> instruction, the builder adds a
|
||
trigger to the metadata of the image being built. The instruction
|
||
does not otherwise affect the current build.</li>
|
||
<li>At the end of the build, a list of all triggers is stored in the
|
||
image manifest, under the key <code>OnBuild</code>. They can be inspected with
|
||
the <code>docker inspect</code> command.</li>
|
||
<li>Later the image may be used as a base for a new build, using the
|
||
<code>FROM</code> instruction. As part of processing the <code>FROM</code> instruction,
|
||
the downstream builder looks for <code>ONBUILD</code> triggers, and executes
|
||
them in the same order they were registered. If any of the triggers
|
||
fail, the <code>FROM</code> instruction is aborted which in turn causes the
|
||
build to fail. If all triggers succeed, the <code>FROM</code> instruction
|
||
completes and the build continues as usual.</li>
|
||
<li>Triggers are cleared from the final image after being executed. In
|
||
other words they are not inherited by &ldquo;grand-children&rdquo; builds.</li>
|
||
</ol>
|
||
|
||
<p>For example you might add something like this:</p>
|
||
|
||
<pre><code>[...]
|
||
ONBUILD ADD . /app/src
|
||
ONBUILD RUN /usr/local/bin/python-build --dir /app/src
|
||
[...]
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Warning</strong>: Chaining <code>ONBUILD</code> instructions using <code>ONBUILD ONBUILD</code> isn&rsquo;t allowed.</p>
|
||
|
||
<p><strong>Warning</strong>: The <code>ONBUILD</code> instruction may not trigger <code>FROM</code> or <code>MAINTAINER</code> instructions.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="dockerfile-examples">Dockerfile examples</h2>
|
||
|
||
<pre><code># Nginx
|
||
#
|
||
# VERSION 0.0.1
|
||
|
||
FROM ubuntu
|
||
MAINTAINER Victor Vieux &lt;victor@docker.com&gt;
|
||
|
||
LABEL Description=&quot;This image is used to start the foobar executable&quot; Vendor=&quot;ACME Products&quot; Version=&quot;1.0&quot;
|
||
RUN apt-get update &amp;&amp; apt-get install -y inotify-tools nginx apache2 openssh-server
|
||
|
||
# Firefox over VNC
|
||
#
|
||
# VERSION 0.3
|
||
|
||
FROM ubuntu
|
||
|
||
# Install vnc, xvfb in order to create a 'fake' display and firefox
|
||
RUN apt-get update &amp;&amp; apt-get install -y x11vnc xvfb firefox
|
||
RUN mkdir ~/.vnc
|
||
# Setup a password
|
||
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
|
||
# Autostart firefox (might not be the best way, but it does the trick)
|
||
RUN bash -c 'echo &quot;firefox&quot; &gt;&gt; /.bashrc'
|
||
|
||
EXPOSE 5900
|
||
CMD [&quot;x11vnc&quot;, &quot;-forever&quot;, &quot;-usepw&quot;, &quot;-create&quot;]
|
||
|
||
# Multiple images example
|
||
#
|
||
# VERSION 0.1
|
||
|
||
FROM ubuntu
|
||
RUN echo foo &gt; bar
|
||
# Will output something like ===&gt; 907ad6c2736f
|
||
|
||
FROM ubuntu
|
||
RUN echo moo &gt; oink
|
||
# Will output something like ===&gt; 695d7793cbe4
|
||
|
||
# You᾿ll now have two images, 907ad6c2736f with /bar, and 695d7793cbe4 with
|
||
# /oink.
|
||
</code></pre>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Remote API</title>
|
||
<link>http://localhost/reference/api/docker_remote_api/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/docker_remote_api/</guid>
|
||
<description>
|
||
|
||
<h1 id="docker-remote-api">Docker Remote API</h1>
|
||
|
||
<ul>
|
||
<li>By default the Docker daemon listens on <code>unix:///var/run/docker.sock</code>
|
||
and the client must have <code>root</code> access to interact with the daemon.</li>
|
||
<li>If the Docker daemon is set to use an encrypted TCP socket (<code>--tls</code>,
|
||
or <code>--tlsverify</code>) as with Boot2Docker 1.3.0, then you need to add extra
|
||
parameters to <code>curl</code> or <code>wget</code> when making test API requests:
|
||
<code>curl --insecure --cert ~/.docker/cert.pem --key ~/.docker/key.pem https://boot2docker:2376/images/json</code>
|
||
or
|
||
<code>wget --no-check-certificate --certificate=$DOCKER_CERT_PATH/cert.pem --private-key=$DOCKER_CERT_PATH/key.pem https://boot2docker:2376/images/json -O - -q</code></li>
|
||
<li>If a group named <code>docker</code> exists on your system, docker will apply
|
||
ownership of the socket to the group.</li>
|
||
<li>The API tends to be REST, but for some complex commands, like attach
|
||
or pull, the HTTP connection is hijacked to transport STDOUT, STDIN,
|
||
and STDERR.</li>
|
||
<li>Since API version 1.2, the auth configuration is now handled client
|
||
side, so the client has to send the <code>authConfig</code> as a <code>POST</code> in <code>/images/(name)/push</code>.</li>
|
||
<li>authConfig, set as the <code>X-Registry-Auth</code> header, is currently a Base64
|
||
encoded (JSON) string with the following structure:
|
||
<code>{&quot;username&quot;: &quot;string&quot;, &quot;password&quot;: &quot;string&quot;, &quot;email&quot;: &quot;string&quot;,
|
||
&quot;serveraddress&quot; : &quot;string&quot;, &quot;auth&quot;: &quot;&quot;}</code>. Notice that <code>auth</code> is to be left
|
||
empty, <code>serveraddress</code> is a domain/ip without protocol, and that double
|
||
quotes (instead of single ones) are required.</li>
|
||
<li>The Remote API uses an open schema model. In this model, unknown
|
||
properties in incoming messages will be ignored.
|
||
Client applications need to take this into account to ensure
|
||
they will not break when talking to newer Docker daemons.</li>
|
||
</ul>
|
||
|
||
<p>The current version of the API is v1.19</p>
|
||
|
||
<p>Calling <code>/info</code> is the same as calling
|
||
<code>/v1.19/info</code>.</p>
|
||
|
||
<p>You can still call an old version of the API using
|
||
<code>/v1.18/info</code>.</p>
|
||
|
||
<h2 id="docker-events">Docker Events</h2>
|
||
|
||
<p>The following diagram depicts the container states accessible through the API.</p>
|
||
|
||
<p><img src="http://localhost/docker/reference/api/images/event_state.png" alt="States" />
|
||
</p>
|
||
|
||
<p>Some container-related events are not affected by container state, so they are not included in this diagram. These events are:</p>
|
||
|
||
<ul>
|
||
<li><strong>export</strong> emitted by <code>docker export</code></li>
|
||
<li><strong>exec_create</strong> emitted by <code>docker exec</code></li>
|
||
<li><strong>exec_start</strong> emitted by <code>docker exec</code> after <strong>exec_create</strong></li>
|
||
</ul>
|
||
|
||
<p>Running <code>docker rmi</code> emits an <strong>untag</strong> event when removing an image name. The <code>rmi</code> command may also emit <strong>delete</strong> events when images are deleted by ID directly or by deleting the last tag referring to the image.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Acknowledgement</strong>: This diagram and the accompanying text were used with the permission of Matt Good and Gilder Labs. See Matt&rsquo;s original blog post <a href="http://gliderlabs.com/blog/2015/04/14/docker-events-explained/">Docker Events Explained</a>.</p>
|
||
</blockquote>
|
||
|
||
<h2 id="v1-19">v1.19</h2>
|
||
|
||
<h3 id="full-documentation">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.19/"><em>Docker Remote API v1.19</em></a></p>
|
||
|
||
<h3 id="what-s-new">What&rsquo;s new</h3>
|
||
|
||
<p><strong>New!</strong>
|
||
When the daemon detects a version mismatch with the client, usually when
|
||
the client is newer than the daemon, an HTTP 400 is now returned instead
|
||
of a 404.</p>
|
||
|
||
<p><code>GET /containers/(id)/stats</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can now supply a <code>stream</code> bool to get only one set of stats and
|
||
disconnect</p>
|
||
|
||
<p><code>GET /containers(id)/logs</code></p>
|
||
|
||
<p><strong>New!</strong></p>
|
||
|
||
<p>This endpoint now accepts a <code>since</code> timestamp parameter.</p>
|
||
|
||
<p><code>GET /info</code></p>
|
||
|
||
<p><strong>New!</strong></p>
|
||
|
||
<p>The fields <code>Debug</code>, <code>IPv4Forwarding</code>, <code>MemoryLimit</code>, and <code>SwapLimit</code>
|
||
are now returned as boolean instead of as an int.</p>
|
||
|
||
<p>In addition, the end point now returns the new boolean fields
|
||
<code>CpuCfsPeriod</code>, <code>CpuCfsQuota</code>, and <code>OomKillDisable</code>.</p>
|
||
|
||
<h2 id="v1-18">v1.18</h2>
|
||
|
||
<h3 id="full-documentation-1">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.18/"><em>Docker Remote API v1.18</em></a></p>
|
||
|
||
<h3 id="what-s-new-1">What&rsquo;s new</h3>
|
||
|
||
<p><code>GET /version</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
This endpoint now returns <code>Os</code>, <code>Arch</code> and <code>KernelVersion</code>.</p>
|
||
|
||
<p><code>POST /containers/create</code>
|
||
<code>POST /containers/(id)/start</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can set ulimit settings to be used within the container.</p>
|
||
|
||
<p><code>GET /info</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
This endpoint now returns <code>SystemTime</code>, <code>HttpProxy</code>,<code>HttpsProxy</code> and <code>NoProxy</code>.</p>
|
||
|
||
<p><code>GET /images/json</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
Added a <code>RepoDigests</code> field to include image digest information.</p>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
Builds can now set resource constraints for all containers created for the build.</p>
|
||
|
||
<p><strong>New!</strong>
|
||
(<code>CgroupParent</code>) can be passed in the host config to setup container cgroups under a specific cgroup.</p>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
Closing the HTTP request will now cause the build to be canceled.</p>
|
||
|
||
<p><code>POST /containers/(id)/exec</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
Add <code>Warnings</code> field to response.</p>
|
||
|
||
<h2 id="v1-17">v1.17</h2>
|
||
|
||
<h3 id="full-documentation-2">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.17/"><em>Docker Remote API v1.17</em></a></p>
|
||
|
||
<h3 id="what-s-new-2">What&rsquo;s new</h3>
|
||
|
||
<p>The build supports <code>LABEL</code> command. Use this to add metadata
|
||
to an image. For example you could add data describing the content of an image.</p>
|
||
|
||
<p><code>LABEL &quot;com.example.vendor&quot;=&quot;ACME Incorporated&quot;</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
<code>POST /containers/(id)/attach</code> and <code>POST /exec/(id)/start</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
Docker client now hints potential proxies about connection hijacking using HTTP Upgrade headers.</p>
|
||
|
||
<p><code>POST /containers/create</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can set labels on container create describing the container.</p>
|
||
|
||
<p><code>GET /containers/json</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
The endpoint returns the labels associated with the containers (<code>Labels</code>).</p>
|
||
|
||
<p><code>GET /containers/(id)/json</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
This endpoint now returns the list current execs associated with the container (<code>ExecIDs</code>).
|
||
This endpoint now returns the container labels (<code>Config.Labels</code>).</p>
|
||
|
||
<p><code>POST /containers/(id)/rename</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
New endpoint to rename a container <code>id</code> to a new name.</p>
|
||
|
||
<p><code>POST /containers/create</code>
|
||
<code>POST /containers/(id)/start</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
(<code>ReadonlyRootfs</code>) can be passed in the host config to mount the container&rsquo;s
|
||
root filesystem as read only.</p>
|
||
|
||
<p><code>GET /containers/(id)/stats</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
This endpoint returns a live stream of a container&rsquo;s resource usage statistics.</p>
|
||
|
||
<p><code>GET /images/json</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
This endpoint now returns the labels associated with each image (<code>Labels</code>).</p>
|
||
|
||
<h2 id="v1-16">v1.16</h2>
|
||
|
||
<h3 id="full-documentation-3">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.16/"><em>Docker Remote API v1.16</em></a></p>
|
||
|
||
<h3 id="what-s-new-3">What&rsquo;s new</h3>
|
||
|
||
<p><code>GET /info</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
<code>info</code> now returns the number of CPUs available on the machine (<code>NCPU</code>),
|
||
total memory available (<code>MemTotal</code>), a user-friendly name describing the running Docker daemon (<code>Name</code>), a unique ID identifying the daemon (<code>ID</code>), and
|
||
a list of daemon labels (<code>Labels</code>).</p>
|
||
|
||
<p><code>POST /containers/create</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can set the new container&rsquo;s MAC address explicitly.</p>
|
||
|
||
<p><strong>New!</strong>
|
||
Volumes are now initialized when the container is created.</p>
|
||
|
||
<p><code>POST /containers/(id)/copy</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can now copy data which is contained in a volume.</p>
|
||
|
||
<h2 id="v1-15">v1.15</h2>
|
||
|
||
<h3 id="full-documentation-4">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.15/"><em>Docker Remote API v1.15</em></a></p>
|
||
|
||
<h3 id="what-s-new-4">What&rsquo;s new</h3>
|
||
|
||
<p><code>POST /containers/create</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
It is now possible to set a container&rsquo;s HostConfig when creating a container.
|
||
Previously this was only available when starting a container.</p>
|
||
|
||
<h2 id="v1-14">v1.14</h2>
|
||
|
||
<h3 id="full-documentation-5">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.14/"><em>Docker Remote API v1.14</em></a></p>
|
||
|
||
<h3 id="what-s-new-5">What&rsquo;s new</h3>
|
||
|
||
<p><code>DELETE /containers/(id)</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
When using <code>force</code>, the container will be immediately killed with SIGKILL.</p>
|
||
|
||
<p><code>POST /containers/(id)/start</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
The <code>hostConfig</code> option now accepts the field <code>CapAdd</code>, which specifies a list of capabilities
|
||
to add, and the field <code>CapDrop</code>, which specifies a list of capabilities to drop.</p>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
The <code>fromImage</code> and <code>repo</code> parameters now supports the <code>repo:tag</code> format.
|
||
Consequently, the <code>tag</code> parameter is now obsolete. Using the new format and
|
||
the <code>tag</code> parameter at the same time will return an error.</p>
|
||
|
||
<h2 id="v1-13">v1.13</h2>
|
||
|
||
<h3 id="full-documentation-6">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.13/"><em>Docker Remote API v1.13</em></a></p>
|
||
|
||
<h3 id="what-s-new-6">What&rsquo;s new</h3>
|
||
|
||
<p><code>GET /containers/(name)/json</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
The <code>HostConfig.Links</code> field is now filled correctly</p>
|
||
|
||
<p><strong>New!</strong>
|
||
<code>Sockets</code> parameter added to the <code>/info</code> endpoint listing all the sockets the
|
||
daemon is configured to listen on.</p>
|
||
|
||
<p><code>POST /containers/(name)/start</code>
|
||
<code>POST /containers/(name)/stop</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
<code>start</code> and <code>stop</code> will now return 304 if the container&rsquo;s status is not modified</p>
|
||
|
||
<p><code>POST /commit</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
Added a <code>pause</code> parameter (default <code>true</code>) to pause the container during commit</p>
|
||
|
||
<h2 id="v1-12">v1.12</h2>
|
||
|
||
<h3 id="full-documentation-7">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.12/"><em>Docker Remote API v1.12</em></a></p>
|
||
|
||
<h3 id="what-s-new-7">What&rsquo;s new</h3>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
Build now has support for the <code>forcerm</code> parameter to always remove containers</p>
|
||
|
||
<p><code>GET /containers/(name)/json</code>
|
||
<code>GET /images/(name)/json</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
All the JSON keys are now in CamelCase</p>
|
||
|
||
<p><strong>New!</strong>
|
||
Trusted builds are now Automated Builds - <code>is_trusted</code> is now <code>is_automated</code>.</p>
|
||
|
||
<p><strong>Removed Insert Endpoint</strong>
|
||
The <code>insert</code> endpoint has been removed.</p>
|
||
|
||
<h2 id="v1-11">v1.11</h2>
|
||
|
||
<h3 id="full-documentation-8">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.11/"><em>Docker Remote API v1.11</em></a></p>
|
||
|
||
<h3 id="what-s-new-8">What&rsquo;s new</h3>
|
||
|
||
<p><code>GET /_ping</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can now ping the server via the <code>_ping</code> endpoint.</p>
|
||
|
||
<p><code>GET /events</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can now use the <code>-until</code> parameter to close connection
|
||
after timestamp.</p>
|
||
|
||
<p><code>GET /containers/(id)/logs</code></p>
|
||
|
||
<p>This url is preferred method for getting container logs now.</p>
|
||
|
||
<h2 id="v1-10">v1.10</h2>
|
||
|
||
<h3 id="full-documentation-9">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.10/"><em>Docker Remote API v1.10</em></a></p>
|
||
|
||
<h3 id="what-s-new-9">What&rsquo;s new</h3>
|
||
|
||
<p><code>DELETE /images/(name)</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can now use the force parameter to force delete of an
|
||
image, even if it&rsquo;s tagged in multiple repositories. <strong>New!</strong>
|
||
You
|
||
can now use the noprune parameter to prevent the deletion of parent
|
||
images</p>
|
||
|
||
<p><code>DELETE /containers/(id)</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can now use the force parameter to force delete a
|
||
container, even if it is currently running</p>
|
||
|
||
<h2 id="v1-9">v1.9</h2>
|
||
|
||
<h3 id="full-documentation-10">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.9/"><em>Docker Remote API v1.9</em></a></p>
|
||
|
||
<h3 id="what-s-new-10">What&rsquo;s new</h3>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
This endpoint now takes a serialized ConfigFile which it
|
||
uses to resolve the proper registry auth credentials for pulling the
|
||
base image. Clients which previously implemented the version
|
||
accepting an AuthConfig object must be updated.</p>
|
||
|
||
<h2 id="v1-8">v1.8</h2>
|
||
|
||
<h3 id="full-documentation-11">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.8/"><em>Docker Remote API v1.8</em></a></p>
|
||
|
||
<h3 id="what-s-new-11">What&rsquo;s new</h3>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
This endpoint now returns build status as json stream. In
|
||
case of a build error, it returns the exit status of the failed
|
||
command.</p>
|
||
|
||
<p><code>GET /containers/(id)/json</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
This endpoint now returns the host config for the
|
||
container.</p>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p><code>POST /images/(name)/insert</code></p>
|
||
|
||
<p><code>POST /images/(name)/push</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
progressDetail object was added in the JSON. It&rsquo;s now
|
||
possible to get the current value and the total of the progress
|
||
without having to parse the string.</p>
|
||
|
||
<h2 id="v1-7">v1.7</h2>
|
||
|
||
<h3 id="full-documentation-12">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.7/"><em>Docker Remote API v1.7</em></a></p>
|
||
|
||
<h3 id="what-s-new-12">What&rsquo;s new</h3>
|
||
|
||
<p><code>GET /images/json</code></p>
|
||
|
||
<p>The format of the json returned from this uri changed. Instead of an
|
||
entry for each repo/tag on an image, each image is only represented
|
||
once, with a nested attribute indicating the repo/tags that apply to
|
||
that image.</p>
|
||
|
||
<p>Instead of:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;VirtualSize&quot;: 131506275,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Tag&quot;: &quot;12.04&quot;,
|
||
&quot;Repository&quot;: &quot;ubuntu&quot;
|
||
},
|
||
{
|
||
&quot;VirtualSize&quot;: 131506275,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Tag&quot;: &quot;latest&quot;,
|
||
&quot;Repository&quot;: &quot;ubuntu&quot;
|
||
},
|
||
{
|
||
&quot;VirtualSize&quot;: 131506275,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Tag&quot;: &quot;precise&quot;,
|
||
&quot;Repository&quot;: &quot;ubuntu&quot;
|
||
},
|
||
{
|
||
&quot;VirtualSize&quot;: 180116135,
|
||
&quot;Size&quot;: 24653,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Tag&quot;: &quot;12.10&quot;,
|
||
&quot;Repository&quot;: &quot;ubuntu&quot;
|
||
},
|
||
{
|
||
&quot;VirtualSize&quot;: 180116135,
|
||
&quot;Size&quot;: 24653,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Tag&quot;: &quot;quantal&quot;,
|
||
&quot;Repository&quot;: &quot;ubuntu&quot;
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>The returned json looks like this:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.04&quot;,
|
||
&quot;ubuntu:precise&quot;,
|
||
&quot;ubuntu:latest&quot;
|
||
],
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;VirtualSize&quot;: 131506275
|
||
},
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.10&quot;,
|
||
&quot;ubuntu:quantal&quot;
|
||
],
|
||
&quot;ParentId&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;Size&quot;: 24653,
|
||
&quot;VirtualSize&quot;: 180116135
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p><code>GET /images/viz</code></p>
|
||
|
||
<p>This URI no longer exists. The <code>images --viz</code>
|
||
output is now generated in the client, using the
|
||
<code>/images/json</code> data.</p>
|
||
|
||
<h2 id="v1-6">v1.6</h2>
|
||
|
||
<h3 id="full-documentation-13">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.6/"><em>Docker Remote API v1.6</em></a></p>
|
||
|
||
<h3 id="what-s-new-13">What&rsquo;s new</h3>
|
||
|
||
<p><code>POST /containers/(id)/attach</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can now split stderr from stdout. This is done by
|
||
prefixing a header to each transmission. See
|
||
<a href="http://localhost/reference/api/docker_remote_api_v1.9/#attach-to-a-container &quot;POST /containers/(id"><code>POST /containers/(id)/attach</code></a>/attach&rdquo;).
|
||
The WebSocket attach is unchanged. Note that attach calls on the
|
||
previous API version didn&rsquo;t change. Stdout and stderr are merged.</p>
|
||
|
||
<h2 id="v1-5">v1.5</h2>
|
||
|
||
<h3 id="full-documentation-14">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.5/"><em>Docker Remote API v1.5</em></a></p>
|
||
|
||
<h3 id="what-s-new-14">What&rsquo;s new</h3>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can now pass registry credentials (via an AuthConfig
|
||
object) through the X-Registry-Auth header</p>
|
||
|
||
<p><code>POST /images/(name)/push</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
The AuthConfig object now needs to be passed through the
|
||
X-Registry-Auth header</p>
|
||
|
||
<p><code>GET /containers/json</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
The format of the Ports entry has been changed to a list of
|
||
dicts each containing PublicPort, PrivatePort and Type describing a
|
||
port mapping.</p>
|
||
|
||
<h2 id="v1-4">v1.4</h2>
|
||
|
||
<h3 id="full-documentation-15">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.4/"><em>Docker Remote API v1.4</em></a></p>
|
||
|
||
<h3 id="what-s-new-15">What&rsquo;s new</h3>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
When pulling a repo, all images are now downloaded in parallel.</p>
|
||
|
||
<p><code>GET /containers/(id)/top</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
You can now use ps args with docker top, like docker top
|
||
<container_id> aux</p>
|
||
|
||
<p><code>GET /events</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
Image&rsquo;s name added in the events</p>
|
||
|
||
<h2 id="v1-3">v1.3</h2>
|
||
|
||
<p>docker v0.5.0
|
||
<a href="https://github.com/docker/docker/commit/51f6c4a7372450d164c61e0054daf0223ddbd909">51f6c4a</a></p>
|
||
|
||
<h3 id="full-documentation-16">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.3/"><em>Docker Remote API v1.3</em></a></p>
|
||
|
||
<h3 id="what-s-new-16">What&rsquo;s new</h3>
|
||
|
||
<p><code>GET /containers/(id)/top</code></p>
|
||
|
||
<p>List the processes running inside a container.</p>
|
||
|
||
<p><code>GET /events</code></p>
|
||
|
||
<p><strong>New!</strong>
|
||
Monitor docker&rsquo;s events via streaming or via polling</p>
|
||
|
||
<p>Builder (/build):</p>
|
||
|
||
<ul>
|
||
<li>Simplify the upload of the build context</li>
|
||
<li>Simply stream a tarball instead of multipart upload with 4
|
||
intermediary buffers</li>
|
||
<li>Simpler, less memory usage, less disk usage and faster</li>
|
||
</ul>
|
||
|
||
<blockquote>
|
||
<p><strong>Warning</strong>:
|
||
The /build improvements are not reverse-compatible. Pre 1.3 clients will
|
||
break on /build.</p>
|
||
</blockquote>
|
||
|
||
<p>List containers (/containers/json):</p>
|
||
|
||
<ul>
|
||
<li>You can use size=1 to get the size of the containers</li>
|
||
</ul>
|
||
|
||
<p>Start containers (/containers/<id>/start):</p>
|
||
|
||
<ul>
|
||
<li>You can now pass host-specific configuration (e.g., bind mounts) in
|
||
the POST body for start calls</li>
|
||
</ul>
|
||
|
||
<h2 id="v1-2">v1.2</h2>
|
||
|
||
<p>docker v0.4.2
|
||
<a href="https://github.com/docker/docker/commit/2e7649beda7c820793bd46766cbc2cfeace7b168">2e7649b</a></p>
|
||
|
||
<h3 id="full-documentation-17">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.2/"><em>Docker Remote API v1.2</em></a></p>
|
||
|
||
<h3 id="what-s-new-17">What&rsquo;s new</h3>
|
||
|
||
<p>The auth configuration is now handled by the client.</p>
|
||
|
||
<p>The client should send it&rsquo;s authConfig as POST on each call of
|
||
<code>/images/(name)/push</code></p>
|
||
|
||
<p><code>GET /auth</code></p>
|
||
|
||
<p><strong>Deprecated.</strong></p>
|
||
|
||
<p><code>POST /auth</code></p>
|
||
|
||
<p>Only checks the configuration but doesn&rsquo;t store it on the server</p>
|
||
|
||
<pre><code>Deleting an image is now improved, will only untag the image if it
|
||
has children and remove all the untagged parents if has any.
|
||
</code></pre>
|
||
|
||
<p><code>POST /images/&lt;name&gt;/delete</code></p>
|
||
|
||
<p>Now returns a JSON structure with the list of images
|
||
deleted/untagged.</p>
|
||
|
||
<h2 id="v1-1">v1.1</h2>
|
||
|
||
<p>docker v0.4.0
|
||
<a href="https://github.com/docker/docker/commit/a8ae398bf52e97148ee7bd0d5868de2e15bd297f">a8ae398</a></p>
|
||
|
||
<h3 id="full-documentation-18">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.1/"><em>Docker Remote API v1.1</em></a></p>
|
||
|
||
<h3 id="what-s-new-18">What&rsquo;s new</h3>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p><code>POST /images/(name)/insert</code></p>
|
||
|
||
<p><code>POST /images/(name)/push</code></p>
|
||
|
||
<p>Uses json stream instead of HTML hijack, it looks like this:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;:&quot;Pushing...&quot;}
|
||
{&quot;status&quot;:&quot;Pushing&quot;, &quot;progress&quot;:&quot;1/? (n/a)&quot;}
|
||
{&quot;error&quot;:&quot;Invalid...&quot;}
|
||
...
|
||
</code></pre>
|
||
|
||
<h2 id="v1-0">v1.0</h2>
|
||
|
||
<p>docker v0.3.4
|
||
<a href="https://github.com/docker/docker/commit/8d73740343778651c09160cde9661f5f387b36f4">8d73740</a></p>
|
||
|
||
<h3 id="full-documentation-19">Full documentation</h3>
|
||
|
||
<p><a href="http://localhost/docker/reference/api/docker_remote_api_v1.0/"><em>Docker Remote API v1.0</em></a></p>
|
||
|
||
<h3 id="what-s-new-19">What&rsquo;s new</h3>
|
||
|
||
<p>Initial version</p>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Remote API client libraries</title>
|
||
<link>http://localhost/reference/api/remote_api_client_libraries/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/remote_api_client_libraries/</guid>
|
||
<description>
|
||
|
||
<h1 id="docker-remote-api-client-libraries">Docker Remote API client libraries</h1>
|
||
|
||
<p>These libraries have not been tested by the Docker maintainers for
|
||
compatibility. Please file issues with the library owners. If you find
|
||
more library implementations, please list them in Docker doc bugs and we
|
||
will add the libraries here.</p>
|
||
|
||
<table border="1" class="docutils">
|
||
<colgroup>
|
||
<col width="24%">
|
||
<col width="17%">
|
||
<col width="48%">
|
||
<col width="11%">
|
||
</colgroup>
|
||
<thead valign="bottom">
|
||
<tr class="row-odd"><th class="head">Language/Framework</th>
|
||
<th class="head">Name</th>
|
||
<th class="head">Repository</th>
|
||
<th class="head">Status</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody valign = "top">
|
||
<tr class="row-even">
|
||
<td>C#</td>
|
||
<td>Docker.DotNet</td>
|
||
<td><a class="reference external" href="https://github.com/ahmetalpbalkan/Docker.DotNet">https://github.com/ahmetalpbalkan/Docker.DotNet</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>C++</td>
|
||
<td>lasote/docker_client</td>
|
||
<td><a class="reference external" href="http://www.biicode.com/lasote/docker_client">http://www.biicode.com/lasote/docker_client (Biicode C++ dependency manager)</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>Erlang</td>
|
||
<td>erldocker</td>
|
||
<td><a class="reference external" href="https://github.com/proger/erldocker">https://github.com/proger/erldocker</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>Dart</td>
|
||
<td>bwu_docker</td>
|
||
<td><a class="reference external" href="https://github.com/bwu-dart/bwu_docker">https://github.com/bwu-dart/bwu_docker</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>Go</td>
|
||
<td>go-dockerclient</td>
|
||
<td><a class="reference external" href="https://github.com/fsouza/go-dockerclient">https://github.com/fsouza/go-dockerclient</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>Go</td>
|
||
<td>dockerclient</td>
|
||
<td><a class="reference external" href="https://github.com/samalba/dockerclient">https://github.com/samalba/dockerclient</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>Groovy</td>
|
||
<td>docker-client</td>
|
||
<td><a class="reference external" href="https://github.com/gesellix-docker/docker-client">https://github.com/gesellix-docker/docker-client</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>Haskell</td>
|
||
<td>docker-hs</td>
|
||
<td><a class="reference external" href="https://github.com/denibertovic/docker-hs">https://github.com/denibertovic/docker-hs</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>Java</td>
|
||
<td>docker-java</td>
|
||
<td><a class="reference external" href="https://github.com/docker-java/docker-java">https://github.com/docker-java/docker-java</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>Java</td>
|
||
<td>docker-client</td>
|
||
<td><a class="reference external" href="https://github.com/spotify/docker-client">https://github.com/spotify/docker-client</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>Java</td>
|
||
<td>jclouds-docker</td>
|
||
<td><a class="reference external" href="https://github.com/jclouds/jclouds-labs/tree/master/docker">https://github.com/jclouds/jclouds-labs/tree/master/docker</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>JavaScript (NodeJS)</td>
|
||
<td>dockerode</td>
|
||
<td><a class="reference external" href="https://github.com/apocas/dockerode">https://github.com/apocas/dockerode</a>
|
||
Install via NPM: <cite>npm install dockerode</cite></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>JavaScript (NodeJS)</td>
|
||
<td>docker.io</td>
|
||
<td><a class="reference external" href="https://github.com/appersonlabs/docker.io">https://github.com/appersonlabs/docker.io</a>
|
||
Install via NPM: <cite>npm install docker.io</cite></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>JavaScript</td>
|
||
<td>docker-js</td>
|
||
<td><a class="reference external" href="https://github.com/dgoujard/docker-js">https://github.com/dgoujard/docker-js</a></td>
|
||
<td>Outdated</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>JavaScript (Angular) <strong>WebUI</strong></td>
|
||
<td>docker-cp</td>
|
||
<td><a class="reference external" href="https://github.com/13W/docker-cp">https://github.com/13W/docker-cp</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>JavaScript (Angular) <strong>WebUI</strong></td>
|
||
<td>dockerui</td>
|
||
<td><a class="reference external" href="https://github.com/crosbymichael/dockerui">https://github.com/crosbymichael/dockerui</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>Perl</td>
|
||
<td>Net::Docker</td>
|
||
<td><a class="reference external" href="https://metacpan.org/pod/Net::Docker">https://metacpan.org/pod/Net::Docker</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>Perl</td>
|
||
<td>Eixo::Docker</td>
|
||
<td><a class="reference external" href="https://github.com/alambike/eixo-docker">https://github.com/alambike/eixo-docker</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>PHP</td>
|
||
<td>Alvine</td>
|
||
<td><a class="reference external" href="http://pear.alvine.io/">http://pear.alvine.io/</a> (alpha)</td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>PHP</td>
|
||
<td>Docker-PHP</td>
|
||
<td><a class="reference external" href="http://stage1.github.io/docker-php/">http://stage1.github.io/docker-php/</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>Python</td>
|
||
<td>docker-py</td>
|
||
<td><a class="reference external" href="https://github.com/docker/docker-py">https://github.com/docker/docker-py</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>Ruby</td>
|
||
<td>docker-api</td>
|
||
<td><a class="reference external" href="https://github.com/swipely/docker-api">https://github.com/swipely/docker-api</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>Ruby</td>
|
||
<td>docker-client</td>
|
||
<td><a class="reference external" href="https://github.com/geku/docker-client">https://github.com/geku/docker-client</a></td>
|
||
<td>Outdated</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>Rust</td>
|
||
<td>docker-rust</td>
|
||
<td><a class="reference external" href="https://github.com/abh1nav/docker-rust">https://github.com/abh1nav/docker-rust</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-odd">
|
||
<td>Scala</td>
|
||
<td>tugboat</td>
|
||
<td><a class="reference external" href="https://github.com/softprops/tugboat">https://github.com/softprops/tugboat</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
<tr class="row-even">
|
||
<td>Scala</td>
|
||
<td>reactive-docker</td>
|
||
<td><a class="reference external" href="https://github.com/almoehi/reactive-docker">https://github.com/almoehi/reactive-docker</a></td>
|
||
<td>Active</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Remote API v1.14</title>
|
||
<link>http://localhost/reference/api/docker_remote_api_v1.14/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/docker_remote_api_v1.14/</guid>
|
||
<description>
|
||
|
||
<h1 id="docker-remote-api-v1-14">Docker Remote API v1.14</h1>
|
||
|
||
<h2 id="1-brief-introduction">1. Brief introduction</h2>
|
||
|
||
<ul>
|
||
<li>The Remote API has replaced <code>rcli</code>.</li>
|
||
<li>The daemon listens on <code>unix:///var/run/docker.sock</code> but you can
|
||
<a href="http://localhost/articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket">Bind Docker to another host/port or a Unix socket</a>.</li>
|
||
<li>The API tends to be REST, but for some complex commands, like <code>attach</code>
|
||
or <code>pull</code>, the HTTP connection is hijacked to transport <code>STDOUT</code>,
|
||
<code>STDIN</code> and <code>STDERR</code>.</li>
|
||
</ul>
|
||
|
||
<h1 id="2-endpoints">2. Endpoints</h1>
|
||
|
||
<h2 id="2-1-containers">2.1 Containers</h2>
|
||
|
||
<h3 id="list-containers">List containers</h3>
|
||
|
||
<p><code>GET /containers/json</code></p>
|
||
|
||
<p>List containers</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/json?all=1&amp;before=8dfafdbc3a40&amp;size=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;8dfafdbc3a40&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 1&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [{&quot;PrivatePort&quot;: 2222, &quot;PublicPort&quot;: 3333, &quot;Type&quot;: &quot;tcp&quot;}],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;9cd87474be90&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 222222&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;3176a2479c92&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 3333333333333333&quot;,
|
||
&quot;Created&quot;: 1367854154,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;:[],
|
||
&quot;SizeRw&quot;:12288,
|
||
&quot;SizeRootFs&quot;:0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;4cb07b47f9fb&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 444444444444444444444444444444444&quot;,
|
||
&quot;Created&quot;: 1367854152,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, Show all containers.
|
||
Only running containers are shown by default (i.e., this defaults to false)</li>
|
||
<li><strong>limit</strong> – Show <code>limit</code> last created containers, include non-running ones.</li>
|
||
<li><strong>since</strong> – Show only containers created since Id, include non-running ones.</li>
|
||
<li><strong>before</strong> – Show only containers created before Id, include non-running ones.</li>
|
||
<li><strong>size</strong> – 1/True/true or 0/False/false, Show the containers sizes</li>
|
||
<li><strong>filters</strong> - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
|
||
|
||
<ul>
|
||
<li>exited=&lt;int&gt; &ndash; containers with exit code of &lt;int&gt;</li>
|
||
<li>status=(restarting|running|paused|exited)</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-container">Create a container</h3>
|
||
|
||
<p><code>POST /containers/create</code></p>
|
||
|
||
<p>Create a container</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/create HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;:&quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;:&quot;&quot;,
|
||
&quot;Memory&quot;:0,
|
||
&quot;MemorySwap&quot;:0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;Cpuset&quot;: &quot;0,1&quot;,
|
||
&quot;AttachStdin&quot;:false,
|
||
&quot;AttachStdout&quot;:true,
|
||
&quot;AttachStderr&quot;:true,
|
||
&quot;PortSpecs&quot;:null,
|
||
&quot;Tty&quot;:false,
|
||
&quot;OpenStdin&quot;:false,
|
||
&quot;StdinOnce&quot;:false,
|
||
&quot;Env&quot;:null,
|
||
&quot;Cmd&quot;:[
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Image&quot;:&quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;:{
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;:&quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;ExposedPorts&quot;:{
|
||
&quot;22/tcp&quot;: {}
|
||
},
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;always&quot; }
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;:&quot;e90e34656806&quot;
|
||
&quot;Warnings&quot;:[]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>config</strong> – the container&rsquo;s configuration</li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>name</strong> – Assign the specified name to the container. Must match <code>/?[a-zA-Z0-9_-]+</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>406</strong> – impossible to attach (container not running)</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-a-container">Inspect a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/json</code></p>
|
||
|
||
<p>Return low-level information on the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;: &quot;4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2&quot;,
|
||
&quot;Created&quot;: &quot;2013-05-07T14:51:42.041847+02:00&quot;,
|
||
&quot;Path&quot;: &quot;date&quot;,
|
||
&quot;Args&quot;: [],
|
||
&quot;Config&quot;: {
|
||
&quot;Hostname&quot;: &quot;4fa6e0f0c678&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Dns&quot;: null,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: {},
|
||
&quot;VolumesFrom&quot;: &quot;&quot;,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;State&quot;: {
|
||
&quot;Running&quot;: false,
|
||
&quot;Pid&quot;: 0,
|
||
&quot;ExitCode&quot;: 0,
|
||
&quot;StartedAt&quot;: &quot;2013-05-07T14:51:42.087658+02:01360&quot;,
|
||
&quot;Ghost&quot;: false
|
||
},
|
||
&quot;Image&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;NetworkSettings&quot;: {
|
||
&quot;IpAddress&quot;: &quot;&quot;,
|
||
&quot;IpPrefixLen&quot;: 0,
|
||
&quot;Gateway&quot;: &quot;&quot;,
|
||
&quot;Bridge&quot;: &quot;&quot;,
|
||
&quot;PortMapping&quot;: null
|
||
},
|
||
&quot;SysInitPath&quot;: &quot;/home/kitty/go/src/github.com/docker/docker/bin/docker&quot;,
|
||
&quot;ResolvConfPath&quot;: &quot;/etc/resolv.conf&quot;,
|
||
&quot;Volumes&quot;: {},
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: null,
|
||
&quot;ContainerIDFile&quot;: &quot;&quot;,
|
||
&quot;LxcConf&quot;: [],
|
||
&quot;Privileged&quot;: false,
|
||
&quot;PortBindings&quot;: {
|
||
&quot;80/tcp&quot;: [
|
||
{
|
||
&quot;HostIp&quot;: &quot;0.0.0.0&quot;,
|
||
&quot;HostPort&quot;: &quot;49153&quot;
|
||
}
|
||
]
|
||
},
|
||
&quot;Links&quot;: [&quot;/name:alias&quot;],
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;]
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="list-processes-running-inside-a-container">List processes running inside a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/top</code></p>
|
||
|
||
<p>List processes running inside the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/top HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Titles&quot;: [
|
||
&quot;USER&quot;,
|
||
&quot;PID&quot;,
|
||
&quot;%CPU&quot;,
|
||
&quot;%MEM&quot;,
|
||
&quot;VSZ&quot;,
|
||
&quot;RSS&quot;,
|
||
&quot;TTY&quot;,
|
||
&quot;STAT&quot;,
|
||
&quot;START&quot;,
|
||
&quot;TIME&quot;,
|
||
&quot;COMMAND&quot;
|
||
],
|
||
&quot;Processes&quot;: [
|
||
[&quot;root&quot;,&quot;20147&quot;,&quot;0.0&quot;,&quot;0.1&quot;,&quot;18060&quot;,&quot;1864&quot;,&quot;pts/4&quot;,&quot;S&quot;,&quot;10:06&quot;,&quot;0:00&quot;,&quot;bash&quot;],
|
||
[&quot;root&quot;,&quot;20271&quot;,&quot;0.0&quot;,&quot;0.0&quot;,&quot;4312&quot;,&quot;352&quot;,&quot;pts/4&quot;,&quot;S+&quot;,&quot;10:07&quot;,&quot;0:00&quot;,&quot;sleep&quot;,&quot;10&quot;]
|
||
]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>ps_args</strong> – ps arguments to use (e.g., aux)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-container-logs">Get container logs</h3>
|
||
|
||
<p><code>GET /containers/(id)/logs</code></p>
|
||
|
||
<p>Get stdout and stderr logs from the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/logs?stderr=1&amp;stdout=1&amp;timestamps=1&amp;follow=1&amp;tail=10 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>follow</strong> – 1/True/true or 0/False/false, return stream. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, show stdout log. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, show stderr log. Default false</li>
|
||
<li><strong>timestamps</strong> – 1/True/true or 0/False/false, print timestamps for every
|
||
log line. Default false</li>
|
||
<li><strong>tail</strong> – Output specified number of lines at the end of logs: <code>all</code> or
|
||
<code>&lt;number&gt;</code>. Default all</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-changes-on-a-container-s-filesystem">Inspect changes on a container&rsquo;s filesystem</h3>
|
||
|
||
<p><code>GET /containers/(id)/changes</code></p>
|
||
|
||
<p>Inspect changes on container <code>id</code>&rsquo;s filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/changes HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Path&quot;: &quot;/dev&quot;,
|
||
&quot;Kind&quot;: 0
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/dev/kmsg&quot;,
|
||
&quot;Kind&quot;: 1
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/test&quot;,
|
||
&quot;Kind&quot;: 1
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="export-a-container">Export a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/export</code></p>
|
||
|
||
<p>Export the contents of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/export HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/octet-stream
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="start-a-container">Start a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/start</code></p>
|
||
|
||
<p>Start the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/(id)/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Binds&quot;:[&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;:[&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;:[{&quot;Key&quot;:&quot;lxc.utsname&quot;,&quot;Value&quot;:&quot;docker&quot;}],
|
||
&quot;PortBindings&quot;:{ &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;:false,
|
||
&quot;Privileged&quot;:false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;]
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>hostConfig</strong> – the container&rsquo;s host configuration (optional)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already started</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="stop-a-container">Stop a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/stop</code></p>
|
||
|
||
<p>Stop the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/stop?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already stopped</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="restart-a-container">Restart a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/restart</code></p>
|
||
|
||
<p>Restart the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/restart?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="kill-a-container">Kill a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/kill</code></p>
|
||
|
||
<p>Kill the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/kill HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters</p>
|
||
|
||
<ul>
|
||
<li><strong>signal</strong> - Signal to send to the container: integer or string like &ldquo;SIGINT&rdquo;.
|
||
When not set, SIGKILL is assumed and the call will wait for the container to exit.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="pause-a-container">Pause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/pause</code></p>
|
||
|
||
<p>Pause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/pause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="unpause-a-container">Unpause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/unpause</code></p>
|
||
|
||
<p>Unpause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/unpause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container">Attach to a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/attach</code></p>
|
||
|
||
<p>Attach to the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/attach?logs=1&amp;stream=0&amp;stdout=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream. Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach to stdin.
|
||
Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
|
||
<li><p><strong>500</strong> – server error</p>
|
||
|
||
<p><strong>Stream details</strong>:</p>
|
||
|
||
<p>When using the TTY setting is enabled in
|
||
<a href="http://localhost/docker/reference/api/docker_remote_api_v1.9/#create-a-container" title="POST /containers/create"><code>POST /containers/create</code>
|
||
</a>,
|
||
the stream is the raw data from the process PTY and client&rsquo;s stdin.
|
||
When the TTY is disabled, then the stream is multiplexed to separate
|
||
stdout and stderr.</p>
|
||
|
||
<p>The format is a <strong>Header</strong> and a <strong>Payload</strong> (frame).</p>
|
||
|
||
<p><strong>HEADER</strong></p>
|
||
|
||
<p>The header will contain the information on which stream write the
|
||
stream (stdout or stderr). It also contain the size of the
|
||
associated frame encoded on the last 4 bytes (uint32).</p>
|
||
|
||
<p>It is encoded on the first 8 bytes like this:</p>
|
||
|
||
<pre><code>header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
|
||
</code></pre>
|
||
|
||
<p><code>STREAM_TYPE</code> can be:</p></li>
|
||
|
||
<li><p>0: stdin (will be written on stdout)</p></li>
|
||
|
||
<li><p>1: stdout</p></li>
|
||
|
||
<li><p>2: stderr</p>
|
||
|
||
<p><code>SIZE1, SIZE2, SIZE3, SIZE4</code> are the 4 bytes of
|
||
the uint32 size encoded as big endian.</p>
|
||
|
||
<p><strong>PAYLOAD</strong></p>
|
||
|
||
<p>The payload is the raw stream.</p>
|
||
|
||
<p><strong>IMPLEMENTATION</strong></p>
|
||
|
||
<p>The simplest way to implement the Attach protocol is the following:</p>
|
||
|
||
<ol>
|
||
<li>Read 8 bytes</li>
|
||
<li>chose stdout or stderr depending on the first byte</li>
|
||
<li>Extract the frame size from the last 4 bytes</li>
|
||
<li>Read the extracted size and output it on the correct output</li>
|
||
<li>Goto 1</li>
|
||
</ol></li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container-websocket">Attach to a container (websocket)</h3>
|
||
|
||
<p><code>GET /containers/(id)/attach/ws</code></p>
|
||
|
||
<p>Attach to the container <code>id</code> via websocket</p>
|
||
|
||
<p>Implements websocket protocol handshake according to <a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a></p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /containers/e90e34656806/attach/ws?logs=0&amp;stream=1&amp;stdin=1&amp;stdout=1&amp;stderr=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong></p>
|
||
|
||
<pre><code> {{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach
|
||
to stdin. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="wait-a-container">Wait a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/wait</code></p>
|
||
|
||
<p>Block until container <code>id</code> stops, then returns the exit code</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/wait HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;StatusCode&quot;: 0}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-a-container">Remove a container</h3>
|
||
|
||
<p><code>DELETE /containers/(id)</code></p>
|
||
|
||
<p>Remove the container <code>id</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /containers/16253994b7c4?v=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>v</strong> – 1/True/true or 0/False/false, Remove the volumes
|
||
associated to the container. Default false</li>
|
||
<li><strong>force</strong> - 1/True/true or 0/False/false, Kill then remove the container.
|
||
Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="copy-files-or-folders-from-a-container">Copy files or folders from a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/copy</code></p>
|
||
|
||
<p>Copy files or folders of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/4fa6e0f0c678/copy HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Resource&quot;: &quot;test.txt&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/octet-stream
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-2-images">2.2 Images</h2>
|
||
|
||
<h3 id="list-images">List Images</h3>
|
||
|
||
<p><code>GET /images/json</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/json?all=0 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.04&quot;,
|
||
&quot;ubuntu:precise&quot;,
|
||
&quot;ubuntu:latest&quot;
|
||
],
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;VirtualSize&quot;: 131506275
|
||
},
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.10&quot;,
|
||
&quot;ubuntu:quantal&quot;
|
||
],
|
||
&quot;ParentId&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;Size&quot;: 24653,
|
||
&quot;VirtualSize&quot;: 180116135
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>filters</strong> – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
|
||
|
||
<ul>
|
||
<li>dangling=true</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<h3 id="create-an-image">Create an image</h3>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p>Create an image, either by pulling it from the registry or by importing it</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/create?fromImage=ubuntu HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pulling...&quot;}
|
||
{&quot;status&quot;: &quot;Pulling&quot;, &quot;progress&quot;: &quot;1 B/ 100 B&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1, &quot;total&quot;: 100}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
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.
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>fromImage</strong> – name of the image to pull</li>
|
||
<li><strong>fromSrc</strong> – source to import, - means stdin</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
<li><strong>registry</strong> – the registry to pull from</li>
|
||
</ul>
|
||
|
||
<p>Request Headers:</p>
|
||
|
||
<ul>
|
||
<li><strong>X-Registry-Auth</strong> – base64-encoded AuthConfig object</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-an-image">Inspect an image</h3>
|
||
|
||
<p><code>GET /images/(name)/json</code></p>
|
||
|
||
<p>Return low-level information on the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Created&quot;: &quot;2013-03-23T22:24:18.818426-07:00&quot;,
|
||
&quot;Container&quot;: &quot;3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0&quot;,
|
||
&quot;ContainerConfig&quot;:
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: false,
|
||
&quot;AttachStderr&quot;: false,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: true,
|
||
&quot;OpenStdin&quot;: true,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [&quot;/bin/bash&quot;],
|
||
&quot;Dns&quot;: null,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: null,
|
||
&quot;VolumesFrom&quot;: &quot;&quot;,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Parent&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Size&quot;: 6824592
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-the-history-of-an-image">Get the history of an image</h3>
|
||
|
||
<p><code>GET /images/(name)/history</code></p>
|
||
|
||
<p>Return the history of the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/history HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;b750fe79269d&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;CreatedBy&quot;: &quot;/bin/bash&quot;
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;27cf78414709&quot;,
|
||
&quot;Created&quot;: 1364068391,
|
||
&quot;CreatedBy&quot;: &quot;&quot;
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="push-an-image-on-the-registry">Push an image on the registry</h3>
|
||
|
||
<p><code>POST /images/(name)/push</code></p>
|
||
|
||
<p>Push the image <code>name</code> on the registry</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pushing...&quot;}
|
||
{&quot;status&quot;: &quot;Pushing&quot;, &quot;progress&quot;: &quot;1/? (n/a)&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1}}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
If you wish to push an image on to a private registry, that image must already have been tagged
|
||
into a repository which references that registry host name and port. This repository name should
|
||
then be used in the URL. This mirrors the flow of the CLI.
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/registry.acme.com:5000/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>tag</strong> – the tag to associate with the image on the registry, optional</li>
|
||
</ul>
|
||
|
||
<p>Request Headers:</p>
|
||
|
||
<ul>
|
||
<li><strong>X-Registry-Auth</strong> – include a base64-encoded AuthConfig object.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="tag-an-image-into-a-repository">Tag an image into a repository</h3>
|
||
|
||
<p><code>POST /images/(name)/tag</code></p>
|
||
|
||
<p>Tag the image <code>name</code> into a repository</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/tag?repo=myrepo&amp;force=0&amp;tag=v42 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo</strong> – The repository to tag in</li>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>tag</strong> - The new tag name</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-an-image">Remove an image</h3>
|
||
|
||
<p><code>DELETE /images/(name)</code></p>
|
||
|
||
<p>Remove the image <code>name</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /images/test HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-type: application/json
|
||
|
||
[
|
||
{&quot;Untagged&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;53b4f83ac9&quot;}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>noprune</strong> – 1/True/true or 0/False/false, default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="search-images">Search images</h3>
|
||
|
||
<p><code>GET /images/search</code></p>
|
||
|
||
<p>Search for an image on <a href="https://hub.docker.com">Docker Hub</a>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
The response keys have changed from API v1.6 to reflect the JSON
|
||
sent by the registry server to the docker daemon&rsquo;s request.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/search?term=sshd HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;wma55/u1210sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;jdswinbank/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;vgauthier/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
}
|
||
...
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>term</strong> – term to search</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-3-misc">2.3 Misc</h2>
|
||
|
||
<h3 id="build-an-image-from-dockerfile-via-stdin">Build an image from Dockerfile via stdin</h3>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p>Build an image from Dockerfile via stdin</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /build HTTP/1.1
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;stream&quot;: &quot;Step 1...&quot;}
|
||
{&quot;stream&quot;: &quot;...&quot;}
|
||
{&quot;error&quot;: &quot;Error...&quot;, &quot;errorDetail&quot;: {&quot;code&quot;: 123, &quot;message&quot;: &quot;Error...&quot;}}
|
||
|
||
The stream must be a tar archive compressed with one of the
|
||
following algorithms: identity (no compression), gzip, bzip2, xz.
|
||
|
||
The archive must include a file called `Dockerfile`
|
||
at its root. It may include any number of other files,
|
||
which will be accessible in the build context (See the [*ADD build
|
||
command*](/docker/reference/builder/#dockerbuilder)).
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – repository name (and optionally a tag) to be applied to
|
||
the resulting image in case of success</li>
|
||
<li><strong>remote</strong> – git or HTTP/HTTPS URI build source</li>
|
||
<li><strong>q</strong> – suppress verbose build output</li>
|
||
<li><strong>nocache</strong> – do not use the cache when building the image</li>
|
||
<li><strong>rm</strong> - remove intermediate containers after a successful build (default behavior)</li>
|
||
|
||
<li><p><strong>forcerm</strong> - always remove intermediate containers (includes rm)</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>Content-type</strong> – should be set to <code>&quot;application/tar&quot;</code>.</p></li>
|
||
|
||
<li><p><strong>X-Registry-Config</strong> – base64-encoded ConfigFile object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="check-auth-configuration">Check auth configuration</h3>
|
||
|
||
<p><code>POST /auth</code></p>
|
||
|
||
<p>Get the default username and email</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /auth HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;username&quot;:&quot; hannibal&quot;,
|
||
&quot;password: &quot;xxxx&quot;,
|
||
&quot;email&quot;: &quot;hannibal@a-team.com&quot;,
|
||
&quot;serveraddress&quot;: &quot;https://index.docker.io/v1/&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="display-system-wide-information">Display system-wide information</h3>
|
||
|
||
<p><code>GET /info</code></p>
|
||
|
||
<p>Display system-wide information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /info HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Containers&quot;: 11,
|
||
&quot;Images&quot;: 16,
|
||
&quot;Driver&quot;: &quot;btrfs&quot;,
|
||
&quot;ExecutionDriver&quot;: &quot;native-0.1&quot;,
|
||
&quot;KernelVersion&quot;: &quot;3.12.0-1-amd64&quot;
|
||
&quot;Debug&quot;: false,
|
||
&quot;NFd&quot;: 11,
|
||
&quot;NGoroutines&quot;: 21,
|
||
&quot;NEventsListener&quot;: 0,
|
||
&quot;InitPath&quot;: &quot;/usr/bin/docker&quot;,
|
||
&quot;IndexServerAddress&quot;: [&quot;https://index.docker.io/v1/&quot;],
|
||
&quot;MemoryLimit&quot;: true,
|
||
&quot;SwapLimit&quot;: false,
|
||
&quot;IPv4Forwarding&quot;: true
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="show-the-docker-version-information">Show the docker version information</h3>
|
||
|
||
<p><code>GET /version</code></p>
|
||
|
||
<p>Show the docker version information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /version HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;ApiVersion&quot;: &quot;1.12&quot;,
|
||
&quot;Version&quot;: &quot;0.2.2&quot;,
|
||
&quot;GitCommit&quot;: &quot;5a2a5cc+CHANGES&quot;,
|
||
&quot;GoVersion&quot;: &quot;go1.0.3&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="ping-the-docker-server">Ping the docker server</h3>
|
||
|
||
<p><code>GET /_ping</code></p>
|
||
|
||
<p>Ping the docker server</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /_ping HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: text/plain
|
||
|
||
OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> - no error</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-new-image-from-a-container-s-changes">Create a new image from a container&rsquo;s changes</h3>
|
||
|
||
<p><code>POST /commit</code></p>
|
||
|
||
<p>Create a new image from a container&rsquo;s changes</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /commit?container=44c004db4b17&amp;comment=message&amp;repo=myrepo HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;Cpuset&quot;: &quot;0,1&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{&quot;Id&quot;: &quot;596069db4bf5&quot;}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>config</strong> - the container&rsquo;s configuration</li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>container</strong> – source container</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
<li><strong>comment</strong> – commit message</li>
|
||
<li><strong>author</strong> – author (e.g., &ldquo;John Hannibal Smith
|
||
&lt;<a href="mailto:hannibal%40a-team.com">hannibal@a-team.com</a>&gt;&ldquo;)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="monitor-docker-s-events">Monitor Docker&rsquo;s events</h3>
|
||
|
||
<p><code>GET /events</code></p>
|
||
|
||
<p>Get container events from docker, either in real time via streaming, or via
|
||
polling (using since).</p>
|
||
|
||
<p>Docker containers will report the following events:</p>
|
||
|
||
<pre><code>create, destroy, die, export, kill, pause, restart, start, stop, unpause
|
||
</code></pre>
|
||
|
||
<p>and Docker images will report:</p>
|
||
|
||
<pre><code>untag, delete
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /events?since=1374067924
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;create&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;start&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;stop&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067966}
|
||
{&quot;status&quot;: &quot;destroy&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067970}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>since</strong> – timestamp used for polling</li>
|
||
<li><strong>until</strong> – timestamp used for polling</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images-and-tags-in-a-repository">Get a tarball containing all images and tags in a repository</h3>
|
||
|
||
<p><code>GET /images/(name)/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for the repository
|
||
specified by <code>name</code>.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /images/ubuntu/get
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="load-a-tarball-with-a-set-of-images-and-tags-into-docker">Load a tarball with a set of images and tags into docker</h3>
|
||
|
||
<p><code>POST /images/load</code></p>
|
||
|
||
<p>Load a set of images and tags into the docker repository.
|
||
See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> POST /images/load
|
||
|
||
Tarball in body
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="image-tarball-format">Image tarball format</h3>
|
||
|
||
<p>An image tarball contains one directory per image layer (named using its long ID),
|
||
each containing three files:</p>
|
||
|
||
<ol>
|
||
<li><code>VERSION</code>: currently <code>1.0</code> - the file format version</li>
|
||
<li><code>json</code>: detailed layer information, similar to <code>docker inspect layer_id</code></li>
|
||
<li><code>layer.tar</code>: A tarfile containing the filesystem changes in this layer</li>
|
||
</ol>
|
||
|
||
<p>The <code>layer.tar</code> file will contain <code>aufs</code> style <code>.wh..wh.aufs</code> files and directories
|
||
for storing attribute changes and deletions.</p>
|
||
|
||
<p>If the tarball defines a repository, there will also be a <code>repositories</code> file at
|
||
the root that contains a list of repository and tag names mapped to layer IDs.</p>
|
||
|
||
<pre><code>{&quot;hello-world&quot;:
|
||
{&quot;latest&quot;: &quot;565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1&quot;}
|
||
}
|
||
</code></pre>
|
||
|
||
<h1 id="3-going-further">3. Going further</h1>
|
||
|
||
<h2 id="3-1-inside-docker-run">3.1 Inside <code>docker run</code></h2>
|
||
|
||
<p>As an example, the <code>docker run</code> command line makes the following API calls:</p>
|
||
|
||
<ul>
|
||
<li><p>Create the container</p></li>
|
||
|
||
<li><p>If the status code is 404, it means the image doesn&rsquo;t exist:</p>
|
||
|
||
<ul>
|
||
<li>Try to pull it</li>
|
||
<li>Then retry to create the container</li>
|
||
</ul></li>
|
||
|
||
<li><p>Start the container</p></li>
|
||
|
||
<li><p>If you are not in detached mode:</p>
|
||
|
||
<ul>
|
||
<li>Attach to the container, using logs=1 (to have stdout and
|
||
stderr from the container&rsquo;s start) and stream=1</li>
|
||
</ul></li>
|
||
|
||
<li><p>If in detached mode or only stdin is attached:</p>
|
||
|
||
<ul>
|
||
<li>Display the container&rsquo;s id</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<h2 id="3-2-hijacking">3.2 Hijacking</h2>
|
||
|
||
<p>In this version of the API, /attach, uses hijacking to transport stdin,
|
||
stdout and stderr on the same socket. This might change in the future.</p>
|
||
|
||
<h2 id="3-3-cors-requests">3.3 CORS Requests</h2>
|
||
|
||
<p>To enable cross origin requests to the remote api add the flag
|
||
&ldquo;&ndash;api-enable-cors&rdquo; when running docker in daemon mode.</p>
|
||
|
||
<pre><code>$ docker -d -H=&quot;192.168.1.9:2375&quot; --api-enable-cors
|
||
</code></pre>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Remote API v1.15</title>
|
||
<link>http://localhost/reference/api/docker_remote_api_v1.15/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/docker_remote_api_v1.15/</guid>
|
||
<description>
|
||
|
||
<h1 id="docker-remote-api-v1-15">Docker Remote API v1.15</h1>
|
||
|
||
<h2 id="1-brief-introduction">1. Brief introduction</h2>
|
||
|
||
<ul>
|
||
<li>The Remote API has replaced <code>rcli</code>.</li>
|
||
<li>The daemon listens on <code>unix:///var/run/docker.sock</code> but you can
|
||
<a href="http://localhost/articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket">Bind Docker to another host/port or a Unix socket</a>.</li>
|
||
<li>The API tends to be REST, but for some complex commands, like <code>attach</code>
|
||
or <code>pull</code>, the HTTP connection is hijacked to transport <code>STDOUT</code>,
|
||
<code>STDIN</code> and <code>STDERR</code>.</li>
|
||
</ul>
|
||
|
||
<h1 id="2-endpoints">2. Endpoints</h1>
|
||
|
||
<h2 id="2-1-containers">2.1 Containers</h2>
|
||
|
||
<h3 id="list-containers">List containers</h3>
|
||
|
||
<p><code>GET /containers/json</code></p>
|
||
|
||
<p>List containers</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/json?all=1&amp;before=8dfafdbc3a40&amp;size=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;8dfafdbc3a40&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 1&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [{&quot;PrivatePort&quot;: 2222, &quot;PublicPort&quot;: 3333, &quot;Type&quot;: &quot;tcp&quot;}],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;9cd87474be90&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 222222&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;3176a2479c92&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 3333333333333333&quot;,
|
||
&quot;Created&quot;: 1367854154,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;:[],
|
||
&quot;SizeRw&quot;:12288,
|
||
&quot;SizeRootFs&quot;:0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;4cb07b47f9fb&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 444444444444444444444444444444444&quot;,
|
||
&quot;Created&quot;: 1367854152,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, Show all containers.
|
||
Only running containers are shown by default (i.e., this defaults to false)</li>
|
||
<li><strong>limit</strong> – Show <code>limit</code> last created
|
||
containers, include non-running ones.</li>
|
||
<li><strong>since</strong> – Show only containers created since Id, include
|
||
non-running ones.</li>
|
||
<li><strong>before</strong> – Show only containers created before Id, include
|
||
non-running ones.</li>
|
||
<li><strong>size</strong> – 1/True/true or 0/False/false, Show the containers
|
||
sizes</li>
|
||
<li><strong>filters</strong> - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
|
||
|
||
<ul>
|
||
<li>exited=&lt;int&gt; &ndash; containers with exit code of &lt;int&gt;</li>
|
||
<li>status=(restarting|running|paused|exited)</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-container">Create a container</h3>
|
||
|
||
<p><code>POST /containers/create</code></p>
|
||
|
||
<p>Create a container</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/create HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;Cpuset&quot;: &quot;0,1&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Entrypoint&quot;: &quot;&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;MacAddress&quot;: &quot;12:34:56:78:9a:bc&quot;,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
},
|
||
&quot;SecurityOpts&quot;: [&quot;&quot;],
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: []
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;: &quot;f91ddc4b01e079c4481a8340bbbeca4dbd33d6e4a10662e499f8eacbb5bf252b&quot;
|
||
&quot;Warnings&quot;: []
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Hostname</strong> - A string value containing the desired hostname to use for the
|
||
container.</li>
|
||
<li><strong>Domainname</strong> - A string value containing the desired domain name to use
|
||
for the container.</li>
|
||
<li><strong>User</strong> - A string value containing the user to use inside the container.</li>
|
||
<li><strong>Memory</strong> - Memory limit in bytes.</li>
|
||
<li><strong>MemorySwap</strong>- Total memory usage (memory + swap); set <code>-1</code> to disable swap.</li>
|
||
<li><strong>CpuShares</strong> - An integer value containing the CPU Shares for container
|
||
(ie. the relative weight vs other containers).
|
||
<strong>CpuSet</strong> - String value containing the cgroups Cpuset to use.</li>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to stdin.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to stdout.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to stderr.</li>
|
||
<li><strong>Tty</strong> - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.</li>
|
||
<li><strong>OpenStdin</strong> - Boolean value, opens stdin,</li>
|
||
<li><strong>StdinOnce</strong> - Boolean value, close stdin after the 1 attached client disconnects.</li>
|
||
<li><strong>Env</strong> - A list of environment variables in the form of <code>VAR=value</code></li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
<li><strong>Entrypoint</strong> - Set the entrypoint for the container a a string or an array
|
||
of strings</li>
|
||
<li><strong>Image</strong> - String value containing the image name to use for the container</li>
|
||
<li><strong>Volumes</strong> – An object mapping mountpoint paths (strings) inside the
|
||
container to empty objects.</li>
|
||
<li><strong>WorkingDir</strong> - A string value containing the working dir for commands to
|
||
run in.</li>
|
||
<li><strong>NetworkDisabled</strong> - Boolean value, when true disables networking for the
|
||
container</li>
|
||
<li><strong>ExposedPorts</strong> - An object mapping ports to an empty object in the form of:
|
||
<code>&quot;ExposedPorts&quot;: { &quot;&lt;port&gt;/&lt;tcp|udp&gt;: {}&quot; }</code></li>
|
||
<li><strong>SecurityOpts</strong>: A list of string values to customize labels for MLS
|
||
systems, such as SELinux.</li>
|
||
<li><strong>HostConfig</strong>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume
|
||
binding is a string of the form <code>container_path</code> (to create a new
|
||
volume for the container), <code>host_path:container_path</code> (to bind-mount
|
||
a host path into the container), or <code>host_path:container_path:ro</code>
|
||
(to make the bind-mount read-only inside the container).</li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be
|
||
in the form of &ldquo;container_name:alias&rdquo;.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations will only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. It should be specified in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of dns servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains</li>
|
||
<li><strong>ExtraHosts</strong> - A list of hostnames/IP mappings to be added to the
|
||
container&rsquo;s <code>/etc/hosts</code> file. Specified in the form <code>[&quot;hostname:IP&quot;]</code>.</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>name</strong> – Assign the specified name to the container. Must
|
||
match <code>/?[a-zA-Z0-9_-]+</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>406</strong> – impossible to attach (container not running)</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-a-container">Inspect a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/json</code></p>
|
||
|
||
<p>Return low-level information on the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;: &quot;4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2&quot;,
|
||
&quot;Created&quot;: &quot;2013-05-07T14:51:42.041847+02:00&quot;,
|
||
&quot;Path&quot;: &quot;date&quot;,
|
||
&quot;Args&quot;: [],
|
||
&quot;Config&quot;: {
|
||
&quot;Hostname&quot;: &quot;4fa6e0f0c678&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Dns&quot;: null,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: {},
|
||
&quot;VolumesFrom&quot;: &quot;&quot;,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;State&quot;: {
|
||
&quot;Running&quot;: false,
|
||
&quot;Pid&quot;: 0,
|
||
&quot;ExitCode&quot;: 0,
|
||
&quot;StartedAt&quot;: &quot;2013-05-07T14:51:42.087658+02:01360&quot;,
|
||
&quot;Ghost&quot;: false
|
||
},
|
||
&quot;Image&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;NetworkSettings&quot;: {
|
||
&quot;IpAddress&quot;: &quot;&quot;,
|
||
&quot;IpPrefixLen&quot;: 0,
|
||
&quot;Gateway&quot;: &quot;&quot;,
|
||
&quot;Bridge&quot;: &quot;&quot;,
|
||
&quot;PortMapping&quot;: null
|
||
},
|
||
&quot;SysInitPath&quot;: &quot;/home/kitty/go/src/github.com/docker/docker/bin/docker&quot;,
|
||
&quot;ResolvConfPath&quot;: &quot;/etc/resolv.conf&quot;,
|
||
&quot;Volumes&quot;: {},
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: null,
|
||
&quot;ContainerIDFile&quot;: &quot;&quot;,
|
||
&quot;LxcConf&quot;: [],
|
||
&quot;Privileged&quot;: false,
|
||
&quot;PortBindings&quot;: {
|
||
&quot;80/tcp&quot;: [
|
||
{
|
||
&quot;HostIp&quot;: &quot;0.0.0.0&quot;,
|
||
&quot;HostPort&quot;: &quot;49153&quot;
|
||
}
|
||
]
|
||
},
|
||
&quot;Links&quot;: [&quot;/name:alias&quot;],
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;]
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="list-processes-running-inside-a-container">List processes running inside a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/top</code></p>
|
||
|
||
<p>List processes running inside the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/top HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Titles&quot;: [
|
||
&quot;USER&quot;,
|
||
&quot;PID&quot;,
|
||
&quot;%CPU&quot;,
|
||
&quot;%MEM&quot;,
|
||
&quot;VSZ&quot;,
|
||
&quot;RSS&quot;,
|
||
&quot;TTY&quot;,
|
||
&quot;STAT&quot;,
|
||
&quot;START&quot;,
|
||
&quot;TIME&quot;,
|
||
&quot;COMMAND&quot;
|
||
],
|
||
&quot;Processes&quot;: [
|
||
[&quot;root&quot;,&quot;20147&quot;,&quot;0.0&quot;,&quot;0.1&quot;,&quot;18060&quot;,&quot;1864&quot;,&quot;pts/4&quot;,&quot;S&quot;,&quot;10:06&quot;,&quot;0:00&quot;,&quot;bash&quot;],
|
||
[&quot;root&quot;,&quot;20271&quot;,&quot;0.0&quot;,&quot;0.0&quot;,&quot;4312&quot;,&quot;352&quot;,&quot;pts/4&quot;,&quot;S+&quot;,&quot;10:07&quot;,&quot;0:00&quot;,&quot;sleep&quot;,&quot;10&quot;]
|
||
]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>ps_args</strong> – ps arguments to use (e.g., aux)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-container-logs">Get container logs</h3>
|
||
|
||
<p><code>GET /containers/(id)/logs</code></p>
|
||
|
||
<p>Get stdout and stderr logs from the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/logs?stderr=1&amp;stdout=1&amp;timestamps=1&amp;follow=1&amp;tail=10 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>follow</strong> – 1/True/true or 0/False/false, return stream. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, show stdout log. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, show stderr log. Default false</li>
|
||
<li><strong>timestamps</strong> – 1/True/true or 0/False/false, print timestamps for
|
||
every log line. Default false</li>
|
||
<li><strong>tail</strong> – Output specified number of lines at the end of logs: <code>all</code> or <code>&lt;number&gt;</code>. Default all</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-changes-on-a-container-s-filesystem">Inspect changes on a container&rsquo;s filesystem</h3>
|
||
|
||
<p><code>GET /containers/(id)/changes</code></p>
|
||
|
||
<p>Inspect changes on container <code>id</code>&rsquo;s filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/changes HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Path&quot;: &quot;/dev&quot;,
|
||
&quot;Kind&quot;: 0
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/dev/kmsg&quot;,
|
||
&quot;Kind&quot;: 1
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/test&quot;,
|
||
&quot;Kind&quot;: 1
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="export-a-container">Export a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/export</code></p>
|
||
|
||
<p>Export the contents of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/export HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/octet-stream
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="resize-a-container-tty">Resize a container TTY</h3>
|
||
|
||
<p><code>GET /containers/(id)/resize?h=&lt;height&gt;&amp;w=&lt;width&gt;</code></p>
|
||
|
||
<p>Resize the TTY of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/resize?h=40&amp;w=80 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Length: 0
|
||
Content-Type: text/plain; charset=utf-8
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – No such container</li>
|
||
<li><strong>500</strong> – bad file descriptor</li>
|
||
</ul>
|
||
|
||
<h3 id="start-a-container">Start a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/start</code></p>
|
||
|
||
<p>Start the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/(id)/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: []
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume
|
||
binding is a string of the form <code>container_path</code> (to create a new
|
||
volume for the container), <code>host_path:container_path</code> (to bind-mount
|
||
a host path into the container), or <code>host_path:container_path:ro</code>
|
||
(to make the bind-mount read-only inside the container).</li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be of
|
||
of the form &ldquo;container_name:alias&rdquo;.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations will only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. It should be specified in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of dns servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already started</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="stop-a-container">Stop a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/stop</code></p>
|
||
|
||
<p>Stop the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/stop?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already stopped</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="restart-a-container">Restart a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/restart</code></p>
|
||
|
||
<p>Restart the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/restart?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="kill-a-container">Kill a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/kill</code></p>
|
||
|
||
<p>Kill the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/kill HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters</p>
|
||
|
||
<ul>
|
||
<li><strong>signal</strong> - Signal to send to the container: integer or string like &ldquo;SIGINT&rdquo;.
|
||
When not set, SIGKILL is assumed and the call will waits for the container to exit.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="pause-a-container">Pause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/pause</code></p>
|
||
|
||
<p>Pause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/pause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="unpause-a-container">Unpause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/unpause</code></p>
|
||
|
||
<p>Unpause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/unpause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container">Attach to a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/attach</code></p>
|
||
|
||
<p>Attach to the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/attach?logs=1&amp;stream=0&amp;stdout=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach
|
||
to stdin. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
|
||
<li><p><strong>500</strong> – server error</p>
|
||
|
||
<p><strong>Stream details</strong>:</p>
|
||
|
||
<p>When using the TTY setting is enabled in
|
||
<a href="http://localhost/docker/reference/api/docker_remote_api_v1.9/#create-a-container" title="POST /containers/create"><code>POST /containers/create</code>
|
||
</a>,
|
||
the stream is the raw data from the process PTY and client&rsquo;s stdin.
|
||
When the TTY is disabled, then the stream is multiplexed to separate
|
||
stdout and stderr.</p>
|
||
|
||
<p>The format is a <strong>Header</strong> and a <strong>Payload</strong> (frame).</p>
|
||
|
||
<p><strong>HEADER</strong></p>
|
||
|
||
<p>The header will contain the information on which stream write the
|
||
stream (stdout or stderr). It also contain the size of the
|
||
associated frame encoded on the last 4 bytes (uint32).</p>
|
||
|
||
<p>It is encoded on the first 8 bytes like this:</p>
|
||
|
||
<pre><code>header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
|
||
</code></pre>
|
||
|
||
<p><code>STREAM_TYPE</code> can be:</p></li>
|
||
|
||
<li><p>0: stdin (will be written on stdout)</p></li>
|
||
|
||
<li><p>1: stdout</p></li>
|
||
|
||
<li><p>2: stderr</p>
|
||
|
||
<p><code>SIZE1, SIZE2, SIZE3, SIZE4</code> are the 4 bytes of
|
||
the uint32 size encoded as big endian.</p>
|
||
|
||
<p><strong>PAYLOAD</strong></p>
|
||
|
||
<p>The payload is the raw stream.</p>
|
||
|
||
<p><strong>IMPLEMENTATION</strong></p>
|
||
|
||
<p>The simplest way to implement the Attach protocol is the following:</p>
|
||
|
||
<ol>
|
||
<li>Read 8 bytes</li>
|
||
<li>chose stdout or stderr depending on the first byte</li>
|
||
<li>Extract the frame size from the last 4 bytes</li>
|
||
<li>Read the extracted size and output it on the correct output</li>
|
||
<li>Goto 1</li>
|
||
</ol></li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container-websocket">Attach to a container (websocket)</h3>
|
||
|
||
<p><code>GET /containers/(id)/attach/ws</code></p>
|
||
|
||
<p>Attach to the container <code>id</code> via websocket</p>
|
||
|
||
<p>Implements websocket protocol handshake according to <a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a></p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /containers/e90e34656806/attach/ws?logs=0&amp;stream=1&amp;stdin=1&amp;stdout=1&amp;stderr=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong></p>
|
||
|
||
<pre><code> {{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach
|
||
to stdin. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="wait-a-container">Wait a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/wait</code></p>
|
||
|
||
<p>Block until container <code>id</code> stops, then returns the exit code</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/wait HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;StatusCode&quot;: 0}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-a-container">Remove a container</h3>
|
||
|
||
<p><code>DELETE /containers/(id)</code></p>
|
||
|
||
<p>Remove the container <code>id</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /containers/16253994b7c4?v=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>v</strong> – 1/True/true or 0/False/false, Remove the volumes
|
||
associated to the container. Default false</li>
|
||
<li><strong>force</strong> - 1/True/true or 0/False/false, Kill then remove the container.
|
||
Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="copy-files-or-folders-from-a-container">Copy files or folders from a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/copy</code></p>
|
||
|
||
<p>Copy files or folders of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/4fa6e0f0c678/copy HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Resource&quot;: &quot;test.txt&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-2-images">2.2 Images</h2>
|
||
|
||
<h3 id="list-images">List Images</h3>
|
||
|
||
<p><code>GET /images/json</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/json?all=0 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.04&quot;,
|
||
&quot;ubuntu:precise&quot;,
|
||
&quot;ubuntu:latest&quot;
|
||
],
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;VirtualSize&quot;: 131506275
|
||
},
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.10&quot;,
|
||
&quot;ubuntu:quantal&quot;
|
||
],
|
||
&quot;ParentId&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;Size&quot;: 24653,
|
||
&quot;VirtualSize&quot;: 180116135
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>filters</strong> – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
|
||
|
||
<ul>
|
||
<li>dangling=true</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<h3 id="create-an-image">Create an image</h3>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p>Create an image, either by pulling it from the registry or by importing it</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/create?fromImage=ubuntu HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pulling...&quot;}
|
||
{&quot;status&quot;: &quot;Pulling&quot;, &quot;progress&quot;: &quot;1 B/ 100 B&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1, &quot;total&quot;: 100}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
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.
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>fromImage</strong> – name of the image to pull</li>
|
||
<li><strong>fromSrc</strong> – source to import. The value may be a URL from which the image
|
||
can be retrieved or <code>-</code> to read the image from the request body.</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
|
||
<li><p><strong>registry</strong> – the registry to pull from</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>X-Registry-Auth</strong> – base64-encoded AuthConfig object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-an-image">Inspect an image</h3>
|
||
|
||
<p><code>GET /images/(name)/json</code></p>
|
||
|
||
<p>Return low-level information on the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Created&quot;: &quot;2013-03-23T22:24:18.818426-07:00&quot;,
|
||
&quot;Container&quot;: &quot;3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0&quot;,
|
||
&quot;ContainerConfig&quot;:
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: false,
|
||
&quot;AttachStderr&quot;: false,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: true,
|
||
&quot;OpenStdin&quot;: true,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [&quot;/bin/bash&quot;],
|
||
&quot;Dns&quot;: null,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: null,
|
||
&quot;VolumesFrom&quot;: &quot;&quot;,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Parent&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Size&quot;: 6824592
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-the-history-of-an-image">Get the history of an image</h3>
|
||
|
||
<p><code>GET /images/(name)/history</code></p>
|
||
|
||
<p>Return the history of the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/history HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;b750fe79269d&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;CreatedBy&quot;: &quot;/bin/bash&quot;
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;27cf78414709&quot;,
|
||
&quot;Created&quot;: 1364068391,
|
||
&quot;CreatedBy&quot;: &quot;&quot;
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="push-an-image-on-the-registry">Push an image on the registry</h3>
|
||
|
||
<p><code>POST /images/(name)/push</code></p>
|
||
|
||
<p>Push the image <code>name</code> on the registry</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pushing...&quot;}
|
||
{&quot;status&quot;: &quot;Pushing&quot;, &quot;progress&quot;: &quot;1/? (n/a)&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1}}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
If you wish to push an image on to a private registry, that image must already have been tagged
|
||
into a repository which references that registry host name and port. This repository name should
|
||
then be used in the URL. This mirrors the flow of the CLI.
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/registry.acme.com:5000/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>tag</strong> – the tag to associate with the image on the registry, optional</li>
|
||
</ul>
|
||
|
||
<p>Request Headers:</p>
|
||
|
||
<ul>
|
||
<li><strong>X-Registry-Auth</strong> – include a base64-encoded AuthConfig
|
||
object.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="tag-an-image-into-a-repository">Tag an image into a repository</h3>
|
||
|
||
<p><code>POST /images/(name)/tag</code></p>
|
||
|
||
<p>Tag the image <code>name</code> into a repository</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/tag?repo=myrepo&amp;force=0&amp;tag=v42 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo</strong> – The repository to tag in</li>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>tag</strong> - The new tag name</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-an-image">Remove an image</h3>
|
||
|
||
<p><code>DELETE /images/(name)</code></p>
|
||
|
||
<p>Remove the image <code>name</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /images/test HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-type: application/json
|
||
|
||
[
|
||
{&quot;Untagged&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;53b4f83ac9&quot;}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>noprune</strong> – 1/True/true or 0/False/false, default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="search-images">Search images</h3>
|
||
|
||
<p><code>GET /images/search</code></p>
|
||
|
||
<p>Search for an image on <a href="https://hub.docker.com">Docker Hub</a>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
The response keys have changed from API v1.6 to reflect the JSON
|
||
sent by the registry server to the docker daemon&rsquo;s request.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/search?term=sshd HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;wma55/u1210sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;jdswinbank/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;vgauthier/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
}
|
||
...
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>term</strong> – term to search</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-3-misc">2.3 Misc</h2>
|
||
|
||
<h3 id="build-an-image-from-dockerfile-via-stdin">Build an image from Dockerfile via stdin</h3>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p>Build an image from Dockerfile via stdin</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /build HTTP/1.1
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;stream&quot;: &quot;Step 1...&quot;}
|
||
{&quot;stream&quot;: &quot;...&quot;}
|
||
{&quot;error&quot;: &quot;Error...&quot;, &quot;errorDetail&quot;: {&quot;code&quot;: 123, &quot;message&quot;: &quot;Error...&quot;}}
|
||
|
||
The stream must be a tar archive compressed with one of the
|
||
following algorithms: identity (no compression), gzip, bzip2, xz.
|
||
|
||
The archive must include a file called `Dockerfile`
|
||
at its root. It may include any number of other files,
|
||
which will be accessible in the build context (See the [*ADD build
|
||
command*](/docker/reference/builder/#dockerbuilder)).
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – repository name (and optionally a tag) to be applied to
|
||
the resulting image in case of success</li>
|
||
<li><strong>remote</strong> – git or HTTP/HTTPS URI build source</li>
|
||
<li><strong>q</strong> – suppress verbose build output</li>
|
||
<li><strong>nocache</strong> – do not use the cache when building the image</li>
|
||
<li><strong>rm</strong> - remove intermediate containers after a successful build (default behavior)</li>
|
||
|
||
<li><p><strong>forcerm</strong> - always remove intermediate containers (includes rm)</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>Content-type</strong> – should be set to <code>&quot;application/tar&quot;</code>.</p></li>
|
||
|
||
<li><p><strong>X-Registry-Config</strong> – base64-encoded ConfigFile object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="check-auth-configuration">Check auth configuration</h3>
|
||
|
||
<p><code>POST /auth</code></p>
|
||
|
||
<p>Get the default username and email</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /auth HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;username&quot;:&quot; hannibal&quot;,
|
||
&quot;password: &quot;xxxx&quot;,
|
||
&quot;email&quot;: &quot;hannibal@a-team.com&quot;,
|
||
&quot;serveraddress&quot;: &quot;https://index.docker.io/v1/&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="display-system-wide-information">Display system-wide information</h3>
|
||
|
||
<p><code>GET /info</code></p>
|
||
|
||
<p>Display system-wide information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /info HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Containers&quot;: 11,
|
||
&quot;Images&quot;: 16,
|
||
&quot;Driver&quot;: &quot;btrfs&quot;,
|
||
&quot;ExecutionDriver&quot;: &quot;native-0.1&quot;,
|
||
&quot;KernelVersion&quot;: &quot;3.12.0-1-amd64&quot;
|
||
&quot;Debug&quot;: false,
|
||
&quot;NFd&quot;: 11,
|
||
&quot;NGoroutines&quot;: 21,
|
||
&quot;NEventsListener&quot;: 0,
|
||
&quot;InitPath&quot;: &quot;/usr/bin/docker&quot;,
|
||
&quot;IndexServerAddress&quot;: [&quot;https://index.docker.io/v1/&quot;],
|
||
&quot;MemoryLimit&quot;: true,
|
||
&quot;SwapLimit&quot;: false,
|
||
&quot;IPv4Forwarding&quot;: true
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="show-the-docker-version-information">Show the docker version information</h3>
|
||
|
||
<p><code>GET /version</code></p>
|
||
|
||
<p>Show the docker version information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /version HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;ApiVersion&quot;: &quot;1.12&quot;,
|
||
&quot;Version&quot;: &quot;0.2.2&quot;,
|
||
&quot;GitCommit&quot;: &quot;5a2a5cc+CHANGES&quot;,
|
||
&quot;GoVersion&quot;: &quot;go1.0.3&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="ping-the-docker-server">Ping the docker server</h3>
|
||
|
||
<p><code>GET /_ping</code></p>
|
||
|
||
<p>Ping the docker server</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /_ping HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: text/plain
|
||
|
||
OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> - no error</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-new-image-from-a-container-s-changes">Create a new image from a container&rsquo;s changes</h3>
|
||
|
||
<p><code>POST /commit</code></p>
|
||
|
||
<p>Create a new image from a container&rsquo;s changes</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /commit?container=44c004db4b17&amp;comment=message&amp;repo=myrepo HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;Cpuset&quot;: &quot;0,1&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{&quot;Id&quot;: &quot;596069db4bf5&quot;}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>config</strong> - the container&rsquo;s configuration</li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>container</strong> – source container</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
<li><strong>comment</strong> – commit message</li>
|
||
<li><strong>author</strong> – author (e.g., &ldquo;John Hannibal Smith
|
||
&lt;<a href="mailto:hannibal%40a-team.com">hannibal@a-team.com</a>&gt;&ldquo;)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="monitor-docker-s-events">Monitor Docker&rsquo;s events</h3>
|
||
|
||
<p><code>GET /events</code></p>
|
||
|
||
<p>Get container events from docker, either in real time via streaming, or via
|
||
polling (using since).</p>
|
||
|
||
<p>Docker containers will report the following events:</p>
|
||
|
||
<pre><code>create, destroy, die, export, kill, pause, restart, start, stop, unpause
|
||
</code></pre>
|
||
|
||
<p>and Docker images will report:</p>
|
||
|
||
<pre><code>untag, delete
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /events?since=1374067924
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;create&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;start&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;stop&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067966}
|
||
{&quot;status&quot;: &quot;destroy&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067970}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>since</strong> – timestamp used for polling</li>
|
||
<li><strong>until</strong> – timestamp used for polling</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images-in-a-repository">Get a tarball containing all images in a repository</h3>
|
||
|
||
<p><code>GET /images/(name)/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for the repository specified
|
||
by <code>name</code>.</p>
|
||
|
||
<p>If <code>name</code> is a specific name and tag (e.g. ubuntu:latest), then only that image
|
||
(and its parents) are returned. If <code>name</code> is an image ID, similarly only that
|
||
image (and its parents) are returned, but with the exclusion of the
|
||
&lsquo;repositories&rsquo; file in the tarball, as there were no image names referenced.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /images/ubuntu/get
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images">Get a tarball containing all images.</h3>
|
||
|
||
<p><code>GET /images/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for one or more repositories.</p>
|
||
|
||
<p>For each value of the <code>names</code> 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 &lsquo;repositories&rsquo; file for this image ID.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /images/get?names=myname%2Fmyapp%3Alatest&amp;names=busybox
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="load-a-tarball-with-a-set-of-images-and-tags-into-docker">Load a tarball with a set of images and tags into docker</h3>
|
||
|
||
<p><code>POST /images/load</code></p>
|
||
|
||
<p>Load a set of images and tags into the docker repository.
|
||
See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> POST /images/load
|
||
|
||
Tarball in body
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="image-tarball-format">Image tarball format</h3>
|
||
|
||
<p>An image tarball contains one directory per image layer (named using its long ID),
|
||
each containing three files:</p>
|
||
|
||
<ol>
|
||
<li><code>VERSION</code>: currently <code>1.0</code> - the file format version</li>
|
||
<li><code>json</code>: detailed layer information, similar to <code>docker inspect layer_id</code></li>
|
||
<li><code>layer.tar</code>: A tarfile containing the filesystem changes in this layer</li>
|
||
</ol>
|
||
|
||
<p>The <code>layer.tar</code> file will contain <code>aufs</code> style <code>.wh..wh.aufs</code> files and directories
|
||
for storing attribute changes and deletions.</p>
|
||
|
||
<p>If the tarball defines a repository, there will also be a <code>repositories</code> file at
|
||
the root that contains a list of repository and tag names mapped to layer IDs.</p>
|
||
|
||
<pre><code>{&quot;hello-world&quot;:
|
||
{&quot;latest&quot;: &quot;565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1&quot;}
|
||
}
|
||
</code></pre>
|
||
|
||
<h3 id="exec-create">Exec Create</h3>
|
||
|
||
<p><code>POST /containers/(id)/exec</code></p>
|
||
|
||
<p>Sets up an exec instance in a running container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/exec HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;: &quot;f90e34656806&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to stdin of the exec command.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to stdout of the exec command.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to stderr of the exec command.</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY</li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
</ul>
|
||
|
||
<h3 id="exec-start">Exec Start</h3>
|
||
|
||
<p><code>POST /exec/(id)/start</code></p>
|
||
|
||
<p>Starts a previously set up exec instance <code>id</code>. If <code>detach</code> is true, this API
|
||
returns after starting the <code>exec</code> command. Otherwise, this API sets up an
|
||
interactive session with the <code>exec</code> command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /exec/e90e34656806/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Detach&quot;: false,
|
||
&quot;Tty&quot;: false,
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Detach</strong> - Detach from the exec command</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
|
||
<li><p><strong>404</strong> – no such exec instance</p>
|
||
|
||
<p><strong>Stream details</strong>:
|
||
Similar to the stream behavior of <code>POST /container/(id)/attach</code> API</p></li>
|
||
</ul>
|
||
|
||
<h3 id="exec-resize">Exec Resize</h3>
|
||
|
||
<p><code>POST /exec/(id)/resize</code></p>
|
||
|
||
<p>Resizes the tty session used by the exec command <code>id</code>.
|
||
This API is valid only if <code>tty</code> was specified as part of creating and starting the exec command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /exec/e90e34656806/resize HTTP/1.1
|
||
Content-Type: plain/text
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: plain/text
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>h</strong> – height of tty session</li>
|
||
<li><strong>w</strong> – width</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such exec instance</li>
|
||
</ul>
|
||
|
||
<h1 id="3-going-further">3. Going further</h1>
|
||
|
||
<h2 id="3-1-inside-docker-run">3.1 Inside <code>docker run</code></h2>
|
||
|
||
<p>As an example, the <code>docker run</code> command line makes the following API calls:</p>
|
||
|
||
<ul>
|
||
<li><p>Create the container</p></li>
|
||
|
||
<li><p>If the status code is 404, it means the image doesn&rsquo;t exist:</p>
|
||
|
||
<ul>
|
||
<li>Try to pull it</li>
|
||
<li>Then retry to create the container</li>
|
||
</ul></li>
|
||
|
||
<li><p>Start the container</p></li>
|
||
|
||
<li><p>If you are not in detached mode:</p></li>
|
||
|
||
<li><p>Attach to the container, using logs=1 (to have stdout and
|
||
stderr from the container&rsquo;s start) and stream=1</p></li>
|
||
|
||
<li><p>If in detached mode or only stdin is attached:</p></li>
|
||
|
||
<li><p>Display the container&rsquo;s id</p></li>
|
||
</ul>
|
||
|
||
<h2 id="3-2-hijacking">3.2 Hijacking</h2>
|
||
|
||
<p>In this version of the API, /attach, uses hijacking to transport stdin,
|
||
stdout and stderr on the same socket. This might change in the future.</p>
|
||
|
||
<h2 id="3-3-cors-requests">3.3 CORS Requests</h2>
|
||
|
||
<p>To enable cross origin requests to the remote api add the flag
|
||
&ldquo;&ndash;api-enable-cors&rdquo; when running docker in daemon mode.</p>
|
||
|
||
<pre><code>$ docker -d -H=&quot;192.168.1.9:2375&quot; --api-enable-cors
|
||
</code></pre>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Remote API v1.16</title>
|
||
<link>http://localhost/reference/api/docker_remote_api_v1.16/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/docker_remote_api_v1.16/</guid>
|
||
<description>
|
||
|
||
<h1 id="docker-remote-api-v1-16">Docker Remote API v1.16</h1>
|
||
|
||
<h2 id="1-brief-introduction">1. Brief introduction</h2>
|
||
|
||
<ul>
|
||
<li>The Remote API has replaced <code>rcli</code>.</li>
|
||
<li>The daemon listens on <code>unix:///var/run/docker.sock</code> but you can
|
||
<a href="http://localhost/articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket">Bind Docker to another host/port or a Unix socket</a>.</li>
|
||
<li>The API tends to be REST, but for some complex commands, like <code>attach</code>
|
||
or <code>pull</code>, the HTTP connection is hijacked to transport <code>STDOUT</code>,
|
||
<code>STDIN</code> and <code>STDERR</code>.</li>
|
||
</ul>
|
||
|
||
<h1 id="2-endpoints">2. Endpoints</h1>
|
||
|
||
<h2 id="2-1-containers">2.1 Containers</h2>
|
||
|
||
<h3 id="list-containers">List containers</h3>
|
||
|
||
<p><code>GET /containers/json</code></p>
|
||
|
||
<p>List containers</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/json?all=1&amp;before=8dfafdbc3a40&amp;size=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;8dfafdbc3a40&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 1&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [{&quot;PrivatePort&quot;: 2222, &quot;PublicPort&quot;: 3333, &quot;Type&quot;: &quot;tcp&quot;}],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;9cd87474be90&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 222222&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;3176a2479c92&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 3333333333333333&quot;,
|
||
&quot;Created&quot;: 1367854154,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;:[],
|
||
&quot;SizeRw&quot;:12288,
|
||
&quot;SizeRootFs&quot;:0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;4cb07b47f9fb&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 444444444444444444444444444444444&quot;,
|
||
&quot;Created&quot;: 1367854152,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, Show all containers.
|
||
Only running containers are shown by default (i.e., this defaults to false)</li>
|
||
<li><strong>limit</strong> – Show <code>limit</code> last created
|
||
containers, include non-running ones.</li>
|
||
<li><strong>since</strong> – Show only containers created since Id, include
|
||
non-running ones.</li>
|
||
<li><strong>before</strong> – Show only containers created before Id, include
|
||
non-running ones.</li>
|
||
<li><strong>size</strong> – 1/True/true or 0/False/false, Show the containers
|
||
sizes</li>
|
||
<li><strong>filters</strong> - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
|
||
|
||
<ul>
|
||
<li>exited=&lt;int&gt; &ndash; containers with exit code of &lt;int&gt;</li>
|
||
<li>status=(restarting|running|paused|exited)</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-container">Create a container</h3>
|
||
|
||
<p><code>POST /containers/create</code></p>
|
||
|
||
<p>Create a container</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/create HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;Cpuset&quot;: &quot;0,1&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Entrypoint&quot;: &quot;&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;MacAddress&quot;: &quot;12:34:56:78:9a:bc&quot;,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
},
|
||
&quot;SecurityOpts&quot;: [&quot;&quot;],
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: []
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;:&quot;e90e34656806&quot;
|
||
&quot;Warnings&quot;:[]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Hostname</strong> - A string value containing the desired hostname to use for the
|
||
container.</li>
|
||
<li><strong>Domainname</strong> - A string value containing the desired domain name to use
|
||
for the container.</li>
|
||
<li><strong>User</strong> - A string value containing the user to use inside the container.</li>
|
||
<li><strong>Memory</strong> - Memory limit in bytes.</li>
|
||
<li><strong>MemorySwap</strong>- Total memory usage (memory + swap); set <code>-1</code> to disable swap.</li>
|
||
<li><strong>CpuShares</strong> - An integer value containing the CPU Shares for container
|
||
(ie. the relative weight vs other containers).
|
||
<strong>CpuSet</strong> - String value containing the cgroups Cpuset to use.</li>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to stdin.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to stdout.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to stderr.</li>
|
||
<li><strong>Tty</strong> - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.</li>
|
||
<li><strong>OpenStdin</strong> - Boolean value, opens stdin,</li>
|
||
<li><strong>StdinOnce</strong> - Boolean value, close stdin after the 1 attached client disconnects.</li>
|
||
<li><strong>Env</strong> - A list of environment variables in the form of <code>VAR=value</code></li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
<li><strong>Entrypoint</strong> - Set the entrypoint for the container a a string or an array
|
||
of strings</li>
|
||
<li><strong>Image</strong> - String value containing the image name to use for the container</li>
|
||
<li><strong>Volumes</strong> – An object mapping mountpoint paths (strings) inside the
|
||
container to empty objects.</li>
|
||
<li><strong>WorkingDir</strong> - A string value containing the working dir for commands to
|
||
run in.</li>
|
||
<li><strong>NetworkDisabled</strong> - Boolean value, when true disables networking for the
|
||
container</li>
|
||
<li><strong>ExposedPorts</strong> - An object mapping ports to an empty object in the form of:
|
||
<code>&quot;ExposedPorts&quot;: { &quot;&lt;port&gt;/&lt;tcp|udp&gt;: {}&quot; }</code></li>
|
||
<li><strong>SecurityOpts</strong>: A list of string values to customize labels for MLS
|
||
systems, such as SELinux.</li>
|
||
<li><strong>HostConfig</strong>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume
|
||
binding is a string of the form <code>container_path</code> (to create a new
|
||
volume for the container), <code>host_path:container_path</code> (to bind-mount
|
||
a host path into the container), or <code>host_path:container_path:ro</code>
|
||
(to make the bind-mount read-only inside the container).</li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be
|
||
in the form of &ldquo;container_name:alias&rdquo;.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations will only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. It should be specified in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of dns servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains</li>
|
||
<li><strong>ExtraHosts</strong> - A list of hostnames/IP mappings to be added to the
|
||
container&rsquo;s <code>/etc/hosts</code> file. Specified in the form <code>[&quot;hostname:IP&quot;]</code>.</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>name</strong> – Assign the specified name to the container. Must
|
||
match <code>/?[a-zA-Z0-9_-]+</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>406</strong> – impossible to attach (container not running)</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-a-container">Inspect a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/json</code></p>
|
||
|
||
<p>Return low-level information on the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;: &quot;4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2&quot;,
|
||
&quot;Created&quot;: &quot;2013-05-07T14:51:42.041847+02:00&quot;,
|
||
&quot;Path&quot;: &quot;date&quot;,
|
||
&quot;Args&quot;: [],
|
||
&quot;Config&quot;: {
|
||
&quot;Hostname&quot;: &quot;4fa6e0f0c678&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Dns&quot;: null,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: {},
|
||
&quot;VolumesFrom&quot;: &quot;&quot;,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;State&quot;: {
|
||
&quot;Running&quot;: false,
|
||
&quot;Pid&quot;: 0,
|
||
&quot;ExitCode&quot;: 0,
|
||
&quot;StartedAt&quot;: &quot;2013-05-07T14:51:42.087658+02:01360&quot;,
|
||
&quot;Ghost&quot;: false
|
||
},
|
||
&quot;Image&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;NetworkSettings&quot;: {
|
||
&quot;IpAddress&quot;: &quot;&quot;,
|
||
&quot;IpPrefixLen&quot;: 0,
|
||
&quot;Gateway&quot;: &quot;&quot;,
|
||
&quot;Bridge&quot;: &quot;&quot;,
|
||
&quot;PortMapping&quot;: null
|
||
},
|
||
&quot;SysInitPath&quot;: &quot;/home/kitty/go/src/github.com/docker/docker/bin/docker&quot;,
|
||
&quot;ResolvConfPath&quot;: &quot;/etc/resolv.conf&quot;,
|
||
&quot;Volumes&quot;: {},
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: null,
|
||
&quot;ContainerIDFile&quot;: &quot;&quot;,
|
||
&quot;LxcConf&quot;: [],
|
||
&quot;Privileged&quot;: false,
|
||
&quot;PortBindings&quot;: {
|
||
&quot;80/tcp&quot;: [
|
||
{
|
||
&quot;HostIp&quot;: &quot;0.0.0.0&quot;,
|
||
&quot;HostPort&quot;: &quot;49153&quot;
|
||
}
|
||
]
|
||
},
|
||
&quot;Links&quot;: [&quot;/name:alias&quot;],
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;]
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="list-processes-running-inside-a-container">List processes running inside a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/top</code></p>
|
||
|
||
<p>List processes running inside the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/top HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Titles&quot;: [
|
||
&quot;USER&quot;,
|
||
&quot;PID&quot;,
|
||
&quot;%CPU&quot;,
|
||
&quot;%MEM&quot;,
|
||
&quot;VSZ&quot;,
|
||
&quot;RSS&quot;,
|
||
&quot;TTY&quot;,
|
||
&quot;STAT&quot;,
|
||
&quot;START&quot;,
|
||
&quot;TIME&quot;,
|
||
&quot;COMMAND&quot;
|
||
],
|
||
&quot;Processes&quot;: [
|
||
[&quot;root&quot;,&quot;20147&quot;,&quot;0.0&quot;,&quot;0.1&quot;,&quot;18060&quot;,&quot;1864&quot;,&quot;pts/4&quot;,&quot;S&quot;,&quot;10:06&quot;,&quot;0:00&quot;,&quot;bash&quot;],
|
||
[&quot;root&quot;,&quot;20271&quot;,&quot;0.0&quot;,&quot;0.0&quot;,&quot;4312&quot;,&quot;352&quot;,&quot;pts/4&quot;,&quot;S+&quot;,&quot;10:07&quot;,&quot;0:00&quot;,&quot;sleep&quot;,&quot;10&quot;]
|
||
]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>ps_args</strong> – ps arguments to use (e.g., aux)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-container-logs">Get container logs</h3>
|
||
|
||
<p><code>GET /containers/(id)/logs</code></p>
|
||
|
||
<p>Get stdout and stderr logs from the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/logs?stderr=1&amp;stdout=1&amp;timestamps=1&amp;follow=1&amp;tail=10 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>follow</strong> – 1/True/true or 0/False/false, return stream. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, show stdout log. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, show stderr log. Default false</li>
|
||
<li><strong>timestamps</strong> – 1/True/true or 0/False/false, print timestamps for
|
||
every log line. Default false</li>
|
||
<li><strong>tail</strong> – Output specified number of lines at the end of logs: <code>all</code> or <code>&lt;number&gt;</code>. Default all</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-changes-on-a-container-s-filesystem">Inspect changes on a container&rsquo;s filesystem</h3>
|
||
|
||
<p><code>GET /containers/(id)/changes</code></p>
|
||
|
||
<p>Inspect changes on container <code>id</code>&rsquo;s filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/changes HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Path&quot;: &quot;/dev&quot;,
|
||
&quot;Kind&quot;: 0
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/dev/kmsg&quot;,
|
||
&quot;Kind&quot;: 1
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/test&quot;,
|
||
&quot;Kind&quot;: 1
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="export-a-container">Export a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/export</code></p>
|
||
|
||
<p>Export the contents of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/export HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/octet-stream
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="resize-a-container-tty">Resize a container TTY</h3>
|
||
|
||
<p><code>POST /containers/(id)/resize?h=&lt;height&gt;&amp;w=&lt;width&gt;</code></p>
|
||
|
||
<p>Resize the TTY for container with <code>id</code>. The container must be restarted for the resize to take effect.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/4fa6e0f0c678/resize?h=40&amp;w=80 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Length: 0
|
||
Content-Type: text/plain; charset=utf-8
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – No such container</li>
|
||
<li><strong>500</strong> – Cannot resize container</li>
|
||
</ul>
|
||
|
||
<h3 id="start-a-container">Start a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/start</code></p>
|
||
|
||
<p>Start the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/(id)/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: []
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume
|
||
binding is a string of the form <code>container_path</code> (to create a new
|
||
volume for the container), <code>host_path:container_path</code> (to bind-mount
|
||
a host path into the container), or <code>host_path:container_path:ro</code>
|
||
(to make the bind-mount read-only inside the container).</li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be of
|
||
of the form &ldquo;container_name:alias&rdquo;.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations will only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. It should be specified in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of dns servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already started</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="stop-a-container">Stop a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/stop</code></p>
|
||
|
||
<p>Stop the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/stop?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already stopped</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="restart-a-container">Restart a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/restart</code></p>
|
||
|
||
<p>Restart the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/restart?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="kill-a-container">Kill a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/kill</code></p>
|
||
|
||
<p>Kill the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/kill HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters</p>
|
||
|
||
<ul>
|
||
<li><strong>signal</strong> - Signal to send to the container: integer or string like &ldquo;SIGINT&rdquo;.
|
||
When not set, SIGKILL is assumed and the call will waits for the container to exit.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="pause-a-container">Pause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/pause</code></p>
|
||
|
||
<p>Pause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/pause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="unpause-a-container">Unpause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/unpause</code></p>
|
||
|
||
<p>Unpause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/unpause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container">Attach to a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/attach</code></p>
|
||
|
||
<p>Attach to the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/attach?logs=1&amp;stream=0&amp;stdout=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach
|
||
to stdin. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
|
||
<li><p><strong>500</strong> – server error</p>
|
||
|
||
<p><strong>Stream details</strong>:</p>
|
||
|
||
<p>When using the TTY setting is enabled in
|
||
<a href="http://localhost/docker/reference/api/docker_remote_api_v1.9/#create-a-container" title="POST /containers/create"><code>POST /containers/create</code>
|
||
</a>,
|
||
the stream is the raw data from the process PTY and client&rsquo;s stdin.
|
||
When the TTY is disabled, then the stream is multiplexed to separate
|
||
stdout and stderr.</p>
|
||
|
||
<p>The format is a <strong>Header</strong> and a <strong>Payload</strong> (frame).</p>
|
||
|
||
<p><strong>HEADER</strong></p>
|
||
|
||
<p>The header will contain the information on which stream write the
|
||
stream (stdout or stderr). It also contain the size of the
|
||
associated frame encoded on the last 4 bytes (uint32).</p>
|
||
|
||
<p>It is encoded on the first 8 bytes like this:</p>
|
||
|
||
<pre><code>header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
|
||
</code></pre>
|
||
|
||
<p><code>STREAM_TYPE</code> can be:</p></li>
|
||
|
||
<li><p>0: stdin (will be written on stdout)</p></li>
|
||
|
||
<li><p>1: stdout</p></li>
|
||
|
||
<li><p>2: stderr</p>
|
||
|
||
<p><code>SIZE1, SIZE2, SIZE3, SIZE4</code> are the 4 bytes of
|
||
the uint32 size encoded as big endian.</p>
|
||
|
||
<p><strong>PAYLOAD</strong></p>
|
||
|
||
<p>The payload is the raw stream.</p>
|
||
|
||
<p><strong>IMPLEMENTATION</strong></p>
|
||
|
||
<p>The simplest way to implement the Attach protocol is the following:</p>
|
||
|
||
<ol>
|
||
<li>Read 8 bytes</li>
|
||
<li>chose stdout or stderr depending on the first byte</li>
|
||
<li>Extract the frame size from the last 4 bytes</li>
|
||
<li>Read the extracted size and output it on the correct output</li>
|
||
<li>Goto 1</li>
|
||
</ol></li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container-websocket">Attach to a container (websocket)</h3>
|
||
|
||
<p><code>GET /containers/(id)/attach/ws</code></p>
|
||
|
||
<p>Attach to the container <code>id</code> via websocket</p>
|
||
|
||
<p>Implements websocket protocol handshake according to <a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a></p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /containers/e90e34656806/attach/ws?logs=0&amp;stream=1&amp;stdin=1&amp;stdout=1&amp;stderr=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong></p>
|
||
|
||
<pre><code> {{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach
|
||
to stdin. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="wait-a-container">Wait a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/wait</code></p>
|
||
|
||
<p>Block until container <code>id</code> stops, then returns the exit code</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/wait HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;StatusCode&quot;: 0}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-a-container">Remove a container</h3>
|
||
|
||
<p><code>DELETE /containers/(id)</code></p>
|
||
|
||
<p>Remove the container <code>id</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /containers/16253994b7c4?v=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>v</strong> – 1/True/true or 0/False/false, Remove the volumes
|
||
associated to the container. Default false</li>
|
||
<li><strong>force</strong> - 1/True/true or 0/False/false, Kill then remove the container.
|
||
Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="copy-files-or-folders-from-a-container">Copy files or folders from a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/copy</code></p>
|
||
|
||
<p>Copy files or folders of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/4fa6e0f0c678/copy HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Resource&quot;: &quot;test.txt&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-2-images">2.2 Images</h2>
|
||
|
||
<h3 id="list-images">List Images</h3>
|
||
|
||
<p><code>GET /images/json</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/json?all=0 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.04&quot;,
|
||
&quot;ubuntu:precise&quot;,
|
||
&quot;ubuntu:latest&quot;
|
||
],
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;VirtualSize&quot;: 131506275
|
||
},
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.10&quot;,
|
||
&quot;ubuntu:quantal&quot;
|
||
],
|
||
&quot;ParentId&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;Size&quot;: 24653,
|
||
&quot;VirtualSize&quot;: 180116135
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>filters</strong> – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
|
||
|
||
<ul>
|
||
<li>dangling=true</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<h3 id="create-an-image">Create an image</h3>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p>Create an image, either by pulling it from the registry or by importing it</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/create?fromImage=ubuntu HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pulling...&quot;}
|
||
{&quot;status&quot;: &quot;Pulling&quot;, &quot;progress&quot;: &quot;1 B/ 100 B&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1, &quot;total&quot;: 100}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
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.
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>fromImage</strong> – name of the image to pull</li>
|
||
<li><strong>fromSrc</strong> – source to import. The value may be a URL from which the image
|
||
can be retrieved or <code>-</code> to read the image from the request body.</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
|
||
<li><p><strong>registry</strong> – the registry to pull from</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>X-Registry-Auth</strong> – base64-encoded AuthConfig object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-an-image">Inspect an image</h3>
|
||
|
||
<p><code>GET /images/(name)/json</code></p>
|
||
|
||
<p>Return low-level information on the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Created&quot;: &quot;2013-03-23T22:24:18.818426-07:00&quot;,
|
||
&quot;Container&quot;: &quot;3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0&quot;,
|
||
&quot;ContainerConfig&quot;:
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: false,
|
||
&quot;AttachStderr&quot;: false,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: true,
|
||
&quot;OpenStdin&quot;: true,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [&quot;/bin/bash&quot;],
|
||
&quot;Dns&quot;: null,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: null,
|
||
&quot;VolumesFrom&quot;: &quot;&quot;,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Parent&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Size&quot;: 6824592
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-the-history-of-an-image">Get the history of an image</h3>
|
||
|
||
<p><code>GET /images/(name)/history</code></p>
|
||
|
||
<p>Return the history of the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/history HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;b750fe79269d&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;CreatedBy&quot;: &quot;/bin/bash&quot;
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;27cf78414709&quot;,
|
||
&quot;Created&quot;: 1364068391,
|
||
&quot;CreatedBy&quot;: &quot;&quot;
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="push-an-image-on-the-registry">Push an image on the registry</h3>
|
||
|
||
<p><code>POST /images/(name)/push</code></p>
|
||
|
||
<p>Push the image <code>name</code> on the registry</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pushing...&quot;}
|
||
{&quot;status&quot;: &quot;Pushing&quot;, &quot;progress&quot;: &quot;1/? (n/a)&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1}}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
If you wish to push an image on to a private registry, that image must already have been tagged
|
||
into a repository which references that registry host name and port. This repository name should
|
||
then be used in the URL. This mirrors the flow of the CLI.
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/registry.acme.com:5000/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>tag</strong> – the tag to associate with the image on the registry, optional</li>
|
||
</ul>
|
||
|
||
<p>Request Headers:</p>
|
||
|
||
<ul>
|
||
<li><strong>X-Registry-Auth</strong> – include a base64-encoded AuthConfig
|
||
object.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="tag-an-image-into-a-repository">Tag an image into a repository</h3>
|
||
|
||
<p><code>POST /images/(name)/tag</code></p>
|
||
|
||
<p>Tag the image <code>name</code> into a repository</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/tag?repo=myrepo&amp;force=0&amp;tag=v42 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo</strong> – The repository to tag in</li>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>tag</strong> - The new tag name</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-an-image">Remove an image</h3>
|
||
|
||
<p><code>DELETE /images/(name)</code></p>
|
||
|
||
<p>Remove the image <code>name</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /images/test HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-type: application/json
|
||
|
||
[
|
||
{&quot;Untagged&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;53b4f83ac9&quot;}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>noprune</strong> – 1/True/true or 0/False/false, default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="search-images">Search images</h3>
|
||
|
||
<p><code>GET /images/search</code></p>
|
||
|
||
<p>Search for an image on <a href="https://hub.docker.com">Docker Hub</a>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
The response keys have changed from API v1.6 to reflect the JSON
|
||
sent by the registry server to the docker daemon&rsquo;s request.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/search?term=sshd HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;wma55/u1210sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;jdswinbank/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;vgauthier/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
}
|
||
...
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>term</strong> – term to search</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-3-misc">2.3 Misc</h2>
|
||
|
||
<h3 id="build-an-image-from-dockerfile-via-stdin">Build an image from Dockerfile via stdin</h3>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p>Build an image from Dockerfile via stdin</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /build HTTP/1.1
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;stream&quot;: &quot;Step 1...&quot;}
|
||
{&quot;stream&quot;: &quot;...&quot;}
|
||
{&quot;error&quot;: &quot;Error...&quot;, &quot;errorDetail&quot;: {&quot;code&quot;: 123, &quot;message&quot;: &quot;Error...&quot;}}
|
||
|
||
The stream must be a tar archive compressed with one of the
|
||
following algorithms: identity (no compression), gzip, bzip2, xz.
|
||
|
||
The archive must include a file called `Dockerfile`
|
||
at its root. It may include any number of other files,
|
||
which will be accessible in the build context (See the [*ADD build
|
||
command*](/docker/reference/builder/#dockerbuilder)).
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – repository name (and optionally a tag) to be applied to
|
||
the resulting image in case of success</li>
|
||
<li><strong>remote</strong> – git or HTTP/HTTPS URI build source</li>
|
||
<li><strong>q</strong> – suppress verbose build output</li>
|
||
<li><strong>nocache</strong> – do not use the cache when building the image</li>
|
||
<li><strong>pull</strong> - attempt to pull the image even if an older image exists locally</li>
|
||
<li><strong>rm</strong> - remove intermediate containers after a successful build (default behavior)</li>
|
||
|
||
<li><p><strong>forcerm</strong> - always remove intermediate containers (includes rm)</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>Content-type</strong> – should be set to <code>&quot;application/tar&quot;</code>.</p></li>
|
||
|
||
<li><p><strong>X-Registry-Config</strong> – base64-encoded ConfigFile object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="check-auth-configuration">Check auth configuration</h3>
|
||
|
||
<p><code>POST /auth</code></p>
|
||
|
||
<p>Get the default username and email</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /auth HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;username&quot;:&quot; hannibal&quot;,
|
||
&quot;password: &quot;xxxx&quot;,
|
||
&quot;email&quot;: &quot;hannibal@a-team.com&quot;,
|
||
&quot;serveraddress&quot;: &quot;https://index.docker.io/v1/&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="display-system-wide-information">Display system-wide information</h3>
|
||
|
||
<p><code>GET /info</code></p>
|
||
|
||
<p>Display system-wide information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /info HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Containers&quot;:11,
|
||
&quot;Images&quot;:16,
|
||
&quot;Driver&quot;:&quot;btrfs&quot;,
|
||
&quot;DriverStatus&quot;: [[&quot;&quot;]],
|
||
&quot;ExecutionDriver&quot;:&quot;native-0.1&quot;,
|
||
&quot;KernelVersion&quot;:&quot;3.12.0-1-amd64&quot;
|
||
&quot;NCPU&quot;:1,
|
||
&quot;MemTotal&quot;:2099236864,
|
||
&quot;Name&quot;:&quot;prod-server-42&quot;,
|
||
&quot;ID&quot;:&quot;7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS&quot;,
|
||
&quot;Debug&quot;:false,
|
||
&quot;NFd&quot;: 11,
|
||
&quot;NGoroutines&quot;:21,
|
||
&quot;NEventsListener&quot;:0,
|
||
&quot;InitPath&quot;:&quot;/usr/bin/docker&quot;,
|
||
&quot;InitSha1&quot;:&quot;&quot;,
|
||
&quot;IndexServerAddress&quot;:[&quot;https://index.docker.io/v1/&quot;],
|
||
&quot;MemoryLimit&quot;:true,
|
||
&quot;SwapLimit&quot;:false,
|
||
&quot;IPv4Forwarding&quot;:true,
|
||
&quot;Labels&quot;:[&quot;storage=ssd&quot;],
|
||
&quot;DockerRootDir&quot;: &quot;/var/lib/docker&quot;,
|
||
&quot;OperatingSystem&quot;: &quot;Boot2Docker&quot;,
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="show-the-docker-version-information">Show the docker version information</h3>
|
||
|
||
<p><code>GET /version</code></p>
|
||
|
||
<p>Show the docker version information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /version HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;ApiVersion&quot;: &quot;1.12&quot;,
|
||
&quot;Version&quot;: &quot;0.2.2&quot;,
|
||
&quot;GitCommit&quot;: &quot;5a2a5cc+CHANGES&quot;,
|
||
&quot;GoVersion&quot;: &quot;go1.0.3&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="ping-the-docker-server">Ping the docker server</h3>
|
||
|
||
<p><code>GET /_ping</code></p>
|
||
|
||
<p>Ping the docker server</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /_ping HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: text/plain
|
||
|
||
OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> - no error</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-new-image-from-a-container-s-changes">Create a new image from a container&rsquo;s changes</h3>
|
||
|
||
<p><code>POST /commit</code></p>
|
||
|
||
<p>Create a new image from a container&rsquo;s changes</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /commit?container=44c004db4b17&amp;comment=message&amp;repo=myrepo HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;Cpuset&quot;: &quot;0,1&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{&quot;Id&quot;: &quot;596069db4bf5&quot;}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>config</strong> - the container&rsquo;s configuration</li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>container</strong> – source container</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
<li><strong>comment</strong> – commit message</li>
|
||
<li><strong>author</strong> – author (e.g., &ldquo;John Hannibal Smith
|
||
&lt;<a href="mailto:hannibal%40a-team.com">hannibal@a-team.com</a>&gt;&ldquo;)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="monitor-docker-s-events">Monitor Docker&rsquo;s events</h3>
|
||
|
||
<p><code>GET /events</code></p>
|
||
|
||
<p>Get container events from docker, either in real time via streaming, or via
|
||
polling (using since).</p>
|
||
|
||
<p>Docker containers will report the following events:</p>
|
||
|
||
<pre><code>create, destroy, die, export, kill, pause, restart, start, stop, unpause
|
||
</code></pre>
|
||
|
||
<p>and Docker images will report:</p>
|
||
|
||
<pre><code>untag, delete
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /events?since=1374067924
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;create&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;start&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;stop&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067966}
|
||
{&quot;status&quot;: &quot;destroy&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067970}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>since</strong> – timestamp used for polling</li>
|
||
<li><strong>until</strong> – timestamp used for polling</li>
|
||
<li><strong>filters</strong> – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
|
||
|
||
<ul>
|
||
<li>event=&lt;string&gt; &ndash; event to filter</li>
|
||
<li>image=&lt;string&gt; &ndash; image to filter</li>
|
||
<li>container=&lt;string&gt; &ndash; container to filter</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images-in-a-repository">Get a tarball containing all images in a repository</h3>
|
||
|
||
<p><code>GET /images/(name)/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for the repository specified
|
||
by <code>name</code>.</p>
|
||
|
||
<p>If <code>name</code> is a specific name and tag (e.g. ubuntu:latest), then only that image
|
||
(and its parents) are returned. If <code>name</code> is an image ID, similarly only that
|
||
image (and its parents) are returned, but with the exclusion of the
|
||
&lsquo;repositories&rsquo; file in the tarball, as there were no image names referenced.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /images/ubuntu/get
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images">Get a tarball containing all images.</h3>
|
||
|
||
<p><code>GET /images/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for one or more repositories.</p>
|
||
|
||
<p>For each value of the <code>names</code> 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 &lsquo;repositories&rsquo; file for this image ID.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /images/get?names=myname%2Fmyapp%3Alatest&amp;names=busybox
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="load-a-tarball-with-a-set-of-images-and-tags-into-docker">Load a tarball with a set of images and tags into docker</h3>
|
||
|
||
<p><code>POST /images/load</code></p>
|
||
|
||
<p>Load a set of images and tags into the docker repository.
|
||
See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> POST /images/load
|
||
|
||
Tarball in body
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="image-tarball-format">Image tarball format</h3>
|
||
|
||
<p>An image tarball contains one directory per image layer (named using its long ID),
|
||
each containing three files:</p>
|
||
|
||
<ol>
|
||
<li><code>VERSION</code>: currently <code>1.0</code> - the file format version</li>
|
||
<li><code>json</code>: detailed layer information, similar to <code>docker inspect layer_id</code></li>
|
||
<li><code>layer.tar</code>: A tarfile containing the filesystem changes in this layer</li>
|
||
</ol>
|
||
|
||
<p>The <code>layer.tar</code> file will contain <code>aufs</code> style <code>.wh..wh.aufs</code> files and directories
|
||
for storing attribute changes and deletions.</p>
|
||
|
||
<p>If the tarball defines a repository, there will also be a <code>repositories</code> file at
|
||
the root that contains a list of repository and tag names mapped to layer IDs.</p>
|
||
|
||
<pre><code>{&quot;hello-world&quot;:
|
||
{&quot;latest&quot;: &quot;565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1&quot;}
|
||
}
|
||
</code></pre>
|
||
|
||
<h3 id="exec-create">Exec Create</h3>
|
||
|
||
<p><code>POST /containers/(id)/exec</code></p>
|
||
|
||
<p>Sets up an exec instance in a running container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/exec HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;: &quot;f90e34656806&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to stdin of the exec command.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to stdout of the exec command.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to stderr of the exec command.</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY</li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
</ul>
|
||
|
||
<h3 id="exec-start">Exec Start</h3>
|
||
|
||
<p><code>POST /exec/(id)/start</code></p>
|
||
|
||
<p>Starts a previously set up exec instance <code>id</code>. If <code>detach</code> is true, this API
|
||
returns after starting the <code>exec</code> command. Otherwise, this API sets up an
|
||
interactive session with the <code>exec</code> command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /exec/e90e34656806/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Detach&quot;: false,
|
||
&quot;Tty&quot;: false,
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Detach</strong> - Detach from the exec command</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
|
||
<li><p><strong>404</strong> – no such exec instance</p>
|
||
|
||
<p><strong>Stream details</strong>:
|
||
Similar to the stream behavior of <code>POST /container/(id)/attach</code> API</p></li>
|
||
</ul>
|
||
|
||
<h3 id="exec-resize">Exec Resize</h3>
|
||
|
||
<p><code>POST /exec/(id)/resize</code></p>
|
||
|
||
<p>Resizes the tty session used by the exec command <code>id</code>.
|
||
This API is valid only if <code>tty</code> was specified as part of creating and starting the exec command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /exec/e90e34656806/resize HTTP/1.1
|
||
Content-Type: plain/text
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: plain/text
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>h</strong> – height of tty session</li>
|
||
<li><strong>w</strong> – width</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such exec instance</li>
|
||
</ul>
|
||
|
||
<h3 id="exec-inspect">Exec Inspect</h3>
|
||
|
||
<p><code>GET /exec/(id)/json</code></p>
|
||
|
||
<p>Return low-level information about the exec command <code>id</code>.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: plain/text
|
||
|
||
{
|
||
&quot;ID&quot; : &quot;11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39&quot;,
|
||
&quot;Running&quot; : false,
|
||
&quot;ExitCode&quot; : 2,
|
||
&quot;ProcessConfig&quot; : {
|
||
&quot;privileged&quot; : false,
|
||
&quot;user&quot; : &quot;&quot;,
|
||
&quot;tty&quot; : false,
|
||
&quot;entrypoint&quot; : &quot;sh&quot;,
|
||
&quot;arguments&quot; : [
|
||
&quot;-c&quot;,
|
||
&quot;exit 2&quot;
|
||
]
|
||
},
|
||
&quot;OpenStdin&quot; : false,
|
||
&quot;OpenStderr&quot; : false,
|
||
&quot;OpenStdout&quot; : false,
|
||
&quot;Container&quot; : {
|
||
&quot;State&quot; : {
|
||
&quot;Running&quot; : true,
|
||
&quot;Paused&quot; : false,
|
||
&quot;Restarting&quot; : false,
|
||
&quot;OOMKilled&quot; : false,
|
||
&quot;Pid&quot; : 3650,
|
||
&quot;ExitCode&quot; : 0,
|
||
&quot;Error&quot; : &quot;&quot;,
|
||
&quot;StartedAt&quot; : &quot;2014-11-17T22:26:03.717657531Z&quot;,
|
||
&quot;FinishedAt&quot; : &quot;0001-01-01T00:00:00Z&quot;
|
||
},
|
||
&quot;ID&quot; : &quot;8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c&quot;,
|
||
&quot;Created&quot; : &quot;2014-11-17T22:26:03.626304998Z&quot;,
|
||
&quot;Path&quot; : &quot;date&quot;,
|
||
&quot;Args&quot; : [],
|
||
&quot;Config&quot; : {
|
||
&quot;Hostname&quot; : &quot;8f177a186b97&quot;,
|
||
&quot;Domainname&quot; : &quot;&quot;,
|
||
&quot;User&quot; : &quot;&quot;,
|
||
&quot;Memory&quot; : 0,
|
||
&quot;MemorySwap&quot; : 0,
|
||
&quot;CpuShares&quot; : 0,
|
||
&quot;Cpuset&quot; : &quot;&quot;,
|
||
&quot;AttachStdin&quot; : false,
|
||
&quot;AttachStdout&quot; : false,
|
||
&quot;AttachStderr&quot; : false,
|
||
&quot;PortSpecs&quot; : null,
|
||
&quot;ExposedPorts&quot; : null,
|
||
&quot;Tty&quot; : false,
|
||
&quot;OpenStdin&quot; : false,
|
||
&quot;StdinOnce&quot; : false,
|
||
&quot;Env&quot; : [ &quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot; ],
|
||
&quot;Cmd&quot; : [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Image&quot; : &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot; : null,
|
||
&quot;WorkingDir&quot; : &quot;&quot;,
|
||
&quot;Entrypoint&quot; : null,
|
||
&quot;NetworkDisabled&quot; : false,
|
||
&quot;MacAddress&quot; : &quot;&quot;,
|
||
&quot;OnBuild&quot; : null,
|
||
&quot;SecurityOpt&quot; : null
|
||
},
|
||
&quot;Image&quot; : &quot;5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5&quot;,
|
||
&quot;NetworkSettings&quot; : {
|
||
&quot;IPAddress&quot; : &quot;172.17.0.2&quot;,
|
||
&quot;IPPrefixLen&quot; : 16,
|
||
&quot;MacAddress&quot; : &quot;02:42:ac:11:00:02&quot;,
|
||
&quot;Gateway&quot; : &quot;172.17.42.1&quot;,
|
||
&quot;Bridge&quot; : &quot;docker0&quot;,
|
||
&quot;PortMapping&quot; : null,
|
||
&quot;Ports&quot; : {}
|
||
},
|
||
&quot;ResolvConfPath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf&quot;,
|
||
&quot;HostnamePath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname&quot;,
|
||
&quot;HostsPath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts&quot;,
|
||
&quot;Name&quot; : &quot;/test&quot;,
|
||
&quot;Driver&quot; : &quot;aufs&quot;,
|
||
&quot;ExecDriver&quot; : &quot;native-0.2&quot;,
|
||
&quot;MountLabel&quot; : &quot;&quot;,
|
||
&quot;ProcessLabel&quot; : &quot;&quot;,
|
||
&quot;AppArmorProfile&quot; : &quot;&quot;,
|
||
&quot;RestartCount&quot; : 0,
|
||
&quot;Volumes&quot; : {},
|
||
&quot;VolumesRW&quot; : {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such exec instance</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h1 id="3-going-further">3. Going further</h1>
|
||
|
||
<h2 id="3-1-inside-docker-run">3.1 Inside <code>docker run</code></h2>
|
||
|
||
<p>As an example, the <code>docker run</code> command line makes the following API calls:</p>
|
||
|
||
<ul>
|
||
<li><p>Create the container</p></li>
|
||
|
||
<li><p>If the status code is 404, it means the image doesn&rsquo;t exist:</p>
|
||
|
||
<ul>
|
||
<li>Try to pull it</li>
|
||
<li>Then retry to create the container</li>
|
||
</ul></li>
|
||
|
||
<li><p>Start the container</p></li>
|
||
|
||
<li><p>If you are not in detached mode:</p></li>
|
||
|
||
<li><p>Attach to the container, using logs=1 (to have stdout and
|
||
stderr from the container&rsquo;s start) and stream=1</p></li>
|
||
|
||
<li><p>If in detached mode or only stdin is attached:</p></li>
|
||
|
||
<li><p>Display the container&rsquo;s id</p></li>
|
||
</ul>
|
||
|
||
<h2 id="3-2-hijacking">3.2 Hijacking</h2>
|
||
|
||
<p>In this version of the API, /attach, uses hijacking to transport stdin,
|
||
stdout and stderr on the same socket. This might change in the future.</p>
|
||
|
||
<h2 id="3-3-cors-requests">3.3 CORS Requests</h2>
|
||
|
||
<p>To enable cross origin requests to the remote api add the flag
|
||
&ldquo;&ndash;api-enable-cors&rdquo; when running docker in daemon mode.</p>
|
||
|
||
<pre><code>$ docker -d -H=&quot;192.168.1.9:2375&quot; --api-enable-cors
|
||
</code></pre>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Remote API v1.17</title>
|
||
<link>http://localhost/reference/api/docker_remote_api_v1.17/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/docker_remote_api_v1.17/</guid>
|
||
<description>
|
||
|
||
<h1 id="docker-remote-api-v1-17">Docker Remote API v1.17</h1>
|
||
|
||
<h2 id="1-brief-introduction">1. Brief introduction</h2>
|
||
|
||
<ul>
|
||
<li>The Remote API has replaced <code>rcli</code>.</li>
|
||
<li>The daemon listens on <code>unix:///var/run/docker.sock</code> but you can
|
||
<a href="http://localhost/articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket">Bind Docker to another host/port or a Unix socket</a>.</li>
|
||
<li>The API tends to be REST, but for some complex commands, like <code>attach</code>
|
||
or <code>pull</code>, the HTTP connection is hijacked to transport <code>STDOUT</code>,
|
||
<code>STDIN</code> and <code>STDERR</code>.</li>
|
||
</ul>
|
||
|
||
<h1 id="2-endpoints">2. Endpoints</h1>
|
||
|
||
<h2 id="2-1-containers">2.1 Containers</h2>
|
||
|
||
<h3 id="list-containers">List containers</h3>
|
||
|
||
<p><code>GET /containers/json</code></p>
|
||
|
||
<p>List containers</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/json?all=1&amp;before=8dfafdbc3a40&amp;size=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;8dfafdbc3a40&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 1&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [{&quot;PrivatePort&quot;: 2222, &quot;PublicPort&quot;: 3333, &quot;Type&quot;: &quot;tcp&quot;}],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;9cd87474be90&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 222222&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;3176a2479c92&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 3333333333333333&quot;,
|
||
&quot;Created&quot;: 1367854154,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;:[],
|
||
&quot;SizeRw&quot;:12288,
|
||
&quot;SizeRootFs&quot;:0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;4cb07b47f9fb&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 444444444444444444444444444444444&quot;,
|
||
&quot;Created&quot;: 1367854152,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, Show all containers.
|
||
Only running containers are shown by default (i.e., this defaults to false)</li>
|
||
<li><strong>limit</strong> – Show <code>limit</code> last created
|
||
containers, include non-running ones.</li>
|
||
<li><strong>since</strong> – Show only containers created since Id, include
|
||
non-running ones.</li>
|
||
<li><strong>before</strong> – Show only containers created before Id, include
|
||
non-running ones.</li>
|
||
<li><strong>size</strong> – 1/True/true or 0/False/false, Show the containers
|
||
sizes</li>
|
||
<li><strong>filters</strong> - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
|
||
|
||
<ul>
|
||
<li>exited=&lt;int&gt; &ndash; containers with exit code of &lt;int&gt;</li>
|
||
<li>status=(restarting|running|paused|exited)</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-container">Create a container</h3>
|
||
|
||
<p><code>POST /containers/create</code></p>
|
||
|
||
<p>Create a container</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/create HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;Cpuset&quot;: &quot;0,1&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Entrypoint&quot;: &quot;&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;MacAddress&quot;: &quot;12:34:56:78:9a:bc&quot;,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
},
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;ReadonlyRootfs&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: []
|
||
&quot;SecurityOpt&quot;: [&quot;&quot;],
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;:&quot;e90e34656806&quot;
|
||
&quot;Warnings&quot;:[]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Hostname</strong> - A string value containing the desired hostname to use for the
|
||
container.</li>
|
||
<li><strong>Domainname</strong> - A string value containing the desired domain name to use
|
||
for the container.</li>
|
||
<li><strong>User</strong> - A string value containing the user to use inside the container.</li>
|
||
<li><strong>Memory</strong> - Memory limit in bytes.</li>
|
||
<li><strong>MemorySwap</strong>- Total memory limit (memory + swap); set <code>-1</code> to disable swap,
|
||
always use this with <code>memory</code>, and make the value larger than <code>memory</code>.</li>
|
||
<li><strong>CpuShares</strong> - An integer value containing the CPU Shares for container
|
||
(ie. the relative weight vs other containers).
|
||
<strong>CpuSet</strong> - String value containing the cgroups Cpuset to use.</li>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to stdin.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to stdout.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to stderr.</li>
|
||
<li><strong>Tty</strong> - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.</li>
|
||
<li><strong>OpenStdin</strong> - Boolean value, opens stdin,</li>
|
||
<li><strong>StdinOnce</strong> - Boolean value, close stdin after the 1 attached client disconnects.</li>
|
||
<li><strong>Env</strong> - A list of environment variables in the form of <code>VAR=value</code></li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
<li><strong>Entrypoint</strong> - Set the entrypoint for the container a a string or an array
|
||
of strings</li>
|
||
<li><strong>Image</strong> - String value containing the image name to use for the container</li>
|
||
<li><strong>Volumes</strong> – An object mapping mountpoint paths (strings) inside the
|
||
container to empty objects.</li>
|
||
<li><strong>WorkingDir</strong> - A string value containing the working dir for commands to
|
||
run in.</li>
|
||
<li><strong>NetworkDisabled</strong> - Boolean value, when true disables networking for the
|
||
container</li>
|
||
<li><strong>ExposedPorts</strong> - An object mapping ports to an empty object in the form of:
|
||
<code>&quot;ExposedPorts&quot;: { &quot;&lt;port&gt;/&lt;tcp|udp&gt;: {}&quot; }</code></li>
|
||
<li><strong>HostConfig</strong>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume
|
||
binding is a string of the form <code>container_path</code> (to create a new
|
||
volume for the container), <code>host_path:container_path</code> (to bind-mount
|
||
a host path into the container), or <code>host_path:container_path:ro</code>
|
||
(to make the bind-mount read-only inside the container).</li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be
|
||
in the form of &ldquo;container_name:alias&rdquo;.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations will only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. It should be specified in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>ReadonlyRootfs</strong> - Mount the container&rsquo;s root filesystem as read only.
|
||
Specified as a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of dns servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains</li>
|
||
<li><strong>ExtraHosts</strong> - A list of hostnames/IP mappings to be added to the
|
||
container&rsquo;s <code>/etc/hosts</code> file. Specified in the form <code>[&quot;hostname:IP&quot;]</code>.</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
<li><strong>SecurityOpt</strong>: A list of string values to customize labels for MLS
|
||
systems, such as SELinux.</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>name</strong> – Assign the specified name to the container. Must
|
||
match <code>/?[a-zA-Z0-9_-]+</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>406</strong> – impossible to attach (container not running)</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-a-container">Inspect a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/json</code></p>
|
||
|
||
<p>Return low-level information on the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;AppArmorProfile&quot;: &quot;&quot;,
|
||
&quot;Args&quot;: [
|
||
&quot;-c&quot;,
|
||
&quot;exit 9&quot;
|
||
],
|
||
&quot;Config&quot;: {
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;Cmd&quot;: [
|
||
&quot;/bin/sh&quot;,
|
||
&quot;-c&quot;,
|
||
&quot;exit 9&quot;
|
||
],
|
||
&quot;CpuShares&quot;: 0,
|
||
&quot;Cpuset&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;Entrypoint&quot;: null,
|
||
&quot;Env&quot;: [
|
||
&quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;
|
||
],
|
||
&quot;ExposedPorts&quot;: null,
|
||
&quot;Hostname&quot;: &quot;ba033ac44011&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;MacAddress&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;OnBuild&quot;: null,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Tty&quot;: false,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Volumes&quot;: null,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;Created&quot;: &quot;2015-01-06T15:47:31.485331387Z&quot;,
|
||
&quot;Driver&quot;: &quot;devicemapper&quot;,
|
||
&quot;ExecDriver&quot;: &quot;native-0.2&quot;,
|
||
&quot;ExecIDs&quot;: null,
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: null,
|
||
&quot;CapAdd&quot;: null,
|
||
&quot;CapDrop&quot;: null,
|
||
&quot;ContainerIDFile&quot;: &quot;&quot;,
|
||
&quot;Devices&quot;: [],
|
||
&quot;Dns&quot;: null,
|
||
&quot;DnsSearch&quot;: null,
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;IpcMode&quot;: &quot;&quot;,
|
||
&quot;Links&quot;: null,
|
||
&quot;LxcConf&quot;: [],
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;PortBindings&quot;: {},
|
||
&quot;Privileged&quot;: false,
|
||
&quot;ReadonlyRootfs&quot;: false,
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;RestartPolicy&quot;: {
|
||
&quot;MaximumRetryCount&quot;: 2,
|
||
&quot;Name&quot;: &quot;on-failure&quot;
|
||
},
|
||
&quot;SecurityOpt&quot;: null,
|
||
&quot;VolumesFrom&quot;: null
|
||
},
|
||
&quot;HostnamePath&quot;: &quot;/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname&quot;,
|
||
&quot;HostsPath&quot;: &quot;/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts&quot;,
|
||
&quot;Id&quot;: &quot;ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39&quot;,
|
||
&quot;Image&quot;: &quot;04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2&quot;,
|
||
&quot;MountLabel&quot;: &quot;&quot;,
|
||
&quot;Name&quot;: &quot;/boring_euclid&quot;,
|
||
&quot;NetworkSettings&quot;: {
|
||
&quot;Bridge&quot;: &quot;&quot;,
|
||
&quot;Gateway&quot;: &quot;&quot;,
|
||
&quot;IPAddress&quot;: &quot;&quot;,
|
||
&quot;IPPrefixLen&quot;: 0,
|
||
&quot;MacAddress&quot;: &quot;&quot;,
|
||
&quot;PortMapping&quot;: null,
|
||
&quot;Ports&quot;: null
|
||
},
|
||
&quot;Path&quot;: &quot;/bin/sh&quot;,
|
||
&quot;ProcessLabel&quot;: &quot;&quot;,
|
||
&quot;ResolvConfPath&quot;: &quot;/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf&quot;,
|
||
&quot;RestartCount&quot;: 1,
|
||
&quot;State&quot;: {
|
||
&quot;Error&quot;: &quot;&quot;,
|
||
&quot;ExitCode&quot;: 9,
|
||
&quot;FinishedAt&quot;: &quot;2015-01-06T15:47:32.080254511Z&quot;,
|
||
&quot;OOMKilled&quot;: false,
|
||
&quot;Paused&quot;: false,
|
||
&quot;Pid&quot;: 0,
|
||
&quot;Restarting&quot;: false,
|
||
&quot;Running&quot;: false,
|
||
&quot;StartedAt&quot;: &quot;2015-01-06T15:47:32.072697474Z&quot;
|
||
},
|
||
&quot;Volumes&quot;: {},
|
||
&quot;VolumesRW&quot;: {}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="list-processes-running-inside-a-container">List processes running inside a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/top</code></p>
|
||
|
||
<p>List processes running inside the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/top HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Titles&quot;: [
|
||
&quot;USER&quot;,
|
||
&quot;PID&quot;,
|
||
&quot;%CPU&quot;,
|
||
&quot;%MEM&quot;,
|
||
&quot;VSZ&quot;,
|
||
&quot;RSS&quot;,
|
||
&quot;TTY&quot;,
|
||
&quot;STAT&quot;,
|
||
&quot;START&quot;,
|
||
&quot;TIME&quot;,
|
||
&quot;COMMAND&quot;
|
||
],
|
||
&quot;Processes&quot;: [
|
||
[&quot;root&quot;,&quot;20147&quot;,&quot;0.0&quot;,&quot;0.1&quot;,&quot;18060&quot;,&quot;1864&quot;,&quot;pts/4&quot;,&quot;S&quot;,&quot;10:06&quot;,&quot;0:00&quot;,&quot;bash&quot;],
|
||
[&quot;root&quot;,&quot;20271&quot;,&quot;0.0&quot;,&quot;0.0&quot;,&quot;4312&quot;,&quot;352&quot;,&quot;pts/4&quot;,&quot;S+&quot;,&quot;10:07&quot;,&quot;0:00&quot;,&quot;sleep&quot;,&quot;10&quot;]
|
||
]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>ps_args</strong> – ps arguments to use (e.g., aux)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-container-logs">Get container logs</h3>
|
||
|
||
<p><code>GET /containers/(id)/logs</code></p>
|
||
|
||
<p>Get stdout and stderr logs from the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/logs?stderr=1&amp;stdout=1&amp;timestamps=1&amp;follow=1&amp;tail=10 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 101 UPGRADED
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
Connection: Upgrade
|
||
Upgrade: tcp
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>follow</strong> – 1/True/true or 0/False/false, return stream. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, show stdout log. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, show stderr log. Default false</li>
|
||
<li><strong>timestamps</strong> – 1/True/true or 0/False/false, print timestamps for
|
||
every log line. Default false</li>
|
||
<li><strong>tail</strong> – Output specified number of lines at the end of logs: <code>all</code> or <code>&lt;number&gt;</code>. Default all</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>101</strong> – no error, hints proxy about hijacking</li>
|
||
<li><strong>200</strong> – no error, no upgrade header found</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-changes-on-a-container-s-filesystem">Inspect changes on a container&rsquo;s filesystem</h3>
|
||
|
||
<p><code>GET /containers/(id)/changes</code></p>
|
||
|
||
<p>Inspect changes on container <code>id</code>&rsquo;s filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/changes HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Path&quot;: &quot;/dev&quot;,
|
||
&quot;Kind&quot;: 0
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/dev/kmsg&quot;,
|
||
&quot;Kind&quot;: 1
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/test&quot;,
|
||
&quot;Kind&quot;: 1
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="export-a-container">Export a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/export</code></p>
|
||
|
||
<p>Export the contents of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/export HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/octet-stream
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-container-stats-based-on-resource-usage">Get container stats based on resource usage</h3>
|
||
|
||
<p><code>GET /containers/(id)/stats</code></p>
|
||
|
||
<p>This endpoint returns a live stream of a container&rsquo;s resource usage statistics.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/redis1/stats HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;read&quot; : &quot;2015-01-08T22:57:31.547920715Z&quot;,
|
||
&quot;network&quot; : {
|
||
&quot;rx_dropped&quot; : 0,
|
||
&quot;rx_bytes&quot; : 648,
|
||
&quot;rx_errors&quot; : 0,
|
||
&quot;tx_packets&quot; : 8,
|
||
&quot;tx_dropped&quot; : 0,
|
||
&quot;rx_packets&quot; : 8,
|
||
&quot;tx_errors&quot; : 0,
|
||
&quot;tx_bytes&quot; : 648
|
||
},
|
||
&quot;memory_stats&quot; : {
|
||
&quot;stats&quot; : {
|
||
&quot;total_pgmajfault&quot; : 0,
|
||
&quot;cache&quot; : 0,
|
||
&quot;mapped_file&quot; : 0,
|
||
&quot;total_inactive_file&quot; : 0,
|
||
&quot;pgpgout&quot; : 414,
|
||
&quot;rss&quot; : 6537216,
|
||
&quot;total_mapped_file&quot; : 0,
|
||
&quot;writeback&quot; : 0,
|
||
&quot;unevictable&quot; : 0,
|
||
&quot;pgpgin&quot; : 477,
|
||
&quot;total_unevictable&quot; : 0,
|
||
&quot;pgmajfault&quot; : 0,
|
||
&quot;total_rss&quot; : 6537216,
|
||
&quot;total_rss_huge&quot; : 6291456,
|
||
&quot;total_writeback&quot; : 0,
|
||
&quot;total_inactive_anon&quot; : 0,
|
||
&quot;rss_huge&quot; : 6291456,
|
||
&quot;hierarchical_memory_limit&quot; : 67108864,
|
||
&quot;total_pgfault&quot; : 964,
|
||
&quot;total_active_file&quot; : 0,
|
||
&quot;active_anon&quot; : 6537216,
|
||
&quot;total_active_anon&quot; : 6537216,
|
||
&quot;total_pgpgout&quot; : 414,
|
||
&quot;total_cache&quot; : 0,
|
||
&quot;inactive_anon&quot; : 0,
|
||
&quot;active_file&quot; : 0,
|
||
&quot;pgfault&quot; : 964,
|
||
&quot;inactive_file&quot; : 0,
|
||
&quot;total_pgpgin&quot; : 477
|
||
},
|
||
&quot;max_usage&quot; : 6651904,
|
||
&quot;usage&quot; : 6537216,
|
||
&quot;failcnt&quot; : 0,
|
||
&quot;limit&quot; : 67108864
|
||
},
|
||
&quot;blkio_stats&quot; : {},
|
||
&quot;cpu_stats&quot; : {
|
||
&quot;cpu_usage&quot; : {
|
||
&quot;percpu_usage&quot; : [
|
||
16970827,
|
||
1839451,
|
||
7107380,
|
||
10571290
|
||
],
|
||
&quot;usage_in_usermode&quot; : 10000000,
|
||
&quot;total_usage&quot; : 36488948,
|
||
&quot;usage_in_kernelmode&quot; : 20000000
|
||
},
|
||
&quot;system_cpu_usage&quot; : 20091722000000000,
|
||
&quot;throttling_data&quot; : {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="resize-a-container-tty">Resize a container TTY</h3>
|
||
|
||
<p><code>POST /containers/(id)/resize?h=&lt;height&gt;&amp;w=&lt;width&gt;</code></p>
|
||
|
||
<p>Resize the TTY for container with <code>id</code>. The container must be restarted for the resize to take effect.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/4fa6e0f0c678/resize?h=40&amp;w=80 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Length: 0
|
||
Content-Type: text/plain; charset=utf-8
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – No such container</li>
|
||
<li><strong>500</strong> – Cannot resize container</li>
|
||
</ul>
|
||
|
||
<h3 id="start-a-container">Start a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/start</code></p>
|
||
|
||
<p>Start the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/(id)/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;ReadonlyRootfs&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: []
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume
|
||
binding is a string of the form <code>container_path</code> (to create a new
|
||
volume for the container), <code>host_path:container_path</code> (to bind-mount
|
||
a host path into the container), or <code>host_path:container_path:ro</code>
|
||
(to make the bind-mount read-only inside the container).</li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be of
|
||
of the form &ldquo;container_name:alias&rdquo;.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations will only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. It should be specified in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>ReadonlyRootfs</strong> - Mount the container&rsquo;s root filesystem as read only.
|
||
Specified as a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of dns servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already started</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="stop-a-container">Stop a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/stop</code></p>
|
||
|
||
<p>Stop the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/stop?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already stopped</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="restart-a-container">Restart a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/restart</code></p>
|
||
|
||
<p>Restart the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/restart?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="kill-a-container">Kill a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/kill</code></p>
|
||
|
||
<p>Kill the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/kill HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters</p>
|
||
|
||
<ul>
|
||
<li><strong>signal</strong> - Signal to send to the container: integer or string like &ldquo;SIGINT&rdquo;.
|
||
When not set, SIGKILL is assumed and the call will waits for the container to exit.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="rename-a-container">Rename a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/rename</code></p>
|
||
|
||
<p>Rename the container <code>id</code> to a <code>new_name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>name</strong> – new name for the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>409</strong> - conflict name already assigned</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="pause-a-container">Pause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/pause</code></p>
|
||
|
||
<p>Pause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/pause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="unpause-a-container">Unpause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/unpause</code></p>
|
||
|
||
<p>Unpause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/unpause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container">Attach to a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/attach</code></p>
|
||
|
||
<p>Attach to the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/attach?logs=1&amp;stream=0&amp;stdout=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 101 UPGRADED
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
Connection: Upgrade
|
||
Upgrade: tcp
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach
|
||
to stdin. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>101</strong> – no error, hints proxy about hijacking</li>
|
||
<li><strong>200</strong> – no error, no upgrade header found</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
|
||
<li><p><strong>500</strong> – server error</p>
|
||
|
||
<p><strong>Stream details</strong>:</p>
|
||
|
||
<p>When using the TTY setting is enabled in
|
||
<a href="http://localhost/docker/reference/api/docker_remote_api_v1.9/#create-a-container" title="POST /containers/create"><code>POST /containers/create</code>
|
||
</a>,
|
||
the stream is the raw data from the process PTY and client&rsquo;s stdin.
|
||
When the TTY is disabled, then the stream is multiplexed to separate
|
||
stdout and stderr.</p>
|
||
|
||
<p>The format is a <strong>Header</strong> and a <strong>Payload</strong> (frame).</p>
|
||
|
||
<p><strong>HEADER</strong></p>
|
||
|
||
<p>The header will contain the information on which stream write the
|
||
stream (stdout or stderr). It also contain the size of the
|
||
associated frame encoded on the last 4 bytes (uint32).</p>
|
||
|
||
<p>It is encoded on the first 8 bytes like this:</p>
|
||
|
||
<pre><code>header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
|
||
</code></pre>
|
||
|
||
<p><code>STREAM_TYPE</code> can be:</p></li>
|
||
|
||
<li><p>0: stdin (will be written on stdout)</p></li>
|
||
|
||
<li><p>1: stdout</p></li>
|
||
|
||
<li><p>2: stderr</p>
|
||
|
||
<p><code>SIZE1, SIZE2, SIZE3, SIZE4</code> are the 4 bytes of
|
||
the uint32 size encoded as big endian.</p>
|
||
|
||
<p><strong>PAYLOAD</strong></p>
|
||
|
||
<p>The payload is the raw stream.</p>
|
||
|
||
<p><strong>IMPLEMENTATION</strong></p>
|
||
|
||
<p>The simplest way to implement the Attach protocol is the following:</p>
|
||
|
||
<ol>
|
||
<li>Read 8 bytes</li>
|
||
<li>chose stdout or stderr depending on the first byte</li>
|
||
<li>Extract the frame size from the last 4 bytes</li>
|
||
<li>Read the extracted size and output it on the correct output</li>
|
||
<li>Goto 1</li>
|
||
</ol></li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container-websocket">Attach to a container (websocket)</h3>
|
||
|
||
<p><code>GET /containers/(id)/attach/ws</code></p>
|
||
|
||
<p>Attach to the container <code>id</code> via websocket</p>
|
||
|
||
<p>Implements websocket protocol handshake according to <a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a></p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /containers/e90e34656806/attach/ws?logs=0&amp;stream=1&amp;stdin=1&amp;stdout=1&amp;stderr=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong></p>
|
||
|
||
<pre><code> {{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach
|
||
to stdin. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="wait-a-container">Wait a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/wait</code></p>
|
||
|
||
<p>Block until container <code>id</code> stops, then returns the exit code</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/wait HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;StatusCode&quot;: 0}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-a-container">Remove a container</h3>
|
||
|
||
<p><code>DELETE /containers/(id)</code></p>
|
||
|
||
<p>Remove the container <code>id</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /containers/16253994b7c4?v=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>v</strong> – 1/True/true or 0/False/false, Remove the volumes
|
||
associated to the container. Default false</li>
|
||
<li><strong>force</strong> - 1/True/true or 0/False/false, Kill then remove the container.
|
||
Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="copy-files-or-folders-from-a-container">Copy files or folders from a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/copy</code></p>
|
||
|
||
<p>Copy files or folders of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/4fa6e0f0c678/copy HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Resource&quot;: &quot;test.txt&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-2-images">2.2 Images</h2>
|
||
|
||
<h3 id="list-images">List Images</h3>
|
||
|
||
<p><code>GET /images/json</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/json?all=0 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.04&quot;,
|
||
&quot;ubuntu:precise&quot;,
|
||
&quot;ubuntu:latest&quot;
|
||
],
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;VirtualSize&quot;: 131506275
|
||
},
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.10&quot;,
|
||
&quot;ubuntu:quantal&quot;
|
||
],
|
||
&quot;ParentId&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;Size&quot;: 24653,
|
||
&quot;VirtualSize&quot;: 180116135
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>filters</strong> – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
|
||
|
||
<ul>
|
||
<li>dangling=true</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<h3 id="build-image-from-a-dockerfile">Build image from a Dockerfile</h3>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p>Build an image from a Dockerfile</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /build HTTP/1.1
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;stream&quot;: &quot;Step 1...&quot;}
|
||
{&quot;stream&quot;: &quot;...&quot;}
|
||
{&quot;error&quot;: &quot;Error...&quot;, &quot;errorDetail&quot;: {&quot;code&quot;: 123, &quot;message&quot;: &quot;Error...&quot;}}
|
||
</code></pre>
|
||
|
||
<p>The input stream must be a tar archive compressed with one of the
|
||
following algorithms: identity (no compression), gzip, bzip2, xz.</p>
|
||
|
||
<p>The archive must include a build instructions file, typically called
|
||
<code>Dockerfile</code> at the root of the archive. The <code>dockerfile</code> parameter may be
|
||
used to specify a different build instructions file by having its value be
|
||
the path to the alternate build instructions file to use.</p>
|
||
|
||
<p>The archive may include any number of other files,
|
||
which will be accessible in the build context (See the <a href="http://localhost/docker/reference/builder/#dockerbuilder"><em>ADD build
|
||
command</em></a>).</p>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>dockerfile</strong> - path within the build context to the Dockerfile</li>
|
||
<li><strong>t</strong> – repository name (and optionally a tag) to be applied to
|
||
the resulting image in case of success</li>
|
||
<li><strong>remote</strong> – git or HTTP/HTTPS URI build source</li>
|
||
<li><strong>q</strong> – suppress verbose build output</li>
|
||
<li><strong>nocache</strong> – do not use the cache when building the image</li>
|
||
<li><strong>pull</strong> - attempt to pull the image even if an older image exists locally</li>
|
||
<li><strong>rm</strong> - remove intermediate containers after a successful build (default behavior)</li>
|
||
|
||
<li><p><strong>forcerm</strong> - always remove intermediate containers (includes rm)</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>Content-type</strong> – should be set to <code>&quot;application/tar&quot;</code>.</p></li>
|
||
|
||
<li><p><strong>X-Registry-Config</strong> – base64-encoded ConfigFile object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-an-image">Create an image</h3>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p>Create an image, either by pulling it from the registry or by importing it</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/create?fromImage=ubuntu HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pulling...&quot;}
|
||
{&quot;status&quot;: &quot;Pulling&quot;, &quot;progress&quot;: &quot;1 B/ 100 B&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1, &quot;total&quot;: 100}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
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.
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>fromImage</strong> – name of the image to pull</li>
|
||
<li><strong>fromSrc</strong> – source to import. The value may be a URL from which the image
|
||
can be retrieved or <code>-</code> to read the image from the request body.</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
|
||
<li><p><strong>registry</strong> – the registry to pull from</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>X-Registry-Auth</strong> – base64-encoded AuthConfig object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-an-image">Inspect an image</h3>
|
||
|
||
<p><code>GET /images/(name)/json</code></p>
|
||
|
||
<p>Return low-level information on the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Created&quot;: &quot;2013-03-23T22:24:18.818426-07:00&quot;,
|
||
&quot;Container&quot;: &quot;3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0&quot;,
|
||
&quot;ContainerConfig&quot;:
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: false,
|
||
&quot;AttachStderr&quot;: false,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: true,
|
||
&quot;OpenStdin&quot;: true,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [&quot;/bin/bash&quot;],
|
||
&quot;Dns&quot;: null,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot;: null,
|
||
&quot;VolumesFrom&quot;: &quot;&quot;,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Parent&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Size&quot;: 6824592
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-the-history-of-an-image">Get the history of an image</h3>
|
||
|
||
<p><code>GET /images/(name)/history</code></p>
|
||
|
||
<p>Return the history of the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/history HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;b750fe79269d&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;CreatedBy&quot;: &quot;/bin/bash&quot;
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;27cf78414709&quot;,
|
||
&quot;Created&quot;: 1364068391,
|
||
&quot;CreatedBy&quot;: &quot;&quot;
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="push-an-image-on-the-registry">Push an image on the registry</h3>
|
||
|
||
<p><code>POST /images/(name)/push</code></p>
|
||
|
||
<p>Push the image <code>name</code> on the registry</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pushing...&quot;}
|
||
{&quot;status&quot;: &quot;Pushing&quot;, &quot;progress&quot;: &quot;1/? (n/a)&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1}}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
If you wish to push an image on to a private registry, that image must already have been tagged
|
||
into a repository which references that registry host name and port. This repository name should
|
||
then be used in the URL. This mirrors the flow of the CLI.
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/registry.acme.com:5000/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>tag</strong> – the tag to associate with the image on the registry, optional</li>
|
||
</ul>
|
||
|
||
<p>Request Headers:</p>
|
||
|
||
<ul>
|
||
<li><strong>X-Registry-Auth</strong> – include a base64-encoded AuthConfig
|
||
object.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="tag-an-image-into-a-repository">Tag an image into a repository</h3>
|
||
|
||
<p><code>POST /images/(name)/tag</code></p>
|
||
|
||
<p>Tag the image <code>name</code> into a repository</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/tag?repo=myrepo&amp;force=0&amp;tag=v42 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo</strong> – The repository to tag in</li>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>tag</strong> - The new tag name</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-an-image">Remove an image</h3>
|
||
|
||
<p><code>DELETE /images/(name)</code></p>
|
||
|
||
<p>Remove the image <code>name</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /images/test HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-type: application/json
|
||
|
||
[
|
||
{&quot;Untagged&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;53b4f83ac9&quot;}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>noprune</strong> – 1/True/true or 0/False/false, default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="search-images">Search images</h3>
|
||
|
||
<p><code>GET /images/search</code></p>
|
||
|
||
<p>Search for an image on <a href="https://hub.docker.com">Docker Hub</a>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
The response keys have changed from API v1.6 to reflect the JSON
|
||
sent by the registry server to the docker daemon&rsquo;s request.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/search?term=sshd HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;wma55/u1210sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;jdswinbank/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;vgauthier/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
}
|
||
...
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>term</strong> – term to search</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-3-misc">2.3 Misc</h2>
|
||
|
||
<h3 id="check-auth-configuration">Check auth configuration</h3>
|
||
|
||
<p><code>POST /auth</code></p>
|
||
|
||
<p>Get the default username and email</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /auth HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;username&quot;:&quot; hannibal&quot;,
|
||
&quot;password: &quot;xxxx&quot;,
|
||
&quot;email&quot;: &quot;hannibal@a-team.com&quot;,
|
||
&quot;serveraddress&quot;: &quot;https://index.docker.io/v1/&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="display-system-wide-information">Display system-wide information</h3>
|
||
|
||
<p><code>GET /info</code></p>
|
||
|
||
<p>Display system-wide information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /info HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Containers&quot;:11,
|
||
&quot;Images&quot;:16,
|
||
&quot;Driver&quot;:&quot;btrfs&quot;,
|
||
&quot;DriverStatus&quot;: [[&quot;&quot;]],
|
||
&quot;ExecutionDriver&quot;:&quot;native-0.1&quot;,
|
||
&quot;KernelVersion&quot;:&quot;3.12.0-1-amd64&quot;
|
||
&quot;NCPU&quot;:1,
|
||
&quot;MemTotal&quot;:2099236864,
|
||
&quot;Name&quot;:&quot;prod-server-42&quot;,
|
||
&quot;ID&quot;:&quot;7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS&quot;,
|
||
&quot;Debug&quot;:false,
|
||
&quot;NFd&quot;: 11,
|
||
&quot;NGoroutines&quot;:21,
|
||
&quot;NEventsListener&quot;:0,
|
||
&quot;InitPath&quot;:&quot;/usr/bin/docker&quot;,
|
||
&quot;InitSha1&quot;:&quot;&quot;,
|
||
&quot;IndexServerAddress&quot;:[&quot;https://index.docker.io/v1/&quot;],
|
||
&quot;MemoryLimit&quot;:true,
|
||
&quot;SwapLimit&quot;:false,
|
||
&quot;IPv4Forwarding&quot;:true,
|
||
&quot;Labels&quot;:[&quot;storage=ssd&quot;],
|
||
&quot;DockerRootDir&quot;: &quot;/var/lib/docker&quot;,
|
||
&quot;OperatingSystem&quot;: &quot;Boot2Docker&quot;,
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="show-the-docker-version-information">Show the docker version information</h3>
|
||
|
||
<p><code>GET /version</code></p>
|
||
|
||
<p>Show the docker version information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /version HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;ApiVersion&quot;: &quot;1.12&quot;,
|
||
&quot;Version&quot;: &quot;0.2.2&quot;,
|
||
&quot;GitCommit&quot;: &quot;5a2a5cc+CHANGES&quot;,
|
||
&quot;GoVersion&quot;: &quot;go1.0.3&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="ping-the-docker-server">Ping the docker server</h3>
|
||
|
||
<p><code>GET /_ping</code></p>
|
||
|
||
<p>Ping the docker server</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /_ping HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: text/plain
|
||
|
||
OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> - no error</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-new-image-from-a-container-s-changes">Create a new image from a container&rsquo;s changes</h3>
|
||
|
||
<p><code>POST /commit</code></p>
|
||
|
||
<p>Create a new image from a container&rsquo;s changes</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /commit?container=44c004db4b17&amp;comment=message&amp;repo=myrepo HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;Cpuset&quot;: &quot;0,1&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{&quot;Id&quot;: &quot;596069db4bf5&quot;}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>config</strong> - the container&rsquo;s configuration</li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>container</strong> – source container</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
<li><strong>comment</strong> – commit message</li>
|
||
<li><strong>author</strong> – author (e.g., &ldquo;John Hannibal Smith
|
||
&lt;<a href="mailto:hannibal%40a-team.com">hannibal@a-team.com</a>&gt;&ldquo;)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="monitor-docker-s-events">Monitor Docker&rsquo;s events</h3>
|
||
|
||
<p><code>GET /events</code></p>
|
||
|
||
<p>Get container events from docker, either in real time via streaming, or via
|
||
polling (using since).</p>
|
||
|
||
<p>Docker containers will report the following events:</p>
|
||
|
||
<pre><code>create, destroy, die, exec_create, exec_start, export, kill, oom, pause, restart, start, stop, unpause
|
||
</code></pre>
|
||
|
||
<p>and Docker images will report:</p>
|
||
|
||
<pre><code>untag, delete
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /events?since=1374067924
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;create&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;start&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;stop&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067966}
|
||
{&quot;status&quot;: &quot;destroy&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067970}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>since</strong> – timestamp used for polling</li>
|
||
<li><strong>until</strong> – timestamp used for polling</li>
|
||
<li><strong>filters</strong> – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
|
||
|
||
<ul>
|
||
<li>event=&lt;string&gt; &ndash; event to filter</li>
|
||
<li>image=&lt;string&gt; &ndash; image to filter</li>
|
||
<li>container=&lt;string&gt; &ndash; container to filter</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images-in-a-repository">Get a tarball containing all images in a repository</h3>
|
||
|
||
<p><code>GET /images/(name)/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for the repository specified
|
||
by <code>name</code>.</p>
|
||
|
||
<p>If <code>name</code> is a specific name and tag (e.g. ubuntu:latest), then only that image
|
||
(and its parents) are returned. If <code>name</code> is an image ID, similarly only that
|
||
image (and its parents) are returned, but with the exclusion of the
|
||
&lsquo;repositories&rsquo; file in the tarball, as there were no image names referenced.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /images/ubuntu/get
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images">Get a tarball containing all images.</h3>
|
||
|
||
<p><code>GET /images/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for one or more repositories.</p>
|
||
|
||
<p>For each value of the <code>names</code> 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 &lsquo;repositories&rsquo; file for this image ID.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /images/get?names=myname%2Fmyapp%3Alatest&amp;names=busybox
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="load-a-tarball-with-a-set-of-images-and-tags-into-docker">Load a tarball with a set of images and tags into docker</h3>
|
||
|
||
<p><code>POST /images/load</code></p>
|
||
|
||
<p>Load a set of images and tags into the docker repository.
|
||
See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> POST /images/load
|
||
|
||
Tarball in body
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="image-tarball-format">Image tarball format</h3>
|
||
|
||
<p>An image tarball contains one directory per image layer (named using its long ID),
|
||
each containing three files:</p>
|
||
|
||
<ol>
|
||
<li><code>VERSION</code>: currently <code>1.0</code> - the file format version</li>
|
||
<li><code>json</code>: detailed layer information, similar to <code>docker inspect layer_id</code></li>
|
||
<li><code>layer.tar</code>: A tarfile containing the filesystem changes in this layer</li>
|
||
</ol>
|
||
|
||
<p>The <code>layer.tar</code> file will contain <code>aufs</code> style <code>.wh..wh.aufs</code> files and directories
|
||
for storing attribute changes and deletions.</p>
|
||
|
||
<p>If the tarball defines a repository, there will also be a <code>repositories</code> file at
|
||
the root that contains a list of repository and tag names mapped to layer IDs.</p>
|
||
|
||
<pre><code>{&quot;hello-world&quot;:
|
||
{&quot;latest&quot;: &quot;565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1&quot;}
|
||
}
|
||
</code></pre>
|
||
|
||
<h3 id="exec-create">Exec Create</h3>
|
||
|
||
<p><code>POST /containers/(id)/exec</code></p>
|
||
|
||
<p>Sets up an exec instance in a running container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/exec HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;: &quot;f90e34656806&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to stdin of the exec command.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to stdout of the exec command.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to stderr of the exec command.</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY</li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
</ul>
|
||
|
||
<h3 id="exec-start">Exec Start</h3>
|
||
|
||
<p><code>POST /exec/(id)/start</code></p>
|
||
|
||
<p>Starts a previously set up exec instance <code>id</code>. If <code>detach</code> is true, this API
|
||
returns after starting the <code>exec</code> command. Otherwise, this API sets up an
|
||
interactive session with the <code>exec</code> command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /exec/e90e34656806/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Detach&quot;: false,
|
||
&quot;Tty&quot;: false,
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Detach</strong> - Detach from the exec command</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
|
||
<li><p><strong>404</strong> – no such exec instance</p>
|
||
|
||
<p><strong>Stream details</strong>:
|
||
Similar to the stream behavior of <code>POST /container/(id)/attach</code> API</p></li>
|
||
</ul>
|
||
|
||
<h3 id="exec-resize">Exec Resize</h3>
|
||
|
||
<p><code>POST /exec/(id)/resize</code></p>
|
||
|
||
<p>Resizes the tty session used by the exec command <code>id</code>.
|
||
This API is valid only if <code>tty</code> was specified as part of creating and starting the exec command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /exec/e90e34656806/resize HTTP/1.1
|
||
Content-Type: text/plain
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: text/plain
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>h</strong> – height of tty session</li>
|
||
<li><strong>w</strong> – width</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such exec instance</li>
|
||
</ul>
|
||
|
||
<h3 id="exec-inspect">Exec Inspect</h3>
|
||
|
||
<p><code>GET /exec/(id)/json</code></p>
|
||
|
||
<p>Return low-level information about the exec command <code>id</code>.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: plain/text
|
||
|
||
{
|
||
&quot;ID&quot; : &quot;11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39&quot;,
|
||
&quot;Running&quot; : false,
|
||
&quot;ExitCode&quot; : 2,
|
||
&quot;ProcessConfig&quot; : {
|
||
&quot;privileged&quot; : false,
|
||
&quot;user&quot; : &quot;&quot;,
|
||
&quot;tty&quot; : false,
|
||
&quot;entrypoint&quot; : &quot;sh&quot;,
|
||
&quot;arguments&quot; : [
|
||
&quot;-c&quot;,
|
||
&quot;exit 2&quot;
|
||
]
|
||
},
|
||
&quot;OpenStdin&quot; : false,
|
||
&quot;OpenStderr&quot; : false,
|
||
&quot;OpenStdout&quot; : false,
|
||
&quot;Container&quot; : {
|
||
&quot;State&quot; : {
|
||
&quot;Running&quot; : true,
|
||
&quot;Paused&quot; : false,
|
||
&quot;Restarting&quot; : false,
|
||
&quot;OOMKilled&quot; : false,
|
||
&quot;Pid&quot; : 3650,
|
||
&quot;ExitCode&quot; : 0,
|
||
&quot;Error&quot; : &quot;&quot;,
|
||
&quot;StartedAt&quot; : &quot;2014-11-17T22:26:03.717657531Z&quot;,
|
||
&quot;FinishedAt&quot; : &quot;0001-01-01T00:00:00Z&quot;
|
||
},
|
||
&quot;ID&quot; : &quot;8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c&quot;,
|
||
&quot;Created&quot; : &quot;2014-11-17T22:26:03.626304998Z&quot;,
|
||
&quot;Path&quot; : &quot;date&quot;,
|
||
&quot;Args&quot; : [],
|
||
&quot;Config&quot; : {
|
||
&quot;Hostname&quot; : &quot;8f177a186b97&quot;,
|
||
&quot;Domainname&quot; : &quot;&quot;,
|
||
&quot;User&quot; : &quot;&quot;,
|
||
&quot;Memory&quot; : 0,
|
||
&quot;MemorySwap&quot; : 0,
|
||
&quot;CpuShares&quot; : 0,
|
||
&quot;Cpuset&quot; : &quot;&quot;,
|
||
&quot;AttachStdin&quot; : false,
|
||
&quot;AttachStdout&quot; : false,
|
||
&quot;AttachStderr&quot; : false,
|
||
&quot;PortSpecs&quot; : null,
|
||
&quot;ExposedPorts&quot; : null,
|
||
&quot;Tty&quot; : false,
|
||
&quot;OpenStdin&quot; : false,
|
||
&quot;StdinOnce&quot; : false,
|
||
&quot;Env&quot; : [ &quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot; ],
|
||
&quot;Cmd&quot; : [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Image&quot; : &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot; : null,
|
||
&quot;WorkingDir&quot; : &quot;&quot;,
|
||
&quot;Entrypoint&quot; : null,
|
||
&quot;NetworkDisabled&quot; : false,
|
||
&quot;MacAddress&quot; : &quot;&quot;,
|
||
&quot;OnBuild&quot; : null,
|
||
&quot;SecurityOpt&quot; : null
|
||
},
|
||
&quot;Image&quot; : &quot;5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5&quot;,
|
||
&quot;NetworkSettings&quot; : {
|
||
&quot;IPAddress&quot; : &quot;172.17.0.2&quot;,
|
||
&quot;IPPrefixLen&quot; : 16,
|
||
&quot;MacAddress&quot; : &quot;02:42:ac:11:00:02&quot;,
|
||
&quot;Gateway&quot; : &quot;172.17.42.1&quot;,
|
||
&quot;Bridge&quot; : &quot;docker0&quot;,
|
||
&quot;PortMapping&quot; : null,
|
||
&quot;Ports&quot; : {}
|
||
},
|
||
&quot;ResolvConfPath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf&quot;,
|
||
&quot;HostnamePath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname&quot;,
|
||
&quot;HostsPath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts&quot;,
|
||
&quot;Name&quot; : &quot;/test&quot;,
|
||
&quot;Driver&quot; : &quot;aufs&quot;,
|
||
&quot;ExecDriver&quot; : &quot;native-0.2&quot;,
|
||
&quot;MountLabel&quot; : &quot;&quot;,
|
||
&quot;ProcessLabel&quot; : &quot;&quot;,
|
||
&quot;AppArmorProfile&quot; : &quot;&quot;,
|
||
&quot;RestartCount&quot; : 0,
|
||
&quot;Volumes&quot; : {},
|
||
&quot;VolumesRW&quot; : {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such exec instance</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h1 id="3-going-further">3. Going further</h1>
|
||
|
||
<h2 id="3-1-inside-docker-run">3.1 Inside <code>docker run</code></h2>
|
||
|
||
<p>As an example, the <code>docker run</code> command line makes the following API calls:</p>
|
||
|
||
<ul>
|
||
<li><p>Create the container</p></li>
|
||
|
||
<li><p>If the status code is 404, it means the image doesn&rsquo;t exist:</p>
|
||
|
||
<ul>
|
||
<li>Try to pull it</li>
|
||
<li>Then retry to create the container</li>
|
||
</ul></li>
|
||
|
||
<li><p>Start the container</p></li>
|
||
|
||
<li><p>If you are not in detached mode:</p></li>
|
||
|
||
<li><p>Attach to the container, using logs=1 (to have stdout and
|
||
stderr from the container&rsquo;s start) and stream=1</p></li>
|
||
|
||
<li><p>If in detached mode or only stdin is attached:</p></li>
|
||
|
||
<li><p>Display the container&rsquo;s id</p></li>
|
||
</ul>
|
||
|
||
<h2 id="3-2-hijacking">3.2 Hijacking</h2>
|
||
|
||
<p>In this version of the API, /attach, uses hijacking to transport stdin,
|
||
stdout and stderr on the same socket.</p>
|
||
|
||
<p>To hint potential proxies about connection hijacking, Docker client sends
|
||
connection upgrade headers similarly to websocket.</p>
|
||
|
||
<pre><code>Upgrade: tcp
|
||
Connection: Upgrade
|
||
</code></pre>
|
||
|
||
<p>When Docker daemon detects the <code>Upgrade</code> header, it will switch its status code
|
||
from <strong>200 OK</strong> to <strong>101 UPGRADED</strong> and resend the same headers.</p>
|
||
|
||
<p>This might change in the future.</p>
|
||
|
||
<h2 id="3-3-cors-requests">3.3 CORS Requests</h2>
|
||
|
||
<p>To set cross origin requests to the remote api, please add flag &ldquo;&ndash;api-enable-cors&rdquo;
|
||
when running docker in daemon mode.</p>
|
||
|
||
<pre><code>$ docker -d -H=&quot;192.168.1.9:2375&quot; --api-enable-cors
|
||
</code></pre>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Remote API v1.18</title>
|
||
<link>http://localhost/reference/api/docker_remote_api_v1.18/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/docker_remote_api_v1.18/</guid>
|
||
<description>
|
||
|
||
<h1 id="docker-remote-api-v1-18">Docker Remote API v1.18</h1>
|
||
|
||
<h2 id="1-brief-introduction">1. Brief introduction</h2>
|
||
|
||
<ul>
|
||
<li>The Remote API has replaced <code>rcli</code>.</li>
|
||
<li>The daemon listens on <code>unix:///var/run/docker.sock</code> but you can
|
||
<a href="http://localhost/articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket">Bind Docker to another host/port or a Unix socket</a>.</li>
|
||
<li>The API tends to be REST, but for some complex commands, like <code>attach</code>
|
||
or <code>pull</code>, the HTTP connection is hijacked to transport <code>STDOUT</code>,
|
||
<code>STDIN</code> and <code>STDERR</code>.</li>
|
||
</ul>
|
||
|
||
<h1 id="2-endpoints">2. Endpoints</h1>
|
||
|
||
<h2 id="2-1-containers">2.1 Containers</h2>
|
||
|
||
<h3 id="list-containers">List containers</h3>
|
||
|
||
<p><code>GET /containers/json</code></p>
|
||
|
||
<p>List containers</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/json?all=1&amp;before=8dfafdbc3a40&amp;size=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;8dfafdbc3a40&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 1&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [{&quot;PrivatePort&quot;: 2222, &quot;PublicPort&quot;: 3333, &quot;Type&quot;: &quot;tcp&quot;}],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;9cd87474be90&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 222222&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;3176a2479c92&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 3333333333333333&quot;,
|
||
&quot;Created&quot;: 1367854154,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;:[],
|
||
&quot;SizeRw&quot;:12288,
|
||
&quot;SizeRootFs&quot;:0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;4cb07b47f9fb&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 444444444444444444444444444444444&quot;,
|
||
&quot;Created&quot;: 1367854152,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, Show all containers.
|
||
Only running containers are shown by default (i.e., this defaults to false)</li>
|
||
<li><strong>limit</strong> – Show <code>limit</code> last created
|
||
containers, include non-running ones.</li>
|
||
<li><strong>since</strong> – Show only containers created since Id, include
|
||
non-running ones.</li>
|
||
<li><strong>before</strong> – Show only containers created before Id, include
|
||
non-running ones.</li>
|
||
<li><strong>size</strong> – 1/True/true or 0/False/false, Show the containers
|
||
sizes</li>
|
||
<li><strong>filters</strong> - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
|
||
|
||
<ul>
|
||
<li>exited=&lt;int&gt; &ndash; containers with exit code of &lt;int&gt;</li>
|
||
<li>status=(restarting|running|paused|exited)</li>
|
||
<li>label=<code>key</code> or <code>key=value</code> of a container label</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-container">Create a container</h3>
|
||
|
||
<p><code>POST /containers/create</code></p>
|
||
|
||
<p>Create a container</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/create HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Entrypoint&quot;: &quot;&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Labels&quot;: {
|
||
&quot;com.example.vendor&quot;: &quot;Acme&quot;,
|
||
&quot;com.example.license&quot;: &quot;GPL&quot;,
|
||
&quot;com.example.version&quot;: &quot;1.0&quot;
|
||
},
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;MacAddress&quot;: &quot;12:34:56:78:9a:bc&quot;,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
},
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;CpusetCpus&quot;: &quot;0,1&quot;,
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;ReadonlyRootfs&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: [],
|
||
&quot;Ulimits&quot;: [{}],
|
||
&quot;LogConfig&quot;: { &quot;Type&quot;: &quot;json-file&quot;, Config: {} },
|
||
&quot;SecurityOpt&quot;: [&quot;&quot;],
|
||
&quot;CgroupParent&quot;: &quot;&quot;
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;:&quot;e90e34656806&quot;
|
||
&quot;Warnings&quot;:[]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Hostname</strong> - A string value containing the desired hostname to use for the
|
||
container.</li>
|
||
<li><strong>Domainname</strong> - A string value containing the desired domain name to use
|
||
for the container.</li>
|
||
<li><strong>User</strong> - A string value containing the user to use inside the container.</li>
|
||
<li><strong>Memory</strong> - Memory limit in bytes.</li>
|
||
<li><strong>MemorySwap</strong>- Total memory limit (memory + swap); set <code>-1</code> to disable swap,
|
||
always use this with <code>memory</code>, and make the value larger than <code>memory</code>.</li>
|
||
<li><strong>CpuShares</strong> - An integer value containing the CPU Shares for container
|
||
(ie. the relative weight vs other containers).</li>
|
||
<li><strong>Cpuset</strong> - The same as CpusetCpus, but deprecated, please don&rsquo;t use.</li>
|
||
<li><strong>CpusetCpus</strong> - String value containing the cgroups CpusetCpus to use.</li>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to stdin.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to stdout.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to stderr.</li>
|
||
<li><strong>Tty</strong> - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.</li>
|
||
<li><strong>OpenStdin</strong> - Boolean value, opens stdin,</li>
|
||
<li><strong>StdinOnce</strong> - Boolean value, close stdin after the 1 attached client disconnects.</li>
|
||
<li><strong>Env</strong> - A list of environment variables in the form of <code>VAR=value</code></li>
|
||
<li><strong>Labels</strong> - Adds a map of labels that to a container. To specify a map: <code>{&quot;key&quot;:&quot;value&quot;[,&quot;key2&quot;:&quot;value2&quot;]}</code></li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
<li><strong>Entrypoint</strong> - Set the entrypoint for the container a a string or an array
|
||
of strings</li>
|
||
<li><strong>Image</strong> - String value containing the image name to use for the container</li>
|
||
<li><strong>Volumes</strong> – An object mapping mountpoint paths (strings) inside the
|
||
container to empty objects.</li>
|
||
<li><strong>WorkingDir</strong> - A string value containing the working dir for commands to
|
||
run in.</li>
|
||
<li><strong>NetworkDisabled</strong> - Boolean value, when true disables networking for the
|
||
container</li>
|
||
<li><strong>ExposedPorts</strong> - An object mapping ports to an empty object in the form of:
|
||
<code>&quot;ExposedPorts&quot;: { &quot;&lt;port&gt;/&lt;tcp|udp&gt;: {}&quot; }</code></li>
|
||
<li><strong>HostConfig</strong>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume
|
||
binding is a string of the form <code>container_path</code> (to create a new
|
||
volume for the container), <code>host_path:container_path</code> (to bind-mount
|
||
a host path into the container), or <code>host_path:container_path:ro</code>
|
||
(to make the bind-mount read-only inside the container).</li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be
|
||
in the form of <code>container_name:alias</code>.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations will only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. It should be specified in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>ReadonlyRootfs</strong> - Mount the container&rsquo;s root filesystem as read only.
|
||
Specified as a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of dns servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains</li>
|
||
<li><strong>ExtraHosts</strong> - A list of hostnames/IP mappings to be added to the
|
||
container&rsquo;s <code>/etc/hosts</code> file. Specified in the form <code>[&quot;hostname:IP&quot;]</code>.</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
<li><strong>Ulimits</strong> - A list of ulimits to be set in the container, specified as
|
||
<code>{ &quot;Name&quot;: &lt;name&gt;, &quot;Soft&quot;: &lt;soft limit&gt;, &quot;Hard&quot;: &lt;hard limit&gt; }</code>, for example:
|
||
<code>Ulimits: { &quot;Name&quot;: &quot;nofile&quot;, &quot;Soft&quot;: 1024, &quot;Hard&quot;, 2048 }}</code></li>
|
||
<li><strong>SecurityOpt</strong>: A list of string values to customize labels for MLS
|
||
systems, such as SELinux.</li>
|
||
<li><strong>LogConfig</strong> - Log configuration for the container, specified as
|
||
<code>{ &quot;Type&quot;: &quot;&lt;driver_name&gt;&quot;, &quot;Config&quot;: {&quot;key1&quot;: &quot;val1&quot;}}</code>.
|
||
Available types: <code>json-file</code>, <code>syslog</code>, <code>none</code>.
|
||
<code>json-file</code> logging driver.</li>
|
||
<li><strong>CgroupParent</strong> - Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>name</strong> – Assign the specified name to the container. Must
|
||
match <code>/?[a-zA-Z0-9_-]+</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>406</strong> – impossible to attach (container not running)</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-a-container">Inspect a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/json</code></p>
|
||
|
||
<p>Return low-level information on the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;AppArmorProfile&quot;: &quot;&quot;,
|
||
&quot;Args&quot;: [
|
||
&quot;-c&quot;,
|
||
&quot;exit 9&quot;
|
||
],
|
||
&quot;Config&quot;: {
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;Cmd&quot;: [
|
||
&quot;/bin/sh&quot;,
|
||
&quot;-c&quot;,
|
||
&quot;exit 9&quot;
|
||
],
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;Entrypoint&quot;: null,
|
||
&quot;Env&quot;: [
|
||
&quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;
|
||
],
|
||
&quot;ExposedPorts&quot;: null,
|
||
&quot;Hostname&quot;: &quot;ba033ac44011&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Labels&quot;: {
|
||
&quot;com.example.vendor&quot;: &quot;Acme&quot;,
|
||
&quot;com.example.license&quot;: &quot;GPL&quot;,
|
||
&quot;com.example.version&quot;: &quot;1.0&quot;
|
||
},
|
||
&quot;MacAddress&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;OnBuild&quot;: null,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Tty&quot;: false,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Volumes&quot;: null,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;Created&quot;: &quot;2015-01-06T15:47:31.485331387Z&quot;,
|
||
&quot;Driver&quot;: &quot;devicemapper&quot;,
|
||
&quot;ExecDriver&quot;: &quot;native-0.2&quot;,
|
||
&quot;ExecIDs&quot;: null,
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: null,
|
||
&quot;CapAdd&quot;: null,
|
||
&quot;CapDrop&quot;: null,
|
||
&quot;ContainerIDFile&quot;: &quot;&quot;,
|
||
&quot;CpusetCpus&quot;: &quot;&quot;,
|
||
&quot;CpuShares&quot;: 0,
|
||
&quot;Devices&quot;: [],
|
||
&quot;Dns&quot;: null,
|
||
&quot;DnsSearch&quot;: null,
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;IpcMode&quot;: &quot;&quot;,
|
||
&quot;Links&quot;: null,
|
||
&quot;LxcConf&quot;: [],
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;PortBindings&quot;: {},
|
||
&quot;Privileged&quot;: false,
|
||
&quot;ReadonlyRootfs&quot;: false,
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;RestartPolicy&quot;: {
|
||
&quot;MaximumRetryCount&quot;: 2,
|
||
&quot;Name&quot;: &quot;on-failure&quot;
|
||
},
|
||
&quot;LogConfig&quot;: {
|
||
&quot;Config&quot;: null,
|
||
&quot;Type&quot;: &quot;json-file&quot;
|
||
},
|
||
&quot;SecurityOpt&quot;: null,
|
||
&quot;VolumesFrom&quot;: null,
|
||
&quot;Ulimits&quot;: [{}]
|
||
},
|
||
&quot;HostnamePath&quot;: &quot;/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname&quot;,
|
||
&quot;HostsPath&quot;: &quot;/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts&quot;,
|
||
&quot;LogPath&quot;: &quot;/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log&quot;,
|
||
&quot;Id&quot;: &quot;ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39&quot;,
|
||
&quot;Image&quot;: &quot;04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2&quot;,
|
||
&quot;MountLabel&quot;: &quot;&quot;,
|
||
&quot;Name&quot;: &quot;/boring_euclid&quot;,
|
||
&quot;NetworkSettings&quot;: {
|
||
&quot;Bridge&quot;: &quot;&quot;,
|
||
&quot;Gateway&quot;: &quot;&quot;,
|
||
&quot;IPAddress&quot;: &quot;&quot;,
|
||
&quot;IPPrefixLen&quot;: 0,
|
||
&quot;MacAddress&quot;: &quot;&quot;,
|
||
&quot;PortMapping&quot;: null,
|
||
&quot;Ports&quot;: null
|
||
},
|
||
&quot;Path&quot;: &quot;/bin/sh&quot;,
|
||
&quot;ProcessLabel&quot;: &quot;&quot;,
|
||
&quot;ResolvConfPath&quot;: &quot;/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf&quot;,
|
||
&quot;RestartCount&quot;: 1,
|
||
&quot;State&quot;: {
|
||
&quot;Error&quot;: &quot;&quot;,
|
||
&quot;ExitCode&quot;: 9,
|
||
&quot;FinishedAt&quot;: &quot;2015-01-06T15:47:32.080254511Z&quot;,
|
||
&quot;OOMKilled&quot;: false,
|
||
&quot;Paused&quot;: false,
|
||
&quot;Pid&quot;: 0,
|
||
&quot;Restarting&quot;: false,
|
||
&quot;Running&quot;: false,
|
||
&quot;StartedAt&quot;: &quot;2015-01-06T15:47:32.072697474Z&quot;
|
||
},
|
||
&quot;Volumes&quot;: {},
|
||
&quot;VolumesRW&quot;: {}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="list-processes-running-inside-a-container">List processes running inside a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/top</code></p>
|
||
|
||
<p>List processes running inside the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/top HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Titles&quot;: [
|
||
&quot;USER&quot;,
|
||
&quot;PID&quot;,
|
||
&quot;%CPU&quot;,
|
||
&quot;%MEM&quot;,
|
||
&quot;VSZ&quot;,
|
||
&quot;RSS&quot;,
|
||
&quot;TTY&quot;,
|
||
&quot;STAT&quot;,
|
||
&quot;START&quot;,
|
||
&quot;TIME&quot;,
|
||
&quot;COMMAND&quot;
|
||
],
|
||
&quot;Processes&quot;: [
|
||
[&quot;root&quot;,&quot;20147&quot;,&quot;0.0&quot;,&quot;0.1&quot;,&quot;18060&quot;,&quot;1864&quot;,&quot;pts/4&quot;,&quot;S&quot;,&quot;10:06&quot;,&quot;0:00&quot;,&quot;bash&quot;],
|
||
[&quot;root&quot;,&quot;20271&quot;,&quot;0.0&quot;,&quot;0.0&quot;,&quot;4312&quot;,&quot;352&quot;,&quot;pts/4&quot;,&quot;S+&quot;,&quot;10:07&quot;,&quot;0:00&quot;,&quot;sleep&quot;,&quot;10&quot;]
|
||
]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>ps_args</strong> – ps arguments to use (e.g., aux)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-container-logs">Get container logs</h3>
|
||
|
||
<p><code>GET /containers/(id)/logs</code></p>
|
||
|
||
<p>Get stdout and stderr logs from the container <code>id</code></p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
This endpoint works only for containers with <code>json-file</code> logging driver.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/logs?stderr=1&amp;stdout=1&amp;timestamps=1&amp;follow=1&amp;tail=10 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 101 UPGRADED
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
Connection: Upgrade
|
||
Upgrade: tcp
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>follow</strong> – 1/True/true or 0/False/false, return stream. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, show stdout log. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, show stderr log. Default false</li>
|
||
<li><strong>timestamps</strong> – 1/True/true or 0/False/false, print timestamps for
|
||
every log line. Default false</li>
|
||
<li><strong>tail</strong> – Output specified number of lines at the end of logs: <code>all</code> or <code>&lt;number&gt;</code>. Default all</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>101</strong> – no error, hints proxy about hijacking</li>
|
||
<li><strong>200</strong> – no error, no upgrade header found</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-changes-on-a-container-s-filesystem">Inspect changes on a container&rsquo;s filesystem</h3>
|
||
|
||
<p><code>GET /containers/(id)/changes</code></p>
|
||
|
||
<p>Inspect changes on container <code>id</code>&rsquo;s filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/changes HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Path&quot;: &quot;/dev&quot;,
|
||
&quot;Kind&quot;: 0
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/dev/kmsg&quot;,
|
||
&quot;Kind&quot;: 1
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/test&quot;,
|
||
&quot;Kind&quot;: 1
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Values for <code>Kind</code>:</p>
|
||
|
||
<ul>
|
||
<li><code>0</code>: Modify</li>
|
||
<li><code>1</code>: Add</li>
|
||
<li><code>2</code>: Delete</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="export-a-container">Export a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/export</code></p>
|
||
|
||
<p>Export the contents of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/export HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/octet-stream
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-container-stats-based-on-resource-usage">Get container stats based on resource usage</h3>
|
||
|
||
<p><code>GET /containers/(id)/stats</code></p>
|
||
|
||
<p>This endpoint returns a live stream of a container&rsquo;s resource usage statistics.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: this functionality currently only works when using the <em>libcontainer</em> exec-driver.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/redis1/stats HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;read&quot; : &quot;2015-01-08T22:57:31.547920715Z&quot;,
|
||
&quot;network&quot; : {
|
||
&quot;rx_dropped&quot; : 0,
|
||
&quot;rx_bytes&quot; : 648,
|
||
&quot;rx_errors&quot; : 0,
|
||
&quot;tx_packets&quot; : 8,
|
||
&quot;tx_dropped&quot; : 0,
|
||
&quot;rx_packets&quot; : 8,
|
||
&quot;tx_errors&quot; : 0,
|
||
&quot;tx_bytes&quot; : 648
|
||
},
|
||
&quot;memory_stats&quot; : {
|
||
&quot;stats&quot; : {
|
||
&quot;total_pgmajfault&quot; : 0,
|
||
&quot;cache&quot; : 0,
|
||
&quot;mapped_file&quot; : 0,
|
||
&quot;total_inactive_file&quot; : 0,
|
||
&quot;pgpgout&quot; : 414,
|
||
&quot;rss&quot; : 6537216,
|
||
&quot;total_mapped_file&quot; : 0,
|
||
&quot;writeback&quot; : 0,
|
||
&quot;unevictable&quot; : 0,
|
||
&quot;pgpgin&quot; : 477,
|
||
&quot;total_unevictable&quot; : 0,
|
||
&quot;pgmajfault&quot; : 0,
|
||
&quot;total_rss&quot; : 6537216,
|
||
&quot;total_rss_huge&quot; : 6291456,
|
||
&quot;total_writeback&quot; : 0,
|
||
&quot;total_inactive_anon&quot; : 0,
|
||
&quot;rss_huge&quot; : 6291456,
|
||
&quot;hierarchical_memory_limit&quot; : 67108864,
|
||
&quot;total_pgfault&quot; : 964,
|
||
&quot;total_active_file&quot; : 0,
|
||
&quot;active_anon&quot; : 6537216,
|
||
&quot;total_active_anon&quot; : 6537216,
|
||
&quot;total_pgpgout&quot; : 414,
|
||
&quot;total_cache&quot; : 0,
|
||
&quot;inactive_anon&quot; : 0,
|
||
&quot;active_file&quot; : 0,
|
||
&quot;pgfault&quot; : 964,
|
||
&quot;inactive_file&quot; : 0,
|
||
&quot;total_pgpgin&quot; : 477
|
||
},
|
||
&quot;max_usage&quot; : 6651904,
|
||
&quot;usage&quot; : 6537216,
|
||
&quot;failcnt&quot; : 0,
|
||
&quot;limit&quot; : 67108864
|
||
},
|
||
&quot;blkio_stats&quot; : {},
|
||
&quot;cpu_stats&quot; : {
|
||
&quot;cpu_usage&quot; : {
|
||
&quot;percpu_usage&quot; : [
|
||
16970827,
|
||
1839451,
|
||
7107380,
|
||
10571290
|
||
],
|
||
&quot;usage_in_usermode&quot; : 10000000,
|
||
&quot;total_usage&quot; : 36488948,
|
||
&quot;usage_in_kernelmode&quot; : 20000000
|
||
},
|
||
&quot;system_cpu_usage&quot; : 20091722000000000,
|
||
&quot;throttling_data&quot; : {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="resize-a-container-tty">Resize a container TTY</h3>
|
||
|
||
<p><code>POST /containers/(id)/resize?h=&lt;height&gt;&amp;w=&lt;width&gt;</code></p>
|
||
|
||
<p>Resize the TTY for container with <code>id</code>. The container must be restarted for the resize to take effect.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/4fa6e0f0c678/resize?h=40&amp;w=80 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Length: 0
|
||
Content-Type: text/plain; charset=utf-8
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – No such container</li>
|
||
<li><strong>500</strong> – Cannot resize container</li>
|
||
</ul>
|
||
|
||
<h3 id="start-a-container">Start a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/start</code></p>
|
||
|
||
<p>Start the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/(id)/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;CpusetCpus&quot;: &quot;0,1&quot;,
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;ReadonlyRootfs&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: [],
|
||
&quot;Ulimits&quot;: [{}],
|
||
&quot;LogConfig&quot;: { &quot;Type&quot;: &quot;json-file&quot;, Config: {} },
|
||
&quot;SecurityOpt&quot;: [&quot;&quot;],
|
||
&quot;CgroupParent&quot;: &quot;&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume
|
||
binding is a string of the form <code>container_path</code> (to create a new
|
||
volume for the container), <code>host_path:container_path</code> (to bind-mount
|
||
a host path into the container), or <code>host_path:container_path:ro</code>
|
||
(to make the bind-mount read-only inside the container).</li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be of
|
||
of the form <code>container_name:alias</code>.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations will only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. It should be specified in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>ReadonlyRootfs</strong> - Mount the container&rsquo;s root filesystem as read only.
|
||
Specified as a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of dns servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains</li>
|
||
<li><strong>ExtraHosts</strong> - A list of hostnames/IP mappings to be added to the
|
||
container&rsquo;s <code>/etc/hosts</code> file. Specified in the form <code>[&quot;hostname:IP&quot;]</code>.</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
<li><strong>Ulimits</strong> - A list of ulimits to be set in the container, specified as
|
||
<code>{ &quot;Name&quot;: &lt;name&gt;, &quot;Soft&quot;: &lt;soft limit&gt;, &quot;Hard&quot;: &lt;hard limit&gt; }</code>, for example:
|
||
<code>Ulimits: { &quot;Name&quot;: &quot;nofile&quot;, &quot;Soft&quot;: 1024, &quot;Hard&quot;, 2048 }}</code></li>
|
||
<li><strong>SecurityOpt</strong>: A list of string values to customize labels for MLS
|
||
systems, such as SELinux.</li>
|
||
<li><strong>LogConfig</strong> - Log configuration for the container, specified as
|
||
<code>{ &quot;Type&quot;: &quot;&lt;driver_name&gt;&quot;, &quot;Config&quot;: {&quot;key1&quot;: &quot;val1&quot;}}</code>.
|
||
Available types: <code>json-file</code>, <code>syslog</code>, <code>none</code>.
|
||
<code>json-file</code> logging driver.</li>
|
||
<li><strong>CgroupParent</strong> - Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already started</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="stop-a-container">Stop a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/stop</code></p>
|
||
|
||
<p>Stop the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/stop?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already stopped</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="restart-a-container">Restart a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/restart</code></p>
|
||
|
||
<p>Restart the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/restart?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="kill-a-container">Kill a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/kill</code></p>
|
||
|
||
<p>Kill the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/kill HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters</p>
|
||
|
||
<ul>
|
||
<li><strong>signal</strong> - Signal to send to the container: integer or string like &ldquo;SIGINT&rdquo;.
|
||
When not set, SIGKILL is assumed and the call will waits for the container to exit.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="rename-a-container">Rename a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/rename</code></p>
|
||
|
||
<p>Rename the container <code>id</code> to a <code>new_name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>name</strong> – new name for the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>409</strong> - conflict name already assigned</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="pause-a-container">Pause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/pause</code></p>
|
||
|
||
<p>Pause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/pause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="unpause-a-container">Unpause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/unpause</code></p>
|
||
|
||
<p>Unpause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/unpause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container">Attach to a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/attach</code></p>
|
||
|
||
<p>Attach to the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/attach?logs=1&amp;stream=0&amp;stdout=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 101 UPGRADED
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
Connection: Upgrade
|
||
Upgrade: tcp
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach
|
||
to stdin. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>101</strong> – no error, hints proxy about hijacking</li>
|
||
<li><strong>200</strong> – no error, no upgrade header found</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
|
||
<li><p><strong>500</strong> – server error</p>
|
||
|
||
<p><strong>Stream details</strong>:</p>
|
||
|
||
<p>When using the TTY setting is enabled in
|
||
<a href="http://localhost/docker/reference/api/docker_remote_api_v1.9/#create-a-container" title="POST /containers/create"><code>POST /containers/create</code>
|
||
</a>,
|
||
the stream is the raw data from the process PTY and client&rsquo;s stdin.
|
||
When the TTY is disabled, then the stream is multiplexed to separate
|
||
stdout and stderr.</p>
|
||
|
||
<p>The format is a <strong>Header</strong> and a <strong>Payload</strong> (frame).</p>
|
||
|
||
<p><strong>HEADER</strong></p>
|
||
|
||
<p>The header will contain the information on which stream write the
|
||
stream (stdout or stderr). It also contain the size of the
|
||
associated frame encoded on the last 4 bytes (uint32).</p>
|
||
|
||
<p>It is encoded on the first 8 bytes like this:</p>
|
||
|
||
<pre><code>header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
|
||
</code></pre>
|
||
|
||
<p><code>STREAM_TYPE</code> can be:</p></li>
|
||
|
||
<li><p>0: stdin (will be written on stdout)</p></li>
|
||
|
||
<li><p>1: stdout</p></li>
|
||
|
||
<li><p>2: stderr</p>
|
||
|
||
<p><code>SIZE1, SIZE2, SIZE3, SIZE4</code> are the 4 bytes of
|
||
the uint32 size encoded as big endian.</p>
|
||
|
||
<p><strong>PAYLOAD</strong></p>
|
||
|
||
<p>The payload is the raw stream.</p>
|
||
|
||
<p><strong>IMPLEMENTATION</strong></p>
|
||
|
||
<p>The simplest way to implement the Attach protocol is the following:</p>
|
||
|
||
<ol>
|
||
<li>Read 8 bytes</li>
|
||
<li>chose stdout or stderr depending on the first byte</li>
|
||
<li>Extract the frame size from the last 4 bytes</li>
|
||
<li>Read the extracted size and output it on the correct output</li>
|
||
<li>Goto 1</li>
|
||
</ol></li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container-websocket">Attach to a container (websocket)</h3>
|
||
|
||
<p><code>GET /containers/(id)/attach/ws</code></p>
|
||
|
||
<p>Attach to the container <code>id</code> via websocket</p>
|
||
|
||
<p>Implements websocket protocol handshake according to <a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a></p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /containers/e90e34656806/attach/ws?logs=0&amp;stream=1&amp;stdin=1&amp;stdout=1&amp;stderr=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong></p>
|
||
|
||
<pre><code> {{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default false</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default false</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if stream=true, attach
|
||
to stdin. Default false</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stdout log, if stream=true, attach to stdout. Default false</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if logs=true, return
|
||
stderr log, if stream=true, attach to stderr. Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="wait-a-container">Wait a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/wait</code></p>
|
||
|
||
<p>Block until container <code>id</code> stops, then returns the exit code</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/16253994b7c4/wait HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;StatusCode&quot;: 0}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-a-container">Remove a container</h3>
|
||
|
||
<p><code>DELETE /containers/(id)</code></p>
|
||
|
||
<p>Remove the container <code>id</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /containers/16253994b7c4?v=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>v</strong> – 1/True/true or 0/False/false, Remove the volumes
|
||
associated to the container. Default false</li>
|
||
<li><strong>force</strong> - 1/True/true or 0/False/false, Kill then remove the container.
|
||
Default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="copy-files-or-folders-from-a-container">Copy files or folders from a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/copy</code></p>
|
||
|
||
<p>Copy files or folders of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/4fa6e0f0c678/copy HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Resource&quot;: &quot;test.txt&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-2-images">2.2 Images</h2>
|
||
|
||
<h3 id="list-images">List Images</h3>
|
||
|
||
<p><code>GET /images/json</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/json?all=0 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.04&quot;,
|
||
&quot;ubuntu:precise&quot;,
|
||
&quot;ubuntu:latest&quot;
|
||
],
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;VirtualSize&quot;: 131506275
|
||
},
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.10&quot;,
|
||
&quot;ubuntu:quantal&quot;
|
||
],
|
||
&quot;ParentId&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;Size&quot;: 24653,
|
||
&quot;VirtualSize&quot;: 180116135
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p><strong>Example request, with digest information</strong>:</p>
|
||
|
||
<pre><code> GET /images/json?digests=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response, with digest information</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Created&quot;: 1420064636,
|
||
&quot;Id&quot;: &quot;4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125&quot;,
|
||
&quot;ParentId&quot;: &quot;ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2&quot;,
|
||
&quot;RepoDigests&quot;: [
|
||
&quot;localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf&quot;
|
||
],
|
||
&quot;RepoTags&quot;: [
|
||
&quot;localhost:5000/test/busybox:latest&quot;,
|
||
&quot;playdate:latest&quot;
|
||
],
|
||
&quot;Size&quot;: 0,
|
||
&quot;VirtualSize&quot;: 2429728
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>The response shows a single image <code>Id</code> associated with two repositories
|
||
(<code>RepoTags</code>): <code>localhost:5000/test/busybox</code>: and <code>playdate</code>. A caller can use
|
||
either of the <code>RepoTags</code> values <code>localhost:5000/test/busybox:latest</code> or
|
||
<code>playdate:latest</code> to reference the image.</p>
|
||
|
||
<p>You can also use <code>RepoDigests</code> values to reference an image. In this response,
|
||
the array has only one reference and that is to the
|
||
<code>localhost:5000/test/busybox</code> repository; the <code>playdate</code> repository has no
|
||
digest. You can reference this digest using the value:
|
||
<code>localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...</code></p>
|
||
|
||
<p>See the <code>docker run</code> and <code>docker build</code> commands for examples of digest and tag
|
||
references on the command line.</p>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>filters</strong> – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
|
||
|
||
<ul>
|
||
<li>dangling=true</li>
|
||
<li>label=<code>key</code> or <code>key=value</code> of an image label</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<h3 id="build-image-from-a-dockerfile">Build image from a Dockerfile</h3>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p>Build an image from a Dockerfile</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /build HTTP/1.1
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;stream&quot;: &quot;Step 1...&quot;}
|
||
{&quot;stream&quot;: &quot;...&quot;}
|
||
{&quot;error&quot;: &quot;Error...&quot;, &quot;errorDetail&quot;: {&quot;code&quot;: 123, &quot;message&quot;: &quot;Error...&quot;}}
|
||
</code></pre>
|
||
|
||
<p>The input stream must be a tar archive compressed with one of the
|
||
following algorithms: identity (no compression), gzip, bzip2, xz.</p>
|
||
|
||
<p>The archive must include a build instructions file, typically called
|
||
<code>Dockerfile</code> at the root of the archive. The <code>dockerfile</code> parameter may be
|
||
used to specify a different build instructions file by having its value be
|
||
the path to the alternate build instructions file to use.</p>
|
||
|
||
<p>The archive may include any number of other files,
|
||
which will be accessible in the build context (See the <a href="http://localhost/docker/reference/builder/#dockerbuilder"><em>ADD build
|
||
command</em></a>).</p>
|
||
|
||
<p>The build will also be canceled if the client drops the connection by quitting
|
||
or being killed.</p>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>dockerfile</strong> - path within the build context to the Dockerfile. This is
|
||
ignored if <code>remote</code> is specified and points to an individual filename.</li>
|
||
<li><strong>t</strong> – repository name (and optionally a tag) to be applied to
|
||
the resulting image in case of success</li>
|
||
<li><strong>remote</strong> – A Git repository URI or HTTP/HTTPS URI build source. If the
|
||
URI specifies a filename, the file&rsquo;s contents are placed into a file
|
||
called <code>Dockerfile</code>.</li>
|
||
<li><strong>q</strong> – suppress verbose build output</li>
|
||
<li><strong>nocache</strong> – do not use the cache when building the image</li>
|
||
<li><strong>pull</strong> - attempt to pull the image even if an older image exists locally</li>
|
||
<li><strong>rm</strong> - remove intermediate containers after a successful build (default behavior)</li>
|
||
<li><strong>forcerm</strong> - always remove intermediate containers (includes rm)</li>
|
||
<li><strong>memory</strong> - set memory limit for build</li>
|
||
<li><strong>memswap</strong> - Total memory (memory + swap), <code>-1</code> to disable swap</li>
|
||
<li><strong>cpushares</strong> - CPU shares (relative weight)</li>
|
||
|
||
<li><p><strong>cpusetcpus</strong> - CPUs in which to allow execution, e.g., <code>0-3</code>, <code>0,1</code></p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>Content-type</strong> – should be set to <code>&quot;application/tar&quot;</code>.</p></li>
|
||
|
||
<li><p><strong>X-Registry-Config</strong> – base64-encoded ConfigFile object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-an-image">Create an image</h3>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p>Create an image, either by pulling it from the registry or by importing it</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/create?fromImage=ubuntu HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pulling...&quot;}
|
||
{&quot;status&quot;: &quot;Pulling&quot;, &quot;progress&quot;: &quot;1 B/ 100 B&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1, &quot;total&quot;: 100}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
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.
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>fromImage</strong> – name of the image to pull</li>
|
||
<li><strong>fromSrc</strong> – source to import. The value may be a URL from which the image
|
||
can be retrieved or <code>-</code> to read the image from the request body.</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
|
||
<li><p><strong>registry</strong> – the registry to pull from</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>X-Registry-Auth</strong> – base64-encoded AuthConfig object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-an-image">Inspect an image</h3>
|
||
|
||
<p><code>GET /images/(name)/json</code></p>
|
||
|
||
<p>Return low-level information on the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Created&quot;: &quot;2013-03-23T22:24:18.818426-07:00&quot;,
|
||
&quot;Container&quot;: &quot;3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0&quot;,
|
||
&quot;ContainerConfig&quot;:
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: false,
|
||
&quot;AttachStderr&quot;: false,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: true,
|
||
&quot;OpenStdin&quot;: true,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [&quot;/bin/bash&quot;],
|
||
&quot;Dns&quot;: null,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Labels&quot;: {
|
||
&quot;com.example.vendor&quot;: &quot;Acme&quot;,
|
||
&quot;com.example.license&quot;: &quot;GPL&quot;,
|
||
&quot;com.example.version&quot;: &quot;1.0&quot;
|
||
},
|
||
&quot;Volumes&quot;: null,
|
||
&quot;VolumesFrom&quot;: &quot;&quot;,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Parent&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Size&quot;: 6824592
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-the-history-of-an-image">Get the history of an image</h3>
|
||
|
||
<p><code>GET /images/(name)/history</code></p>
|
||
|
||
<p>Return the history of the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/ubuntu/history HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;b750fe79269d&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;CreatedBy&quot;: &quot;/bin/bash&quot;
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;27cf78414709&quot;,
|
||
&quot;Created&quot;: 1364068391,
|
||
&quot;CreatedBy&quot;: &quot;&quot;
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="push-an-image-on-the-registry">Push an image on the registry</h3>
|
||
|
||
<p><code>POST /images/(name)/push</code></p>
|
||
|
||
<p>Push the image <code>name</code> on the registry</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pushing...&quot;}
|
||
{&quot;status&quot;: &quot;Pushing&quot;, &quot;progress&quot;: &quot;1/? (n/a)&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1}}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
|
||
If you wish to push an image on to a private registry, that image must already have been tagged
|
||
into a repository which references that registry host name and port. This repository name should
|
||
then be used in the URL. This mirrors the flow of the CLI.
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/registry.acme.com:5000/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>tag</strong> – the tag to associate with the image on the registry, optional</li>
|
||
</ul>
|
||
|
||
<p>Request Headers:</p>
|
||
|
||
<ul>
|
||
<li><strong>X-Registry-Auth</strong> – include a base64-encoded AuthConfig
|
||
object.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="tag-an-image-into-a-repository">Tag an image into a repository</h3>
|
||
|
||
<p><code>POST /images/(name)/tag</code></p>
|
||
|
||
<p>Tag the image <code>name</code> into a repository</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /images/test/tag?repo=myrepo&amp;force=0&amp;tag=v42 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo</strong> – The repository to tag in</li>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>tag</strong> - The new tag name</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-an-image">Remove an image</h3>
|
||
|
||
<p><code>DELETE /images/(name)</code></p>
|
||
|
||
<p>Remove the image <code>name</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> DELETE /images/test HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-type: application/json
|
||
|
||
[
|
||
{&quot;Untagged&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;53b4f83ac9&quot;}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>noprune</strong> – 1/True/true or 0/False/false, default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="search-images">Search images</h3>
|
||
|
||
<p><code>GET /images/search</code></p>
|
||
|
||
<p>Search for an image on <a href="https://hub.docker.com">Docker Hub</a>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
The response keys have changed from API v1.6 to reflect the JSON
|
||
sent by the registry server to the docker daemon&rsquo;s request.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /images/search?term=sshd HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;wma55/u1210sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;jdswinbank/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;vgauthier/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
}
|
||
...
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>term</strong> – term to search</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-3-misc">2.3 Misc</h2>
|
||
|
||
<h3 id="check-auth-configuration">Check auth configuration</h3>
|
||
|
||
<p><code>POST /auth</code></p>
|
||
|
||
<p>Get the default username and email</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /auth HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;username&quot;:&quot; hannibal&quot;,
|
||
&quot;password: &quot;xxxx&quot;,
|
||
&quot;email&quot;: &quot;hannibal@a-team.com&quot;,
|
||
&quot;serveraddress&quot;: &quot;https://index.docker.io/v1/&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="display-system-wide-information">Display system-wide information</h3>
|
||
|
||
<p><code>GET /info</code></p>
|
||
|
||
<p>Display system-wide information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /info HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Containers&quot;: 11,
|
||
&quot;Debug&quot;: 0,
|
||
&quot;DockerRootDir&quot;: &quot;/var/lib/docker&quot;,
|
||
&quot;Driver&quot;: &quot;btrfs&quot;,
|
||
&quot;DriverStatus&quot;: [[&quot;&quot;]],
|
||
&quot;ExecutionDriver&quot;: &quot;native-0.1&quot;,
|
||
&quot;HttpProxy&quot;: &quot;http://test:test@localhost:8080&quot;,
|
||
&quot;HttpsProxy&quot;: &quot;https://test:test@localhost:8080&quot;,
|
||
&quot;ID&quot;: &quot;7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS&quot;,
|
||
&quot;IPv4Forwarding&quot;: 1,
|
||
&quot;Images&quot;: 16,
|
||
&quot;IndexServerAddress&quot;: &quot;https://index.docker.io/v1/&quot;,
|
||
&quot;InitPath&quot;: &quot;/usr/bin/docker&quot;,
|
||
&quot;InitSha1&quot;: &quot;&quot;,
|
||
&quot;KernelVersion&quot;: &quot;3.12.0-1-amd64&quot;,
|
||
&quot;Labels&quot;: [
|
||
&quot;storage=ssd&quot;
|
||
],
|
||
&quot;MemTotal&quot;: 2099236864,
|
||
&quot;MemoryLimit&quot;: 1,
|
||
&quot;NCPU&quot;: 1,
|
||
&quot;NEventsListener&quot;: 0,
|
||
&quot;NFd&quot;: 11,
|
||
&quot;NGoroutines&quot;: 21,
|
||
&quot;Name&quot;: &quot;prod-server-42&quot;,
|
||
&quot;NoProxy&quot;: &quot;9.81.1.160&quot;,
|
||
&quot;OperatingSystem&quot;: &quot;Boot2Docker&quot;,
|
||
&quot;RegistryConfig&quot;: {
|
||
&quot;IndexConfigs&quot;: {
|
||
&quot;docker.io&quot;: {
|
||
&quot;Mirrors&quot;: null,
|
||
&quot;Name&quot;: &quot;docker.io&quot;,
|
||
&quot;Official&quot;: true,
|
||
&quot;Secure&quot;: true
|
||
}
|
||
},
|
||
&quot;InsecureRegistryCIDRs&quot;: [
|
||
&quot;127.0.0.0/8&quot;
|
||
]
|
||
},
|
||
&quot;SwapLimit&quot;: 0,
|
||
&quot;SystemTime&quot;: &quot;2015-03-10T11:11:23.730591467-07:00&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="show-the-docker-version-information">Show the docker version information</h3>
|
||
|
||
<p><code>GET /version</code></p>
|
||
|
||
<p>Show the docker version information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /version HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Version&quot;: &quot;1.5.0&quot;,
|
||
&quot;Os&quot;: &quot;linux&quot;,
|
||
&quot;KernelVersion&quot;: &quot;3.18.5-tinycore64&quot;,
|
||
&quot;GoVersion&quot;: &quot;go1.4.1&quot;,
|
||
&quot;GitCommit&quot;: &quot;a8a31ef&quot;,
|
||
&quot;Arch&quot;: &quot;amd64&quot;,
|
||
&quot;ApiVersion&quot;: &quot;1.18&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="ping-the-docker-server">Ping the docker server</h3>
|
||
|
||
<p><code>GET /_ping</code></p>
|
||
|
||
<p>Ping the docker server</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /_ping HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: text/plain
|
||
|
||
OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> - no error</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-new-image-from-a-container-s-changes">Create a new image from a container&rsquo;s changes</h3>
|
||
|
||
<p><code>POST /commit</code></p>
|
||
|
||
<p>Create a new image from a container&rsquo;s changes</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /commit?container=44c004db4b17&amp;comment=message&amp;repo=myrepo HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{&quot;Id&quot;: &quot;596069db4bf5&quot;}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>config</strong> - the container&rsquo;s configuration</li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>container</strong> – source container</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
<li><strong>comment</strong> – commit message</li>
|
||
<li><strong>author</strong> – author (e.g., &ldquo;John Hannibal Smith
|
||
&lt;<a href="mailto:hannibal%40a-team.com">hannibal@a-team.com</a>&gt;&ldquo;)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="monitor-docker-s-events">Monitor Docker&rsquo;s events</h3>
|
||
|
||
<p><code>GET /events</code></p>
|
||
|
||
<p>Get container events from docker, either in real time via streaming, or via
|
||
polling (using since).</p>
|
||
|
||
<p>Docker containers will report the following events:</p>
|
||
|
||
<pre><code>create, destroy, die, exec_create, exec_start, export, kill, oom, pause, restart, start, stop, unpause
|
||
</code></pre>
|
||
|
||
<p>and Docker images will report:</p>
|
||
|
||
<pre><code>untag, delete
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /events?since=1374067924
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;create&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;start&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;stop&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067966}
|
||
{&quot;status&quot;: &quot;destroy&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067970}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>since</strong> – timestamp used for polling</li>
|
||
<li><strong>until</strong> – timestamp used for polling</li>
|
||
<li><strong>filters</strong> – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
|
||
|
||
<ul>
|
||
<li>event=&lt;string&gt; &ndash; event to filter</li>
|
||
<li>image=&lt;string&gt; &ndash; image to filter</li>
|
||
<li>container=&lt;string&gt; &ndash; container to filter</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images-in-a-repository">Get a tarball containing all images in a repository</h3>
|
||
|
||
<p><code>GET /images/(name)/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for the repository specified
|
||
by <code>name</code>.</p>
|
||
|
||
<p>If <code>name</code> is a specific name and tag (e.g. ubuntu:latest), then only that image
|
||
(and its parents) are returned. If <code>name</code> is an image ID, similarly only that
|
||
image (and its parents) are returned, but with the exclusion of the
|
||
&lsquo;repositories&rsquo; file in the tarball, as there were no image names referenced.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /images/ubuntu/get
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images">Get a tarball containing all images.</h3>
|
||
|
||
<p><code>GET /images/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for one or more repositories.</p>
|
||
|
||
<p>For each value of the <code>names</code> 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 &lsquo;repositories&rsquo; file for this image ID.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> GET /images/get?names=myname%2Fmyapp%3Alatest&amp;names=busybox
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="load-a-tarball-with-a-set-of-images-and-tags-into-docker">Load a tarball with a set of images and tags into docker</h3>
|
||
|
||
<p><code>POST /images/load</code></p>
|
||
|
||
<p>Load a set of images and tags into the docker repository.
|
||
See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code> POST /images/load
|
||
|
||
Tarball in body
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="image-tarball-format">Image tarball format</h3>
|
||
|
||
<p>An image tarball contains one directory per image layer (named using its long ID),
|
||
each containing three files:</p>
|
||
|
||
<ol>
|
||
<li><code>VERSION</code>: currently <code>1.0</code> - the file format version</li>
|
||
<li><code>json</code>: detailed layer information, similar to <code>docker inspect layer_id</code></li>
|
||
<li><code>layer.tar</code>: A tarfile containing the filesystem changes in this layer</li>
|
||
</ol>
|
||
|
||
<p>The <code>layer.tar</code> file will contain <code>aufs</code> style <code>.wh..wh.aufs</code> files and directories
|
||
for storing attribute changes and deletions.</p>
|
||
|
||
<p>If the tarball defines a repository, there will also be a <code>repositories</code> file at
|
||
the root that contains a list of repository and tag names mapped to layer IDs.</p>
|
||
|
||
<pre><code>{&quot;hello-world&quot;:
|
||
{&quot;latest&quot;: &quot;565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1&quot;}
|
||
}
|
||
</code></pre>
|
||
|
||
<h3 id="exec-create">Exec Create</h3>
|
||
|
||
<p><code>POST /containers/(id)/exec</code></p>
|
||
|
||
<p>Sets up an exec instance in a running container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/e90e34656806/exec HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;: &quot;f90e34656806&quot;
|
||
&quot;Warnings&quot;:[]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to stdin of the exec command.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to stdout of the exec command.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to stderr of the exec command.</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY</li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
</ul>
|
||
|
||
<h3 id="exec-start">Exec Start</h3>
|
||
|
||
<p><code>POST /exec/(id)/start</code></p>
|
||
|
||
<p>Starts a previously set up exec instance <code>id</code>. If <code>detach</code> is true, this API
|
||
returns after starting the <code>exec</code> command. Otherwise, this API sets up an
|
||
interactive session with the <code>exec</code> command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /exec/e90e34656806/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Detach&quot;: false,
|
||
&quot;Tty&quot;: false,
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Detach</strong> - Detach from the exec command</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
|
||
<li><p><strong>404</strong> – no such exec instance</p>
|
||
|
||
<p><strong>Stream details</strong>:
|
||
Similar to the stream behavior of <code>POST /container/(id)/attach</code> API</p></li>
|
||
</ul>
|
||
|
||
<h3 id="exec-resize">Exec Resize</h3>
|
||
|
||
<p><code>POST /exec/(id)/resize</code></p>
|
||
|
||
<p>Resizes the tty session used by the exec command <code>id</code>.
|
||
This API is valid only if <code>tty</code> was specified as part of creating and starting the exec command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /exec/e90e34656806/resize HTTP/1.1
|
||
Content-Type: text/plain
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 OK
|
||
Content-Type: text/plain
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>h</strong> – height of tty session</li>
|
||
<li><strong>w</strong> – width</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such exec instance</li>
|
||
</ul>
|
||
|
||
<h3 id="exec-inspect">Exec Inspect</h3>
|
||
|
||
<p><code>GET /exec/(id)/json</code></p>
|
||
|
||
<p>Return low-level information about the exec command <code>id</code>.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: plain/text
|
||
|
||
{
|
||
&quot;ID&quot; : &quot;11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39&quot;,
|
||
&quot;Running&quot; : false,
|
||
&quot;ExitCode&quot; : 2,
|
||
&quot;ProcessConfig&quot; : {
|
||
&quot;privileged&quot; : false,
|
||
&quot;user&quot; : &quot;&quot;,
|
||
&quot;tty&quot; : false,
|
||
&quot;entrypoint&quot; : &quot;sh&quot;,
|
||
&quot;arguments&quot; : [
|
||
&quot;-c&quot;,
|
||
&quot;exit 2&quot;
|
||
]
|
||
},
|
||
&quot;OpenStdin&quot; : false,
|
||
&quot;OpenStderr&quot; : false,
|
||
&quot;OpenStdout&quot; : false,
|
||
&quot;Container&quot; : {
|
||
&quot;State&quot; : {
|
||
&quot;Running&quot; : true,
|
||
&quot;Paused&quot; : false,
|
||
&quot;Restarting&quot; : false,
|
||
&quot;OOMKilled&quot; : false,
|
||
&quot;Pid&quot; : 3650,
|
||
&quot;ExitCode&quot; : 0,
|
||
&quot;Error&quot; : &quot;&quot;,
|
||
&quot;StartedAt&quot; : &quot;2014-11-17T22:26:03.717657531Z&quot;,
|
||
&quot;FinishedAt&quot; : &quot;0001-01-01T00:00:00Z&quot;
|
||
},
|
||
&quot;ID&quot; : &quot;8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c&quot;,
|
||
&quot;Created&quot; : &quot;2014-11-17T22:26:03.626304998Z&quot;,
|
||
&quot;Path&quot; : &quot;date&quot;,
|
||
&quot;Args&quot; : [],
|
||
&quot;Config&quot; : {
|
||
&quot;Hostname&quot; : &quot;8f177a186b97&quot;,
|
||
&quot;Domainname&quot; : &quot;&quot;,
|
||
&quot;User&quot; : &quot;&quot;,
|
||
&quot;AttachStdin&quot; : false,
|
||
&quot;AttachStdout&quot; : false,
|
||
&quot;AttachStderr&quot; : false,
|
||
&quot;PortSpecs&quot; : null,
|
||
&quot;ExposedPorts&quot; : null,
|
||
&quot;Tty&quot; : false,
|
||
&quot;OpenStdin&quot; : false,
|
||
&quot;StdinOnce&quot; : false,
|
||
&quot;Env&quot; : [ &quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot; ],
|
||
&quot;Cmd&quot; : [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Image&quot; : &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot; : null,
|
||
&quot;WorkingDir&quot; : &quot;&quot;,
|
||
&quot;Entrypoint&quot; : null,
|
||
&quot;NetworkDisabled&quot; : false,
|
||
&quot;MacAddress&quot; : &quot;&quot;,
|
||
&quot;OnBuild&quot; : null,
|
||
&quot;SecurityOpt&quot; : null
|
||
},
|
||
&quot;Image&quot; : &quot;5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5&quot;,
|
||
&quot;NetworkSettings&quot; : {
|
||
&quot;IPAddress&quot; : &quot;172.17.0.2&quot;,
|
||
&quot;IPPrefixLen&quot; : 16,
|
||
&quot;MacAddress&quot; : &quot;02:42:ac:11:00:02&quot;,
|
||
&quot;Gateway&quot; : &quot;172.17.42.1&quot;,
|
||
&quot;Bridge&quot; : &quot;docker0&quot;,
|
||
&quot;PortMapping&quot; : null,
|
||
&quot;Ports&quot; : {}
|
||
},
|
||
&quot;ResolvConfPath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf&quot;,
|
||
&quot;HostnamePath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname&quot;,
|
||
&quot;HostsPath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts&quot;,
|
||
&quot;LogPath&quot;: &quot;/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log&quot;,
|
||
&quot;Name&quot; : &quot;/test&quot;,
|
||
&quot;Driver&quot; : &quot;aufs&quot;,
|
||
&quot;ExecDriver&quot; : &quot;native-0.2&quot;,
|
||
&quot;MountLabel&quot; : &quot;&quot;,
|
||
&quot;ProcessLabel&quot; : &quot;&quot;,
|
||
&quot;AppArmorProfile&quot; : &quot;&quot;,
|
||
&quot;RestartCount&quot; : 0,
|
||
&quot;Volumes&quot; : {},
|
||
&quot;VolumesRW&quot; : {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such exec instance</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h1 id="3-going-further">3. Going further</h1>
|
||
|
||
<h2 id="3-1-inside-docker-run">3.1 Inside <code>docker run</code></h2>
|
||
|
||
<p>As an example, the <code>docker run</code> command line makes the following API calls:</p>
|
||
|
||
<ul>
|
||
<li><p>Create the container</p></li>
|
||
|
||
<li><p>If the status code is 404, it means the image doesn&rsquo;t exist:</p>
|
||
|
||
<ul>
|
||
<li>Try to pull it</li>
|
||
<li>Then retry to create the container</li>
|
||
</ul></li>
|
||
|
||
<li><p>Start the container</p></li>
|
||
|
||
<li><p>If you are not in detached mode:</p></li>
|
||
|
||
<li><p>Attach to the container, using logs=1 (to have stdout and
|
||
stderr from the container&rsquo;s start) and stream=1</p></li>
|
||
|
||
<li><p>If in detached mode or only stdin is attached:</p></li>
|
||
|
||
<li><p>Display the container&rsquo;s id</p></li>
|
||
</ul>
|
||
|
||
<h2 id="3-2-hijacking">3.2 Hijacking</h2>
|
||
|
||
<p>In this version of the API, /attach, uses hijacking to transport stdin,
|
||
stdout and stderr on the same socket.</p>
|
||
|
||
<p>To hint potential proxies about connection hijacking, Docker client sends
|
||
connection upgrade headers similarly to websocket.</p>
|
||
|
||
<pre><code>Upgrade: tcp
|
||
Connection: Upgrade
|
||
</code></pre>
|
||
|
||
<p>When Docker daemon detects the <code>Upgrade</code> header, it will switch its status code
|
||
from <strong>200 OK</strong> to <strong>101 UPGRADED</strong> and resend the same headers.</p>
|
||
|
||
<p>This might change in the future.</p>
|
||
|
||
<h2 id="3-3-cors-requests">3.3 CORS Requests</h2>
|
||
|
||
<p>To set cross origin requests to the remote api please give values to
|
||
&ldquo;&ndash;api-cors-header&rdquo; when running docker in daemon mode. Set * will allow all,
|
||
default or blank means CORS disabled</p>
|
||
|
||
<pre><code>$ docker -d -H=&quot;192.168.1.9:2375&quot; --api-cors-header=&quot;http://foo.bar&quot;
|
||
</code></pre>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>Remote API v1.19</title>
|
||
<link>http://localhost/reference/api/docker_remote_api_v1.19/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/docker_remote_api_v1.19/</guid>
|
||
<description>
|
||
|
||
<h1 id="docker-remote-api-v1-19">Docker Remote API v1.19</h1>
|
||
|
||
<h2 id="1-brief-introduction">1. Brief introduction</h2>
|
||
|
||
<ul>
|
||
<li>The Remote API has replaced <code>rcli</code>.</li>
|
||
<li>The daemon listens on <code>unix:///var/run/docker.sock</code> but you can
|
||
<a href="http://localhost/articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket">Bind Docker to another host/port or a Unix socket</a>.</li>
|
||
<li>The API tends to be REST. However, for some complex commands, like <code>attach</code>
|
||
or <code>pull</code>, the HTTP connection is hijacked to transport <code>stdout</code>,
|
||
<code>stdin</code> and <code>stderr</code>.</li>
|
||
<li>When the client API version is newer than the daemon&rsquo;s, these calls return an HTTP
|
||
<code>400 Bad Request</code> error message.</li>
|
||
</ul>
|
||
|
||
<h1 id="2-endpoints">2. Endpoints</h1>
|
||
|
||
<h2 id="2-1-containers">2.1 Containers</h2>
|
||
|
||
<h3 id="list-containers">List containers</h3>
|
||
|
||
<p><code>GET /containers/json</code></p>
|
||
|
||
<p>List containers</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /containers/json?all=1&amp;before=8dfafdbc3a40&amp;size=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;8dfafdbc3a40&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 1&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [{&quot;PrivatePort&quot;: 2222, &quot;PublicPort&quot;: 3333, &quot;Type&quot;: &quot;tcp&quot;}],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;9cd87474be90&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 222222&quot;,
|
||
&quot;Created&quot;: 1367854155,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;3176a2479c92&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 3333333333333333&quot;,
|
||
&quot;Created&quot;: 1367854154,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;:[],
|
||
&quot;SizeRw&quot;:12288,
|
||
&quot;SizeRootFs&quot;:0
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;4cb07b47f9fb&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu:latest&quot;,
|
||
&quot;Command&quot;: &quot;echo 444444444444444444444444444444444&quot;,
|
||
&quot;Created&quot;: 1367854152,
|
||
&quot;Status&quot;: &quot;Exit 0&quot;,
|
||
&quot;Ports&quot;: [],
|
||
&quot;SizeRw&quot;: 12288,
|
||
&quot;SizeRootFs&quot;: 0
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, Show all containers.
|
||
Only running containers are shown by default (i.e., this defaults to false)</li>
|
||
<li><strong>limit</strong> – Show <code>limit</code> last created
|
||
containers, include non-running ones.</li>
|
||
<li><strong>since</strong> – Show only containers created since Id, include
|
||
non-running ones.</li>
|
||
<li><strong>before</strong> – Show only containers created before Id, include
|
||
non-running ones.</li>
|
||
<li><strong>size</strong> – 1/True/true or 0/False/false, Show the containers
|
||
sizes</li>
|
||
<li><strong>filters</strong> - a JSON encoded value of the filters (a <code>map[string][]string</code>) to process on the containers list. Available filters:
|
||
|
||
<ul>
|
||
<li><code>exited=&lt;int&gt;</code>; &ndash; containers with exit code of <code>&lt;int&gt;</code> ;</li>
|
||
<li><code>status=</code>(<code>restarting</code>|<code>running</code>|<code>paused</code>|<code>exited</code>)</li>
|
||
<li><code>label=key</code> or <code>key=value</code> of a container label</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-container">Create a container</h3>
|
||
|
||
<p><code>POST /containers/create</code></p>
|
||
|
||
<p>Create a container</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/create HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Entrypoint&quot;: &quot;&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Labels&quot;: {
|
||
&quot;com.example.vendor&quot;: &quot;Acme&quot;,
|
||
&quot;com.example.license&quot;: &quot;GPL&quot;,
|
||
&quot;com.example.version&quot;: &quot;1.0&quot;
|
||
},
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;MacAddress&quot;: &quot;12:34:56:78:9a:bc&quot;,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
},
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;CpuPeriod&quot;: 100000,
|
||
&quot;CpusetCpus&quot;: &quot;0,1&quot;,
|
||
&quot;CpusetMems&quot;: &quot;0,1&quot;,
|
||
&quot;BlkioWeight&quot;: 300,
|
||
&quot;OomKillDisable&quot;: false,
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;ReadonlyRootfs&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: [],
|
||
&quot;Ulimits&quot;: [{}],
|
||
&quot;LogConfig&quot;: { &quot;Type&quot;: &quot;json-file&quot;, &quot;Config&quot;: {} },
|
||
&quot;SecurityOpt&quot;: [&quot;&quot;],
|
||
&quot;CgroupParent&quot;: &quot;&quot;
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 201 Created
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;:&quot;e90e34656806&quot;
|
||
&quot;Warnings&quot;:[]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Hostname</strong> - A string value containing the hostname to use for the
|
||
container.</li>
|
||
<li><strong>Domainname</strong> - A string value containing the domain name to use
|
||
for the container.</li>
|
||
<li><strong>User</strong> - A string value specifying the user inside the container.</li>
|
||
<li><strong>Memory</strong> - Memory limit in bytes.</li>
|
||
<li><strong>MemorySwap</strong>- Total memory limit (memory + swap); set <code>-1</code> to disable swap
|
||
You must use this with <code>memory</code> and make the swap value larger than <code>memory</code>.</li>
|
||
<li><strong>CpuShares</strong> - An integer value containing the container&rsquo;s CPU Shares
|
||
(ie. the relative weight vs other containers).</li>
|
||
<li><strong>CpuPeriod</strong> - The length of a CPU period in microseconds.</li>
|
||
<li><strong>Cpuset</strong> - Deprecated please don&rsquo;t use. Use <code>CpusetCpus</code> instead.</li>
|
||
<li><strong>CpusetCpus</strong> - String value containing the <code>cgroups CpusetCpus</code> to use.</li>
|
||
<li><strong>CpusetMems</strong> - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.</li>
|
||
<li><strong>BlkioWeight</strong> - Block IO weight (relative weight) accepts a weight value between 10 and 1000.</li>
|
||
<li><strong>OomKillDisable</strong> - Boolean value, whether to disable OOM Killer for the container or not.</li>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to <code>stdin</code>.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to <code>stdout</code>.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to <code>stderr</code>.</li>
|
||
<li><strong>Tty</strong> - Boolean value, Attach standard streams to a <code>tty</code>, including <code>stdin</code> if it is not closed.</li>
|
||
<li><strong>OpenStdin</strong> - Boolean value, opens stdin,</li>
|
||
<li><strong>StdinOnce</strong> - Boolean value, close <code>stdin</code> after the 1 attached client disconnects.</li>
|
||
<li><strong>Env</strong> - A list of environment variables in the form of <code>VAR=value</code></li>
|
||
<li><strong>Labels</strong> - Adds a map of labels to a container. To specify a map: <code>{&quot;key&quot;:&quot;value&quot;[,&quot;key2&quot;:&quot;value2&quot;]}</code></li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
<li><strong>Entrypoint</strong> - Set the entry point for the container as a string or an array
|
||
of strings.</li>
|
||
<li><strong>Image</strong> - A string specifying the image name to use for the container.</li>
|
||
<li><strong>Volumes</strong> – An object mapping mount point paths (strings) inside the
|
||
container to empty objects.</li>
|
||
<li><strong>WorkingDir</strong> - A string specifying the working directory for commands to
|
||
run in.</li>
|
||
<li><strong>NetworkDisabled</strong> - Boolean value, when true disables networking for the
|
||
container</li>
|
||
<li><strong>ExposedPorts</strong> - An object mapping ports to an empty object in the form of:
|
||
<code>&quot;ExposedPorts&quot;: { &quot;&lt;port&gt;/&lt;tcp|udp&gt;: {}&quot; }</code></li>
|
||
<li><strong>HostConfig</strong>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
|
||
|
||
<ul>
|
||
<li><code>container_path</code> to create a new volume for the container</li>
|
||
<li><code>host_path:container_path</code> to bind-mount a host path into the container</li>
|
||
<li><code>host_path:container_path:ro</code> to make the bind-mount read-only inside the container.</li>
|
||
</ul></li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be
|
||
in the form of <code>container_name:alias</code>.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. A JSON object in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>ReadonlyRootfs</strong> - Mount the container&rsquo;s root filesystem as read only.
|
||
Specified as a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of DNS servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains</li>
|
||
<li><strong>ExtraHosts</strong> - A list of hostnames/IP mappings to add to the
|
||
container&rsquo;s <code>/etc/hosts</code> file. Specified in the form <code>[&quot;hostname:IP&quot;]</code>.</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified as a JSON object in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
<li><strong>Ulimits</strong> - A list of ulimits to set in the container, specified as
|
||
<code>{ &quot;Name&quot;: &lt;name&gt;, &quot;Soft&quot;: &lt;soft limit&gt;, &quot;Hard&quot;: &lt;hard limit&gt; }</code>, for example:
|
||
<code>Ulimits: { &quot;Name&quot;: &quot;nofile&quot;, &quot;Soft&quot;: 1024, &quot;Hard&quot;, 2048 }}</code></li>
|
||
<li><strong>SecurityOpt</strong>: A list of string values to customize labels for MLS
|
||
systems, such as SELinux.</li>
|
||
<li><strong>LogConfig</strong> - Log configuration for the container, specified as a JSON object in the form
|
||
<code>{ &quot;Type&quot;: &quot;&lt;driver_name&gt;&quot;, &quot;Config&quot;: {&quot;key1&quot;: &quot;val1&quot;}}</code>.
|
||
Available types: <code>json-file</code>, <code>syslog</code>, <code>journald</code>, <code>none</code>.
|
||
<code>syslog</code> available options are: <code>address</code>.</li>
|
||
<li><strong>CgroupParent</strong> - Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>name</strong> – Assign the specified name to the container. Must
|
||
match <code>/?[a-zA-Z0-9_-]+</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>406</strong> – impossible to attach (container not running)</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-a-container">Inspect a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/json</code></p>
|
||
|
||
<p>Return low-level information on the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;AppArmorProfile&quot;: &quot;&quot;,
|
||
&quot;Args&quot;: [
|
||
&quot;-c&quot;,
|
||
&quot;exit 9&quot;
|
||
],
|
||
&quot;Config&quot;: {
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;Cmd&quot;: [
|
||
&quot;/bin/sh&quot;,
|
||
&quot;-c&quot;,
|
||
&quot;exit 9&quot;
|
||
],
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;Entrypoint&quot;: null,
|
||
&quot;Env&quot;: [
|
||
&quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;
|
||
],
|
||
&quot;ExposedPorts&quot;: null,
|
||
&quot;Hostname&quot;: &quot;ba033ac44011&quot;,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Labels&quot;: {
|
||
&quot;com.example.vendor&quot;: &quot;Acme&quot;,
|
||
&quot;com.example.license&quot;: &quot;GPL&quot;,
|
||
&quot;com.example.version&quot;: &quot;1.0&quot;
|
||
},
|
||
&quot;MacAddress&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;OnBuild&quot;: null,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Tty&quot;: false,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;Volumes&quot;: null,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;Created&quot;: &quot;2015-01-06T15:47:31.485331387Z&quot;,
|
||
&quot;Driver&quot;: &quot;devicemapper&quot;,
|
||
&quot;ExecDriver&quot;: &quot;native-0.2&quot;,
|
||
&quot;ExecIDs&quot;: null,
|
||
&quot;HostConfig&quot;: {
|
||
&quot;Binds&quot;: null,
|
||
&quot;BlkioWeight&quot;: 0,
|
||
&quot;CapAdd&quot;: null,
|
||
&quot;CapDrop&quot;: null,
|
||
&quot;ContainerIDFile&quot;: &quot;&quot;,
|
||
&quot;CpusetCpus&quot;: &quot;&quot;,
|
||
&quot;CpusetMems&quot;: &quot;&quot;,
|
||
&quot;CpuShares&quot;: 0,
|
||
&quot;CpuPeriod&quot;: 100000,
|
||
&quot;Devices&quot;: [],
|
||
&quot;Dns&quot;: null,
|
||
&quot;DnsSearch&quot;: null,
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;IpcMode&quot;: &quot;&quot;,
|
||
&quot;Links&quot;: null,
|
||
&quot;LxcConf&quot;: [],
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;OomKillDisable&quot;: false,
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;PortBindings&quot;: {},
|
||
&quot;Privileged&quot;: false,
|
||
&quot;ReadonlyRootfs&quot;: false,
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;RestartPolicy&quot;: {
|
||
&quot;MaximumRetryCount&quot;: 2,
|
||
&quot;Name&quot;: &quot;on-failure&quot;
|
||
},
|
||
&quot;LogConfig&quot;: {
|
||
&quot;Config&quot;: null,
|
||
&quot;Type&quot;: &quot;json-file&quot;
|
||
},
|
||
&quot;SecurityOpt&quot;: null,
|
||
&quot;VolumesFrom&quot;: null,
|
||
&quot;Ulimits&quot;: [{}]
|
||
},
|
||
&quot;HostnamePath&quot;: &quot;/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname&quot;,
|
||
&quot;HostsPath&quot;: &quot;/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts&quot;,
|
||
&quot;LogPath&quot;: &quot;/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log&quot;,
|
||
&quot;Id&quot;: &quot;ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39&quot;,
|
||
&quot;Image&quot;: &quot;04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2&quot;,
|
||
&quot;MountLabel&quot;: &quot;&quot;,
|
||
&quot;Name&quot;: &quot;/boring_euclid&quot;,
|
||
&quot;NetworkSettings&quot;: {
|
||
&quot;Bridge&quot;: &quot;&quot;,
|
||
&quot;Gateway&quot;: &quot;&quot;,
|
||
&quot;IPAddress&quot;: &quot;&quot;,
|
||
&quot;IPPrefixLen&quot;: 0,
|
||
&quot;MacAddress&quot;: &quot;&quot;,
|
||
&quot;PortMapping&quot;: null,
|
||
&quot;Ports&quot;: null
|
||
},
|
||
&quot;Path&quot;: &quot;/bin/sh&quot;,
|
||
&quot;ProcessLabel&quot;: &quot;&quot;,
|
||
&quot;ResolvConfPath&quot;: &quot;/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf&quot;,
|
||
&quot;RestartCount&quot;: 1,
|
||
&quot;State&quot;: {
|
||
&quot;Error&quot;: &quot;&quot;,
|
||
&quot;ExitCode&quot;: 9,
|
||
&quot;FinishedAt&quot;: &quot;2015-01-06T15:47:32.080254511Z&quot;,
|
||
&quot;OOMKilled&quot;: false,
|
||
&quot;Paused&quot;: false,
|
||
&quot;Pid&quot;: 0,
|
||
&quot;Restarting&quot;: false,
|
||
&quot;Running&quot;: false,
|
||
&quot;StartedAt&quot;: &quot;2015-01-06T15:47:32.072697474Z&quot;
|
||
},
|
||
&quot;Volumes&quot;: {},
|
||
&quot;VolumesRW&quot;: {}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="list-processes-running-inside-a-container">List processes running inside a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/top</code></p>
|
||
|
||
<p>List processes running inside the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /containers/4fa6e0f0c678/top HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Titles&quot;: [
|
||
&quot;USER&quot;,
|
||
&quot;PID&quot;,
|
||
&quot;%CPU&quot;,
|
||
&quot;%MEM&quot;,
|
||
&quot;VSZ&quot;,
|
||
&quot;RSS&quot;,
|
||
&quot;TTY&quot;,
|
||
&quot;STAT&quot;,
|
||
&quot;START&quot;,
|
||
&quot;TIME&quot;,
|
||
&quot;COMMAND&quot;
|
||
],
|
||
&quot;Processes&quot;: [
|
||
[&quot;root&quot;,&quot;20147&quot;,&quot;0.0&quot;,&quot;0.1&quot;,&quot;18060&quot;,&quot;1864&quot;,&quot;pts/4&quot;,&quot;S&quot;,&quot;10:06&quot;,&quot;0:00&quot;,&quot;bash&quot;],
|
||
[&quot;root&quot;,&quot;20271&quot;,&quot;0.0&quot;,&quot;0.0&quot;,&quot;4312&quot;,&quot;352&quot;,&quot;pts/4&quot;,&quot;S+&quot;,&quot;10:07&quot;,&quot;0:00&quot;,&quot;sleep&quot;,&quot;10&quot;]
|
||
]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>ps_args</strong> – ps arguments to use (e.g., aux)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-container-logs">Get container logs</h3>
|
||
|
||
<p><code>GET /containers/(id)/logs</code></p>
|
||
|
||
<p>Get <code>stdout</code> and <code>stderr</code> logs from the container <code>id</code></p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
This endpoint works only for containers with <code>json-file</code> logging driver.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> GET /containers/4fa6e0f0c678/logs?stderr=1&amp;stdout=1&amp;timestamps=1&amp;follow=1&amp;tail=10&amp;since=1428990821 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 101 UPGRADED
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
Connection: Upgrade
|
||
Upgrade: tcp
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>follow</strong> – 1/True/true or 0/False/false, return stream. Default <code>false</code>.</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, show <code>stdout</code> log. Default <code>false</code>.</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, show <code>stderr</code> log. Default <code>false</code>.</li>
|
||
<li><strong>since</strong> – UNIX timestamp (integer) to filter logs. Specifying a timestamp
|
||
will only output log-entries since that timestamp. Default: 0 (unfiltered)</li>
|
||
<li><strong>timestamps</strong> – 1/True/true or 0/False/false, print timestamps for
|
||
every log line. Default <code>false</code>.</li>
|
||
<li><strong>tail</strong> – Output specified number of lines at the end of logs: <code>all</code> or <code>&lt;number&gt;</code>. Default all.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>101</strong> – no error, hints proxy about hijacking</li>
|
||
<li><strong>200</strong> – no error, no upgrade header found</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-changes-on-a-container-s-filesystem">Inspect changes on a container&rsquo;s filesystem</h3>
|
||
|
||
<p><code>GET /containers/(id)/changes</code></p>
|
||
|
||
<p>Inspect changes on container <code>id</code>&rsquo;s filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /containers/4fa6e0f0c678/changes HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Path&quot;: &quot;/dev&quot;,
|
||
&quot;Kind&quot;: 0
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/dev/kmsg&quot;,
|
||
&quot;Kind&quot;: 1
|
||
},
|
||
{
|
||
&quot;Path&quot;: &quot;/test&quot;,
|
||
&quot;Kind&quot;: 1
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Values for <code>Kind</code>:</p>
|
||
|
||
<ul>
|
||
<li><code>0</code>: Modify</li>
|
||
<li><code>1</code>: Add</li>
|
||
<li><code>2</code>: Delete</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="export-a-container">Export a container</h3>
|
||
|
||
<p><code>GET /containers/(id)/export</code></p>
|
||
|
||
<p>Export the contents of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /containers/4fa6e0f0c678/export HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/octet-stream
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-container-stats-based-on-resource-usage">Get container stats based on resource usage</h3>
|
||
|
||
<p><code>GET /containers/(id)/stats</code></p>
|
||
|
||
<p>This endpoint returns a live stream of a container&rsquo;s resource usage statistics.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>: this functionality currently only works when using the <em>libcontainer</em> exec-driver.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /containers/redis1/stats HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;read&quot; : &quot;2015-01-08T22:57:31.547920715Z&quot;,
|
||
&quot;network&quot; : {
|
||
&quot;rx_dropped&quot; : 0,
|
||
&quot;rx_bytes&quot; : 648,
|
||
&quot;rx_errors&quot; : 0,
|
||
&quot;tx_packets&quot; : 8,
|
||
&quot;tx_dropped&quot; : 0,
|
||
&quot;rx_packets&quot; : 8,
|
||
&quot;tx_errors&quot; : 0,
|
||
&quot;tx_bytes&quot; : 648
|
||
},
|
||
&quot;memory_stats&quot; : {
|
||
&quot;stats&quot; : {
|
||
&quot;total_pgmajfault&quot; : 0,
|
||
&quot;cache&quot; : 0,
|
||
&quot;mapped_file&quot; : 0,
|
||
&quot;total_inactive_file&quot; : 0,
|
||
&quot;pgpgout&quot; : 414,
|
||
&quot;rss&quot; : 6537216,
|
||
&quot;total_mapped_file&quot; : 0,
|
||
&quot;writeback&quot; : 0,
|
||
&quot;unevictable&quot; : 0,
|
||
&quot;pgpgin&quot; : 477,
|
||
&quot;total_unevictable&quot; : 0,
|
||
&quot;pgmajfault&quot; : 0,
|
||
&quot;total_rss&quot; : 6537216,
|
||
&quot;total_rss_huge&quot; : 6291456,
|
||
&quot;total_writeback&quot; : 0,
|
||
&quot;total_inactive_anon&quot; : 0,
|
||
&quot;rss_huge&quot; : 6291456,
|
||
&quot;hierarchical_memory_limit&quot; : 67108864,
|
||
&quot;total_pgfault&quot; : 964,
|
||
&quot;total_active_file&quot; : 0,
|
||
&quot;active_anon&quot; : 6537216,
|
||
&quot;total_active_anon&quot; : 6537216,
|
||
&quot;total_pgpgout&quot; : 414,
|
||
&quot;total_cache&quot; : 0,
|
||
&quot;inactive_anon&quot; : 0,
|
||
&quot;active_file&quot; : 0,
|
||
&quot;pgfault&quot; : 964,
|
||
&quot;inactive_file&quot; : 0,
|
||
&quot;total_pgpgin&quot; : 477
|
||
},
|
||
&quot;max_usage&quot; : 6651904,
|
||
&quot;usage&quot; : 6537216,
|
||
&quot;failcnt&quot; : 0,
|
||
&quot;limit&quot; : 67108864
|
||
},
|
||
&quot;blkio_stats&quot; : {},
|
||
&quot;cpu_stats&quot; : {
|
||
&quot;cpu_usage&quot; : {
|
||
&quot;percpu_usage&quot; : [
|
||
16970827,
|
||
1839451,
|
||
7107380,
|
||
10571290
|
||
],
|
||
&quot;usage_in_usermode&quot; : 10000000,
|
||
&quot;total_usage&quot; : 36488948,
|
||
&quot;usage_in_kernelmode&quot; : 20000000
|
||
},
|
||
&quot;system_cpu_usage&quot; : 20091722000000000,
|
||
&quot;throttling_data&quot; : {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, pull stats once then disconnect. Default <code>true</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="resize-a-container-tty">Resize a container TTY</h3>
|
||
|
||
<p><code>POST /containers/(id)/resize?h=&lt;height&gt;&amp;w=&lt;width&gt;</code></p>
|
||
|
||
<p>Resize the TTY for container with <code>id</code>. You must restart the container for the resize to take effect.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/4fa6e0f0c678/resize?h=40&amp;w=80 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 200 OK
|
||
Content-Length: 0
|
||
Content-Type: text/plain; charset=utf-8
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – No such container</li>
|
||
<li><strong>500</strong> – Cannot resize container</li>
|
||
</ul>
|
||
|
||
<h3 id="start-a-container">Start a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/start</code></p>
|
||
|
||
<p>Start the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code> POST /containers/(id)/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Binds&quot;: [&quot;/tmp:/tmp&quot;],
|
||
&quot;Links&quot;: [&quot;redis3:redis&quot;],
|
||
&quot;LxcConf&quot;: {&quot;lxc.utsname&quot;:&quot;docker&quot;},
|
||
&quot;Memory&quot;: 0,
|
||
&quot;MemorySwap&quot;: 0,
|
||
&quot;CpuShares&quot;: 512,
|
||
&quot;CpusetCpus&quot;: &quot;0,1&quot;,
|
||
&quot;PortBindings&quot;: { &quot;22/tcp&quot;: [{ &quot;HostPort&quot;: &quot;11022&quot; }] },
|
||
&quot;PublishAllPorts&quot;: false,
|
||
&quot;Privileged&quot;: false,
|
||
&quot;ReadonlyRootfs&quot;: false,
|
||
&quot;Dns&quot;: [&quot;8.8.8.8&quot;],
|
||
&quot;DnsSearch&quot;: [&quot;&quot;],
|
||
&quot;ExtraHosts&quot;: null,
|
||
&quot;VolumesFrom&quot;: [&quot;parent&quot;, &quot;other:ro&quot;],
|
||
&quot;CapAdd&quot;: [&quot;NET_ADMIN&quot;],
|
||
&quot;CapDrop&quot;: [&quot;MKNOD&quot;],
|
||
&quot;RestartPolicy&quot;: { &quot;Name&quot;: &quot;&quot;, &quot;MaximumRetryCount&quot;: 0 },
|
||
&quot;NetworkMode&quot;: &quot;bridge&quot;,
|
||
&quot;Devices&quot;: [],
|
||
&quot;Ulimits&quot;: [{}],
|
||
&quot;LogConfig&quot;: { &quot;Type&quot;: &quot;json-file&quot;, &quot;Config&quot;: {} },
|
||
&quot;SecurityOpt&quot;: [&quot;&quot;],
|
||
&quot;CgroupParent&quot;: &quot;&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code> HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Binds</strong> – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
|
||
|
||
<ul>
|
||
<li><code>container_path</code> to create a new volume for the container</li>
|
||
<li><code>host_path:container_path</code> to bind-mount a host path into the container</li>
|
||
<li><code>host_path:container_path:ro</code> to make the bind-mount read-only inside the container.</li>
|
||
</ul></li>
|
||
<li><strong>Links</strong> - A list of links for the container. Each link entry should be of
|
||
of the form <code>container_name:alias</code>.</li>
|
||
<li><strong>LxcConf</strong> - LXC specific configurations. These configurations only
|
||
work when using the <code>lxc</code> execution driver.</li>
|
||
<li><strong>PortBindings</strong> - A map of exposed container ports and the host port they
|
||
should map to. A JSON object in the form
|
||
<code>{ &lt;port&gt;/&lt;protocol&gt;: [{ &quot;HostPort&quot;: &quot;&lt;port&gt;&quot; }] }</code>
|
||
Take note that <code>port</code> is specified as a string and not an integer value.</li>
|
||
<li><strong>PublishAllPorts</strong> - Allocates a random host port for all of a container&rsquo;s
|
||
exposed ports. Specified as a boolean value.</li>
|
||
<li><strong>Privileged</strong> - Gives the container full access to the host. Specified as
|
||
a boolean value.</li>
|
||
<li><strong>ReadonlyRootfs</strong> - Mount the container&rsquo;s root filesystem as read only.
|
||
Specified as a boolean value.</li>
|
||
<li><strong>Dns</strong> - A list of dns servers for the container to use.</li>
|
||
<li><strong>DnsSearch</strong> - A list of DNS search domains.</li>
|
||
<li><strong>ExtraHosts</strong> - A list of hostnames/IP mappings to add to the
|
||
container&rsquo;s <code>/etc/hosts</code> file. Specified in the form <code>[&quot;hostname:IP&quot;]</code>.</li>
|
||
<li><strong>VolumesFrom</strong> - A list of volumes to inherit from another container.
|
||
Specified in the form <code>&lt;container name&gt;[:&lt;ro|rw&gt;]</code></li>
|
||
<li><strong>CapAdd</strong> - A list of kernel capabilities to add to the container.</li>
|
||
<li><strong>Capdrop</strong> - A list of kernel capabilities to drop from the container.</li>
|
||
<li><strong>RestartPolicy</strong> – The behavior to apply when the container exits. The
|
||
value is an object with a <code>Name</code> property of either <code>&quot;always&quot;</code> to
|
||
always restart or <code>&quot;on-failure&quot;</code> to restart only when the container
|
||
exit code is non-zero. If <code>on-failure</code> is used, <code>MaximumRetryCount</code>
|
||
controls the number of times to retry before giving up.
|
||
The default is not to restart. (optional)
|
||
An ever increasing delay (double the previous delay, starting at 100mS)
|
||
is added before each restart to prevent flooding the server.</li>
|
||
<li><strong>NetworkMode</strong> - Sets the networking mode for the container. Supported
|
||
values are: <code>bridge</code>, <code>host</code>, and <code>container:&lt;name|id&gt;</code></li>
|
||
<li><strong>Devices</strong> - A list of devices to add to the container specified as a JSON object in the
|
||
form
|
||
<code>{ &quot;PathOnHost&quot;: &quot;/dev/deviceName&quot;, &quot;PathInContainer&quot;: &quot;/dev/deviceName&quot;, &quot;CgroupPermissions&quot;: &quot;mrw&quot;}</code></li>
|
||
<li><strong>Ulimits</strong> - A list of ulimits to set in the container, specified as
|
||
<code>{ &quot;Name&quot;: &lt;name&gt;, &quot;Soft&quot;: &lt;soft limit&gt;, &quot;Hard&quot;: &lt;hard limit&gt; }</code>, for example:
|
||
<code>Ulimits: { &quot;Name&quot;: &quot;nofile&quot;, &quot;Soft&quot;: 1024, &quot;Hard&quot;, 2048 }}</code></li>
|
||
<li><strong>SecurityOpt</strong>: A list of string values to customize labels for MLS
|
||
systems, such as SELinux.</li>
|
||
<li><strong>LogConfig</strong> - Log configuration for the container, specified as
|
||
<code>{ &quot;Type&quot;: &quot;&lt;driver_name&gt;&quot;, &quot;Config&quot;: {&quot;key1&quot;: &quot;val1&quot;}}</code>.
|
||
Available types: <code>json-file</code>, <code>syslog</code>, <code>journald</code>, <code>none</code>.
|
||
<code>json-file</code> logging driver.
|
||
|
||
<ul>
|
||
<li><strong>CgroupParent</strong> - Path to <code>cgroups</code> under which the container&rsquo;s <code>cgroup</code> is created. If the path is not absolute, the path is considered to be relative to the <code>cgroups</code> path of the init process. Cgroups are created if they do not already exist.</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already started</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="stop-a-container">Stop a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/stop</code></p>
|
||
|
||
<p>Stop the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/e90e34656806/stop?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>304</strong> – container already stopped</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="restart-a-container">Restart a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/restart</code></p>
|
||
|
||
<p>Restart the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/e90e34656806/restart?t=5 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>t</strong> – number of seconds to wait before killing the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="kill-a-container">Kill a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/kill</code></p>
|
||
|
||
<p>Kill the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/e90e34656806/kill HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters</p>
|
||
|
||
<ul>
|
||
<li><strong>signal</strong> - Signal to send to the container: integer or string like <code>SIGINT</code>.
|
||
When not set, <code>SIGKILL</code> is assumed and the call waits for the container to exit.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="rename-a-container">Rename a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/rename</code></p>
|
||
|
||
<p>Rename the container <code>id</code> to a <code>new_name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>name</strong> – new name for the container</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>409</strong> - conflict name already assigned</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="pause-a-container">Pause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/pause</code></p>
|
||
|
||
<p>Pause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/e90e34656806/pause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="unpause-a-container">Unpause a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/unpause</code></p>
|
||
|
||
<p>Unpause the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/e90e34656806/unpause HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container">Attach to a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/attach</code></p>
|
||
|
||
<p>Attach to the container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/16253994b7c4/attach?logs=1&amp;stream=0&amp;stdout=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 101 UPGRADED
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
Connection: Upgrade
|
||
Upgrade: tcp
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default <code>false</code>.</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default <code>false</code>.</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if <code>stream=true</code>, attach
|
||
to <code>stdin</code>. Default <code>false</code>.</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if <code>logs=true</code>, return
|
||
<code>stdout</code> log, if <code>stream=true</code>, attach to <code>stdout</code>. Default <code>false</code>.</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if <code>logs=true</code>, return
|
||
<code>stderr</code> log, if <code>stream=true</code>, attach to <code>stderr</code>. Default <code>false</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>101</strong> – no error, hints proxy about hijacking</li>
|
||
<li><strong>200</strong> – no error, no upgrade header found</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
|
||
<li><p><strong>500</strong> – server error</p>
|
||
|
||
<p><strong>Stream details</strong>:</p>
|
||
|
||
<p>When using the TTY setting is enabled in
|
||
<a href="http://localhost/docker/reference/api/docker_remote_api_v1.9/#create-a-container" title="POST /containers/create"><code>POST /containers/create</code>
|
||
</a>,
|
||
the stream is the raw data from the process PTY and client&rsquo;s <code>stdin</code>.
|
||
When the TTY is disabled, then the stream is multiplexed to separate
|
||
<code>stdout</code> and <code>stderr</code>.</p>
|
||
|
||
<p>The format is a <strong>Header</strong> and a <strong>Payload</strong> (frame).</p>
|
||
|
||
<p><strong>HEADER</strong></p>
|
||
|
||
<p>The header contains the information which the stream writes (<code>stdout</code> or
|
||
<code>stderr</code>). It also contains the size of the associated frame encoded in the
|
||
last four bytes (<code>uint32</code>).</p>
|
||
|
||
<p>It is encoded on the first eight bytes like this:</p>
|
||
|
||
<pre><code>header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
|
||
</code></pre>
|
||
|
||
<p><code>STREAM_TYPE</code> can be:</p></li>
|
||
|
||
<li><p>0: <code>stdin</code> (is written on <code>stdout</code>)</p></li>
|
||
|
||
<li><p>1: <code>stdout</code></p></li>
|
||
|
||
<li><p>2: <code>stderr</code></p>
|
||
|
||
<p><code>SIZE1, SIZE2, SIZE3, SIZE4</code> are the four bytes of
|
||
the <code>uint32</code> size encoded as big endian.</p>
|
||
|
||
<p><strong>PAYLOAD</strong></p>
|
||
|
||
<p>The payload is the raw stream.</p>
|
||
|
||
<p><strong>IMPLEMENTATION</strong></p>
|
||
|
||
<p>The simplest way to implement the Attach protocol is the following:</p>
|
||
|
||
<ol>
|
||
<li>Read eight bytes.</li>
|
||
<li>Choose <code>stdout</code> or <code>stderr</code> depending on the first byte.</li>
|
||
<li>Extract the frame size from the last four bytes.</li>
|
||
<li>Read the extracted size and output it on the correct output.</li>
|
||
<li>Goto 1.</li>
|
||
</ol></li>
|
||
</ul>
|
||
|
||
<h3 id="attach-to-a-container-websocket">Attach to a container (websocket)</h3>
|
||
|
||
<p><code>GET /containers/(id)/attach/ws</code></p>
|
||
|
||
<p>Attach to the container <code>id</code> via websocket</p>
|
||
|
||
<p>Implements websocket protocol handshake according to <a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a></p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code>GET /containers/e90e34656806/attach/ws?logs=0&amp;stream=1&amp;stdin=1&amp;stdout=1&amp;stderr=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong></p>
|
||
|
||
<pre><code>{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>logs</strong> – 1/True/true or 0/False/false, return logs. Default <code>false</code>.</li>
|
||
<li><strong>stream</strong> – 1/True/true or 0/False/false, return stream.
|
||
Default <code>false</code>.</li>
|
||
<li><strong>stdin</strong> – 1/True/true or 0/False/false, if <code>stream=true</code>, attach
|
||
to <code>stdin</code>. Default <code>false</code>.</li>
|
||
<li><strong>stdout</strong> – 1/True/true or 0/False/false, if <code>logs=true</code>, return
|
||
<code>stdout</code> log, if <code>stream=true</code>, attach to <code>stdout</code>. Default <code>false</code>.</li>
|
||
<li><strong>stderr</strong> – 1/True/true or 0/False/false, if <code>logs=true</code>, return
|
||
<code>stderr</code> log, if <code>stream=true</code>, attach to <code>stderr</code>. Default <code>false</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="wait-a-container">Wait a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/wait</code></p>
|
||
|
||
<p>Block until container <code>id</code> stops, then returns the exit code</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/16253994b7c4/wait HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;StatusCode&quot;: 0}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-a-container">Remove a container</h3>
|
||
|
||
<p><code>DELETE /containers/(id)</code></p>
|
||
|
||
<p>Remove the container <code>id</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>DELETE /containers/16253994b7c4?v=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 204 No Content
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>v</strong> – 1/True/true or 0/False/false, Remove the volumes
|
||
associated to the container. Default <code>false</code>.</li>
|
||
<li><strong>force</strong> - 1/True/true or 0/False/false, Kill then remove the container.
|
||
Default <code>false</code>.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="copy-files-or-folders-from-a-container">Copy files or folders from a container</h3>
|
||
|
||
<p><code>POST /containers/(id)/copy</code></p>
|
||
|
||
<p>Copy files or folders of container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/4fa6e0f0c678/copy HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Resource&quot;: &quot;test.txt&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-2-images">2.2 Images</h2>
|
||
|
||
<h3 id="list-images">List Images</h3>
|
||
|
||
<p><code>GET /images/json</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /images/json?all=0 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.04&quot;,
|
||
&quot;ubuntu:precise&quot;,
|
||
&quot;ubuntu:latest&quot;
|
||
],
|
||
&quot;Id&quot;: &quot;8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c&quot;,
|
||
&quot;Created&quot;: 1365714795,
|
||
&quot;Size&quot;: 131506275,
|
||
&quot;VirtualSize&quot;: 131506275
|
||
},
|
||
{
|
||
&quot;RepoTags&quot;: [
|
||
&quot;ubuntu:12.10&quot;,
|
||
&quot;ubuntu:quantal&quot;
|
||
],
|
||
&quot;ParentId&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;Size&quot;: 24653,
|
||
&quot;VirtualSize&quot;: 180116135
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p><strong>Example request, with digest information</strong>:</p>
|
||
|
||
<pre><code>GET /images/json?digests=1 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response, with digest information</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Created&quot;: 1420064636,
|
||
&quot;Id&quot;: &quot;4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125&quot;,
|
||
&quot;ParentId&quot;: &quot;ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2&quot;,
|
||
&quot;RepoDigests&quot;: [
|
||
&quot;localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf&quot;
|
||
],
|
||
&quot;RepoTags&quot;: [
|
||
&quot;localhost:5000/test/busybox:latest&quot;,
|
||
&quot;playdate:latest&quot;
|
||
],
|
||
&quot;Size&quot;: 0,
|
||
&quot;VirtualSize&quot;: 2429728
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>The response shows a single image <code>Id</code> associated with two repositories
|
||
(<code>RepoTags</code>): <code>localhost:5000/test/busybox</code>: and <code>playdate</code>. A caller can use
|
||
either of the <code>RepoTags</code> values <code>localhost:5000/test/busybox:latest</code> or
|
||
<code>playdate:latest</code> to reference the image.</p>
|
||
|
||
<p>You can also use <code>RepoDigests</code> values to reference an image. In this response,
|
||
the array has only one reference and that is to the
|
||
<code>localhost:5000/test/busybox</code> repository; the <code>playdate</code> repository has no
|
||
digest. You can reference this digest using the value:
|
||
<code>localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...</code></p>
|
||
|
||
<p>See the <code>docker run</code> and <code>docker build</code> commands for examples of digest and tag
|
||
references on the command line.</p>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>all</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>filters</strong> – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
|
||
|
||
<ul>
|
||
<li><code>dangling=true</code></li>
|
||
<li><code>label=key</code> or <code>key=value</code> of an image label</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<h3 id="build-image-from-a-dockerfile">Build image from a Dockerfile</h3>
|
||
|
||
<p><code>POST /build</code></p>
|
||
|
||
<p>Build an image from a Dockerfile</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /build HTTP/1.1
|
||
|
||
{{ TAR STREAM }}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;stream&quot;: &quot;Step 1...&quot;}
|
||
{&quot;stream&quot;: &quot;...&quot;}
|
||
{&quot;error&quot;: &quot;Error...&quot;, &quot;errorDetail&quot;: {&quot;code&quot;: 123, &quot;message&quot;: &quot;Error...&quot;}}
|
||
</code></pre>
|
||
|
||
<p>The input stream must be a <code>tar</code> archive compressed with one of the
|
||
following algorithms: <code>identity</code> (no compression), <code>gzip</code>, <code>bzip2</code>, <code>xz</code>.</p>
|
||
|
||
<p>The archive must include a build instructions file, typically called
|
||
<code>Dockerfile</code> at the archive&rsquo;s root. The <code>dockerfile</code> 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.</p>
|
||
|
||
<p>The archive may include any number of other files,
|
||
which are accessible in the build context (See the <a href="http://localhost/docker/reference/builder/#dockerbuilder"><em>ADD build
|
||
command</em></a>).</p>
|
||
|
||
<p>The build is canceled if the client drops the connection by quitting
|
||
or being killed.</p>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>dockerfile</strong> - Path within the build context to the Dockerfile. This is
|
||
ignored if <code>remote</code> is specified and points to an individual filename.</li>
|
||
<li><strong>t</strong> – A repository name (and optionally a tag) to apply to
|
||
the resulting image in case of success.</li>
|
||
<li><strong>remote</strong> – A Git repository URI or HTTP/HTTPS URI build source. If the
|
||
URI specifies a filename, the file&rsquo;s contents are placed into a file
|
||
called <code>Dockerfile</code>.</li>
|
||
<li><strong>q</strong> – Suppress verbose build output.</li>
|
||
<li><strong>nocache</strong> – Do not use the cache when building the image.</li>
|
||
<li><strong>pull</strong> - Attempt to pull the image even if an older image exists locally.</li>
|
||
<li><strong>rm</strong> - Remove intermediate containers after a successful build (default behavior).</li>
|
||
<li><strong>forcerm</strong> - Always remove intermediate containers (includes <code>rm</code>).</li>
|
||
<li><strong>memory</strong> - Set memory limit for build.</li>
|
||
<li><strong>memswap</strong> - Total memory (memory + swap), <code>-1</code> to disable swap.</li>
|
||
<li><strong>cpushares</strong> - CPU shares (relative weight).</li>
|
||
|
||
<li><p><strong>cpusetcpus</strong> - CPUs in which to allow execution (e.g., <code>0-3</code>, <code>0,1</code>).</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>Content-type</strong> – Set to <code>&quot;application/tar&quot;</code>.</p></li>
|
||
|
||
<li><p><strong>X-Registry-Config</strong> – base64-encoded ConfigFile object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-an-image">Create an image</h3>
|
||
|
||
<p><code>POST /images/create</code></p>
|
||
|
||
<p>Create an image either by pulling it from the registry or by importing it</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /images/create?fromImage=ubuntu HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pulling...&quot;}
|
||
{&quot;status&quot;: &quot;Pulling&quot;, &quot;progress&quot;: &quot;1 B/ 100 B&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1, &quot;total&quot;: 100}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
</code></pre>
|
||
|
||
<p>When using this endpoint to pull an image from the registry, the
|
||
<code>X-Registry-Auth</code> header can be used to include
|
||
a base64-encoded AuthConfig object.</p>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>fromImage</strong> – Name of the image to pull.</li>
|
||
<li><strong>fromSrc</strong> – Source to import. The value may be a URL from which the image
|
||
can be retrieved or <code>-</code> to read the image from the request body.</li>
|
||
<li><strong>repo</strong> – Repository name.</li>
|
||
<li><strong>tag</strong> – Tag.</li>
|
||
|
||
<li><p><strong>registry</strong> – The registry to pull from.</p>
|
||
|
||
<p>Request Headers:</p></li>
|
||
|
||
<li><p><strong>X-Registry-Auth</strong> – base64-encoded AuthConfig object</p></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="inspect-an-image">Inspect an image</h3>
|
||
|
||
<p><code>GET /images/(name)/json</code></p>
|
||
|
||
<p>Return low-level information on the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /images/ubuntu/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Created&quot;: &quot;2013-03-23T22:24:18.818426-07:00&quot;,
|
||
&quot;Container&quot;: &quot;3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0&quot;,
|
||
&quot;ContainerConfig&quot;:
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: false,
|
||
&quot;AttachStderr&quot;: false,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: true,
|
||
&quot;OpenStdin&quot;: true,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [&quot;/bin/bash&quot;],
|
||
&quot;Dns&quot;: null,
|
||
&quot;Image&quot;: &quot;ubuntu&quot;,
|
||
&quot;Labels&quot;: {
|
||
&quot;com.example.vendor&quot;: &quot;Acme&quot;,
|
||
&quot;com.example.license&quot;: &quot;GPL&quot;,
|
||
&quot;com.example.version&quot;: &quot;1.0&quot;
|
||
},
|
||
&quot;Volumes&quot;: null,
|
||
&quot;VolumesFrom&quot;: &quot;&quot;,
|
||
&quot;WorkingDir&quot;: &quot;&quot;
|
||
},
|
||
&quot;Id&quot;: &quot;b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc&quot;,
|
||
&quot;Parent&quot;: &quot;27cf784147099545&quot;,
|
||
&quot;Size&quot;: 6824592
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-the-history-of-an-image">Get the history of an image</h3>
|
||
|
||
<p><code>GET /images/(name)/history</code></p>
|
||
|
||
<p>Return the history of the image <code>name</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /images/ubuntu/history HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;Id&quot;: &quot;b750fe79269d&quot;,
|
||
&quot;Created&quot;: 1364102658,
|
||
&quot;CreatedBy&quot;: &quot;/bin/bash&quot;
|
||
},
|
||
{
|
||
&quot;Id&quot;: &quot;27cf78414709&quot;,
|
||
&quot;Created&quot;: 1364068391,
|
||
&quot;CreatedBy&quot;: &quot;&quot;
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="push-an-image-on-the-registry">Push an image on the registry</h3>
|
||
|
||
<p><code>POST /images/(name)/push</code></p>
|
||
|
||
<p>Push the image <code>name</code> on the registry</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /images/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;Pushing...&quot;}
|
||
{&quot;status&quot;: &quot;Pushing&quot;, &quot;progress&quot;: &quot;1/? (n/a)&quot;, &quot;progressDetail&quot;: {&quot;current&quot;: 1}}}
|
||
{&quot;error&quot;: &quot;Invalid...&quot;}
|
||
...
|
||
</code></pre>
|
||
|
||
<p>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 <code>hostname</code> and <code>port</code>. This repository name should
|
||
then be used in the URL. This duplicates the command line&rsquo;s flow.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /images/registry.acme.com:5000/test/push HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>tag</strong> – The tag to associate with the image on the registry. This is optional.</li>
|
||
</ul>
|
||
|
||
<p>Request Headers:</p>
|
||
|
||
<ul>
|
||
<li><strong>X-Registry-Auth</strong> – Include a base64-encoded AuthConfig.
|
||
object.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="tag-an-image-into-a-repository">Tag an image into a repository</h3>
|
||
|
||
<p><code>POST /images/(name)/tag</code></p>
|
||
|
||
<p>Tag the image <code>name</code> into a repository</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /images/test/tag?repo=myrepo&amp;force=0&amp;tag=v42 HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 201 OK
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>repo</strong> – The repository to tag in</li>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>tag</strong> - The new tag name</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>400</strong> – bad parameter</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="remove-an-image">Remove an image</h3>
|
||
|
||
<p><code>DELETE /images/(name)</code></p>
|
||
|
||
<p>Remove the image <code>name</code> from the filesystem</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>DELETE /images/test HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-type: application/json
|
||
|
||
[
|
||
{&quot;Untagged&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;3e2f21a89f&quot;},
|
||
{&quot;Deleted&quot;: &quot;53b4f83ac9&quot;}
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>force</strong> – 1/True/true or 0/False/false, default false</li>
|
||
<li><strong>noprune</strong> – 1/True/true or 0/False/false, default false</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such image</li>
|
||
<li><strong>409</strong> – conflict</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="search-images">Search images</h3>
|
||
|
||
<p><code>GET /images/search</code></p>
|
||
|
||
<p>Search for an image on <a href="https://hub.docker.com">Docker Hub</a>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
The response keys have changed from API v1.6 to reflect the JSON
|
||
sent by the registry server to the docker daemon&rsquo;s request.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /images/search?term=sshd HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
[
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;wma55/u1210sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;jdswinbank/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
},
|
||
{
|
||
&quot;description&quot;: &quot;&quot;,
|
||
&quot;is_official&quot;: false,
|
||
&quot;is_automated&quot;: false,
|
||
&quot;name&quot;: &quot;vgauthier/sshd&quot;,
|
||
&quot;star_count&quot;: 0
|
||
}
|
||
...
|
||
]
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>term</strong> – term to search</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h2 id="2-3-misc">2.3 Misc</h2>
|
||
|
||
<h3 id="check-auth-configuration">Check auth configuration</h3>
|
||
|
||
<p><code>POST /auth</code></p>
|
||
|
||
<p>Get the default username and email</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /auth HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;username&quot;:&quot; hannibal&quot;,
|
||
&quot;password: &quot;xxxx&quot;,
|
||
&quot;email&quot;: &quot;hannibal@a-team.com&quot;,
|
||
&quot;serveraddress&quot;: &quot;https://index.docker.io/v1/&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>204</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="display-system-wide-information">Display system-wide information</h3>
|
||
|
||
<p><code>GET /info</code></p>
|
||
|
||
<p>Display system-wide information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /info HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Containers&quot;: 11,
|
||
&quot;CpuCfsPeriod&quot;: true,
|
||
&quot;CpuCfsQuota&quot;: true,
|
||
&quot;Debug&quot;: false,
|
||
&quot;DockerRootDir&quot;: &quot;/var/lib/docker&quot;,
|
||
&quot;Driver&quot;: &quot;btrfs&quot;,
|
||
&quot;DriverStatus&quot;: [[&quot;&quot;]],
|
||
&quot;ExecutionDriver&quot;: &quot;native-0.1&quot;,
|
||
&quot;ExperimentalBuild&quot;: false,
|
||
&quot;HttpProxy&quot;: &quot;http://test:test@localhost:8080&quot;,
|
||
&quot;HttpsProxy&quot;: &quot;https://test:test@localhost:8080&quot;,
|
||
&quot;ID&quot;: &quot;7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS&quot;,
|
||
&quot;IPv4Forwarding&quot;: true,
|
||
&quot;Images&quot;: 16,
|
||
&quot;IndexServerAddress&quot;: &quot;https://index.docker.io/v1/&quot;,
|
||
&quot;InitPath&quot;: &quot;/usr/bin/docker&quot;,
|
||
&quot;InitSha1&quot;: &quot;&quot;,
|
||
&quot;KernelVersion&quot;: &quot;3.12.0-1-amd64&quot;,
|
||
&quot;Labels&quot;: [
|
||
&quot;storage=ssd&quot;
|
||
],
|
||
&quot;MemTotal&quot;: 2099236864,
|
||
&quot;MemoryLimit&quot;: true,
|
||
&quot;NCPU&quot;: 1,
|
||
&quot;NEventsListener&quot;: 0,
|
||
&quot;NFd&quot;: 11,
|
||
&quot;NGoroutines&quot;: 21,
|
||
&quot;Name&quot;: &quot;prod-server-42&quot;,
|
||
&quot;NoProxy&quot;: &quot;9.81.1.160&quot;,
|
||
&quot;OomKillDisable&quot;: true,
|
||
&quot;OperatingSystem&quot;: &quot;Boot2Docker&quot;,
|
||
&quot;RegistryConfig&quot;: {
|
||
&quot;IndexConfigs&quot;: {
|
||
&quot;docker.io&quot;: {
|
||
&quot;Mirrors&quot;: null,
|
||
&quot;Name&quot;: &quot;docker.io&quot;,
|
||
&quot;Official&quot;: true,
|
||
&quot;Secure&quot;: true
|
||
}
|
||
},
|
||
&quot;InsecureRegistryCIDRs&quot;: [
|
||
&quot;127.0.0.0/8&quot;
|
||
]
|
||
},
|
||
&quot;SwapLimit&quot;: false,
|
||
&quot;SystemTime&quot;: &quot;2015-03-10T11:11:23.730591467-07:00&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="show-the-docker-version-information">Show the docker version information</h3>
|
||
|
||
<p><code>GET /version</code></p>
|
||
|
||
<p>Show the docker version information</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /version HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Version&quot;: &quot;1.5.0&quot;,
|
||
&quot;Os&quot;: &quot;linux&quot;,
|
||
&quot;KernelVersion&quot;: &quot;3.18.5-tinycore64&quot;,
|
||
&quot;GoVersion&quot;: &quot;go1.4.1&quot;,
|
||
&quot;GitCommit&quot;: &quot;a8a31ef&quot;,
|
||
&quot;Arch&quot;: &quot;amd64&quot;,
|
||
&quot;ApiVersion&quot;: &quot;1.19&quot;
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="ping-the-docker-server">Ping the docker server</h3>
|
||
|
||
<p><code>GET /_ping</code></p>
|
||
|
||
<p>Ping the docker server</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /_ping HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: text/plain
|
||
|
||
OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> - no error</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h3 id="create-a-new-image-from-a-container-s-changes">Create a new image from a container&rsquo;s changes</h3>
|
||
|
||
<p><code>POST /commit</code></p>
|
||
|
||
<p>Create a new image from a container&rsquo;s changes</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /commit?container=44c004db4b17&amp;comment=message&amp;repo=myrepo HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Hostname&quot;: &quot;&quot;,
|
||
&quot;Domainname&quot;: &quot;&quot;,
|
||
&quot;User&quot;: &quot;&quot;,
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;PortSpecs&quot;: null,
|
||
&quot;Tty&quot;: false,
|
||
&quot;OpenStdin&quot;: false,
|
||
&quot;StdinOnce&quot;: false,
|
||
&quot;Env&quot;: null,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Volumes&quot;: {
|
||
&quot;/tmp&quot;: {}
|
||
},
|
||
&quot;WorkingDir&quot;: &quot;&quot;,
|
||
&quot;NetworkDisabled&quot;: false,
|
||
&quot;ExposedPorts&quot;: {
|
||
&quot;22/tcp&quot;: {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 201 Created
|
||
Content-Type: application/vnd.docker.raw-stream
|
||
|
||
{&quot;Id&quot;: &quot;596069db4bf5&quot;}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>config</strong> - the container&rsquo;s configuration</li>
|
||
</ul>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>container</strong> – source container</li>
|
||
<li><strong>repo</strong> – repository</li>
|
||
<li><strong>tag</strong> – tag</li>
|
||
<li><strong>comment</strong> – commit message</li>
|
||
<li><strong>author</strong> – author (e.g., &ldquo;John Hannibal Smith
|
||
&lt;<a href="mailto:hannibal%40a-team.com">hannibal@a-team.com</a>&gt;&ldquo;)</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="monitor-docker-s-events">Monitor Docker&rsquo;s events</h3>
|
||
|
||
<p><code>GET /events</code></p>
|
||
|
||
<p>Get container events from docker, either in real time via streaming, or via
|
||
polling (using since).</p>
|
||
|
||
<p>Docker containers report the following events:</p>
|
||
|
||
<pre><code>create, destroy, die, exec_create, exec_start, export, kill, oom, pause, restart, start, stop, unpause
|
||
</code></pre>
|
||
|
||
<p>and Docker images report:</p>
|
||
|
||
<pre><code>untag, delete
|
||
</code></pre>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /events?since=1374067924
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/json
|
||
|
||
{&quot;status&quot;: &quot;create&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;start&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067924}
|
||
{&quot;status&quot;: &quot;stop&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067966}
|
||
{&quot;status&quot;: &quot;destroy&quot;, &quot;id&quot;: &quot;dfdf82bd3881&quot;,&quot;from&quot;: &quot;ubuntu:latest&quot;, &quot;time&quot;:1374067970}
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>since</strong> – Timestamp used for polling</li>
|
||
<li><strong>until</strong> – Timestamp used for polling</li>
|
||
<li><strong>filters</strong> – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
|
||
|
||
<ul>
|
||
<li><code>event=&lt;string&gt;</code>; &ndash; event to filter</li>
|
||
<li><code>image=&lt;string&gt;</code>; &ndash; image to filter</li>
|
||
<li><code>container=&lt;string&gt;</code>; &ndash; container to filter</li>
|
||
</ul></li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images-in-a-repository">Get a tarball containing all images in a repository</h3>
|
||
|
||
<p><code>GET /images/(name)/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for the repository specified
|
||
by <code>name</code>.</p>
|
||
|
||
<p>If <code>name</code> is a specific name and tag (e.g. ubuntu:latest), then only that image
|
||
(and its parents) are returned. If <code>name</code> is an image ID, similarly only that
|
||
image (and its parents) are returned, but with the exclusion of the
|
||
&lsquo;repositories&rsquo; file in the tarball, as there were no image names referenced.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code>GET /images/ubuntu/get
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="get-a-tarball-containing-all-images">Get a tarball containing all images.</h3>
|
||
|
||
<p><code>GET /images/get</code></p>
|
||
|
||
<p>Get a tarball containing all images and metadata for one or more repositories.</p>
|
||
|
||
<p>For each value of the <code>names</code> parameter: if it is a specific name and tag (e.g.
|
||
<code>ubuntu:latest</code>), 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 &lsquo;repositories&rsquo; file for this image ID.</p>
|
||
|
||
<p>See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code>GET /images/get?names=myname%2Fmyapp%3Alatest&amp;names=busybox
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: application/x-tar
|
||
|
||
Binary data stream
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="load-a-tarball-with-a-set-of-images-and-tags-into-docker">Load a tarball with a set of images and tags into docker</h3>
|
||
|
||
<p><code>POST /images/load</code></p>
|
||
|
||
<p>Load a set of images and tags into a Docker repository.
|
||
See the <a href="#image-tarball-format">image tarball format</a> for more details.</p>
|
||
|
||
<p><strong>Example request</strong></p>
|
||
|
||
<pre><code>POST /images/load
|
||
|
||
Tarball in body
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>500</strong> – server error</li>
|
||
</ul>
|
||
|
||
<h3 id="image-tarball-format">Image tarball format</h3>
|
||
|
||
<p>An image tarball contains one directory per image layer (named using its long ID),
|
||
each containing these files:</p>
|
||
|
||
<ul>
|
||
<li><code>VERSION</code>: currently <code>1.0</code> - the file format version</li>
|
||
<li><code>json</code>: detailed layer information, similar to <code>docker inspect layer_id</code></li>
|
||
<li><code>layer.tar</code>: A tarfile containing the filesystem changes in this layer</li>
|
||
</ul>
|
||
|
||
<p>The <code>layer.tar</code> file contains <code>aufs</code> style <code>.wh..wh.aufs</code> files and directories
|
||
for storing attribute changes and deletions.</p>
|
||
|
||
<p>If the tarball defines a repository, the tarball should also include a <code>repositories</code> file at
|
||
the root that contains a list of repository and tag names mapped to layer IDs.</p>
|
||
|
||
<pre><code>{&quot;hello-world&quot;:
|
||
{&quot;latest&quot;: &quot;565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1&quot;}
|
||
}
|
||
</code></pre>
|
||
|
||
<h3 id="exec-create">Exec Create</h3>
|
||
|
||
<p><code>POST /containers/(id)/exec</code></p>
|
||
|
||
<p>Sets up an exec instance in a running container <code>id</code></p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /containers/e90e34656806/exec HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;AttachStdin&quot;: false,
|
||
&quot;AttachStdout&quot;: true,
|
||
&quot;AttachStderr&quot;: true,
|
||
&quot;Tty&quot;: false,
|
||
&quot;Cmd&quot;: [
|
||
&quot;date&quot;
|
||
],
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Id&quot;: &quot;f90e34656806&quot;
|
||
&quot;Warnings&quot;:[]
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>AttachStdin</strong> - Boolean value, attaches to <code>stdin</code> of the <code>exec</code> command.</li>
|
||
<li><strong>AttachStdout</strong> - Boolean value, attaches to <code>stdout</code> of the <code>exec</code> command.</li>
|
||
<li><strong>AttachStderr</strong> - Boolean value, attaches to <code>stderr</code> of the <code>exec</code> command.</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY.</li>
|
||
<li><strong>Cmd</strong> - Command to run specified as a string or an array of strings.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such container</li>
|
||
</ul>
|
||
|
||
<h3 id="exec-start">Exec Start</h3>
|
||
|
||
<p><code>POST /exec/(id)/start</code></p>
|
||
|
||
<p>Starts a previously set up <code>exec</code> instance <code>id</code>. If <code>detach</code> is true, this API
|
||
returns after starting the <code>exec</code> command. Otherwise, this API sets up an
|
||
interactive session with the <code>exec</code> command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /exec/e90e34656806/start HTTP/1.1
|
||
Content-Type: application/json
|
||
|
||
{
|
||
&quot;Detach&quot;: false,
|
||
&quot;Tty&quot;: false,
|
||
}
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 201 OK
|
||
Content-Type: application/json
|
||
|
||
{{ STREAM }}
|
||
</code></pre>
|
||
|
||
<p>Json Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>Detach</strong> - Detach from the <code>exec</code> command.</li>
|
||
<li><strong>Tty</strong> - Boolean value to allocate a pseudo-TTY.</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
|
||
<li><p><strong>404</strong> – no such exec instance</p>
|
||
|
||
<p><strong>Stream details</strong>:
|
||
Similar to the stream behavior of <code>POST /container/(id)/attach</code> API</p></li>
|
||
</ul>
|
||
|
||
<h3 id="exec-resize">Exec Resize</h3>
|
||
|
||
<p><code>POST /exec/(id)/resize</code></p>
|
||
|
||
<p>Resizes the <code>tty</code> session used by the <code>exec</code> command <code>id</code>.
|
||
This API is valid only if <code>tty</code> was specified as part of creating and starting the <code>exec</code> command.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>POST /exec/e90e34656806/resize HTTP/1.1
|
||
Content-Type: text/plain
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 201 OK
|
||
Content-Type: text/plain
|
||
</code></pre>
|
||
|
||
<p>Query Parameters:</p>
|
||
|
||
<ul>
|
||
<li><strong>h</strong> – height of <code>tty</code> session</li>
|
||
<li><strong>w</strong> – width</li>
|
||
</ul>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>201</strong> – no error</li>
|
||
<li><strong>404</strong> – no such exec instance</li>
|
||
</ul>
|
||
|
||
<h3 id="exec-inspect">Exec Inspect</h3>
|
||
|
||
<p><code>GET /exec/(id)/json</code></p>
|
||
|
||
<p>Return low-level information about the <code>exec</code> command <code>id</code>.</p>
|
||
|
||
<p><strong>Example request</strong>:</p>
|
||
|
||
<pre><code>GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
|
||
</code></pre>
|
||
|
||
<p><strong>Example response</strong>:</p>
|
||
|
||
<pre><code>HTTP/1.1 200 OK
|
||
Content-Type: plain/text
|
||
|
||
{
|
||
&quot;ID&quot; : &quot;11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39&quot;,
|
||
&quot;Running&quot; : false,
|
||
&quot;ExitCode&quot; : 2,
|
||
&quot;ProcessConfig&quot; : {
|
||
&quot;privileged&quot; : false,
|
||
&quot;user&quot; : &quot;&quot;,
|
||
&quot;tty&quot; : false,
|
||
&quot;entrypoint&quot; : &quot;sh&quot;,
|
||
&quot;arguments&quot; : [
|
||
&quot;-c&quot;,
|
||
&quot;exit 2&quot;
|
||
]
|
||
},
|
||
&quot;OpenStdin&quot; : false,
|
||
&quot;OpenStderr&quot; : false,
|
||
&quot;OpenStdout&quot; : false,
|
||
&quot;Container&quot; : {
|
||
&quot;State&quot; : {
|
||
&quot;Running&quot; : true,
|
||
&quot;Paused&quot; : false,
|
||
&quot;Restarting&quot; : false,
|
||
&quot;OOMKilled&quot; : false,
|
||
&quot;Pid&quot; : 3650,
|
||
&quot;ExitCode&quot; : 0,
|
||
&quot;Error&quot; : &quot;&quot;,
|
||
&quot;StartedAt&quot; : &quot;2014-11-17T22:26:03.717657531Z&quot;,
|
||
&quot;FinishedAt&quot; : &quot;0001-01-01T00:00:00Z&quot;
|
||
},
|
||
&quot;ID&quot; : &quot;8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c&quot;,
|
||
&quot;Created&quot; : &quot;2014-11-17T22:26:03.626304998Z&quot;,
|
||
&quot;Path&quot; : &quot;date&quot;,
|
||
&quot;Args&quot; : [],
|
||
&quot;Config&quot; : {
|
||
&quot;Hostname&quot; : &quot;8f177a186b97&quot;,
|
||
&quot;Domainname&quot; : &quot;&quot;,
|
||
&quot;User&quot; : &quot;&quot;,
|
||
&quot;AttachStdin&quot; : false,
|
||
&quot;AttachStdout&quot; : false,
|
||
&quot;AttachStderr&quot; : false,
|
||
&quot;PortSpecs&quot; : null,
|
||
&quot;ExposedPorts&quot; : null,
|
||
&quot;Tty&quot; : false,
|
||
&quot;OpenStdin&quot; : false,
|
||
&quot;StdinOnce&quot; : false,
|
||
&quot;Env&quot; : [ &quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot; ],
|
||
&quot;Cmd&quot; : [
|
||
&quot;date&quot;
|
||
],
|
||
&quot;Image&quot; : &quot;ubuntu&quot;,
|
||
&quot;Volumes&quot; : null,
|
||
&quot;WorkingDir&quot; : &quot;&quot;,
|
||
&quot;Entrypoint&quot; : null,
|
||
&quot;NetworkDisabled&quot; : false,
|
||
&quot;MacAddress&quot; : &quot;&quot;,
|
||
&quot;OnBuild&quot; : null,
|
||
&quot;SecurityOpt&quot; : null
|
||
},
|
||
&quot;Image&quot; : &quot;5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5&quot;,
|
||
&quot;NetworkSettings&quot; : {
|
||
&quot;IPAddress&quot; : &quot;172.17.0.2&quot;,
|
||
&quot;IPPrefixLen&quot; : 16,
|
||
&quot;MacAddress&quot; : &quot;02:42:ac:11:00:02&quot;,
|
||
&quot;Gateway&quot; : &quot;172.17.42.1&quot;,
|
||
&quot;Bridge&quot; : &quot;docker0&quot;,
|
||
&quot;PortMapping&quot; : null,
|
||
&quot;Ports&quot; : {}
|
||
},
|
||
&quot;ResolvConfPath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf&quot;,
|
||
&quot;HostnamePath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname&quot;,
|
||
&quot;HostsPath&quot; : &quot;/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts&quot;,
|
||
&quot;LogPath&quot;: &quot;/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log&quot;,
|
||
&quot;Name&quot; : &quot;/test&quot;,
|
||
&quot;Driver&quot; : &quot;aufs&quot;,
|
||
&quot;ExecDriver&quot; : &quot;native-0.2&quot;,
|
||
&quot;MountLabel&quot; : &quot;&quot;,
|
||
&quot;ProcessLabel&quot; : &quot;&quot;,
|
||
&quot;AppArmorProfile&quot; : &quot;&quot;,
|
||
&quot;RestartCount&quot; : 0,
|
||
&quot;Volumes&quot; : {},
|
||
&quot;VolumesRW&quot; : {}
|
||
}
|
||
}
|
||
</code></pre>
|
||
|
||
<p>Status Codes:</p>
|
||
|
||
<ul>
|
||
<li><strong>200</strong> – no error</li>
|
||
<li><strong>404</strong> – no such exec instance</li>
|
||
<li><strong>500</strong> - server error</li>
|
||
</ul>
|
||
|
||
<h1 id="3-going-further">3. Going further</h1>
|
||
|
||
<h2 id="3-1-inside-docker-run">3.1 Inside <code>docker run</code></h2>
|
||
|
||
<p>As an example, the <code>docker run</code> command line makes the following API calls:</p>
|
||
|
||
<ul>
|
||
<li><p>Create the container</p></li>
|
||
|
||
<li><p>If the status code is 404, it means the image doesn&rsquo;t exist:</p>
|
||
|
||
<ul>
|
||
<li>Try to pull it.</li>
|
||
<li>Then, retry to create the container.</li>
|
||
</ul></li>
|
||
|
||
<li><p>Start the container.</p></li>
|
||
|
||
<li><p>If you are not in detached mode:</p></li>
|
||
|
||
<li><p>Attach to the container, using <code>logs=1</code> (to have <code>stdout</code> and
|
||
<code>stderr</code> from the container&rsquo;s start) and <code>stream=1</code></p></li>
|
||
|
||
<li><p>If in detached mode or only <code>stdin</code> is attached, display the container&rsquo;s id.</p></li>
|
||
</ul>
|
||
|
||
<h2 id="3-2-hijacking">3.2 Hijacking</h2>
|
||
|
||
<p>In this version of the API, <code>/attach</code>, uses hijacking to transport <code>stdin</code>,
|
||
<code>stdout</code>, and <code>stderr</code> on the same socket.</p>
|
||
|
||
<p>To hint potential proxies about connection hijacking, Docker client sends
|
||
connection upgrade headers similarly to websocket.</p>
|
||
|
||
<pre><code>Upgrade: tcp
|
||
Connection: Upgrade
|
||
</code></pre>
|
||
|
||
<p>When Docker daemon detects the <code>Upgrade</code> header, it switches its status code
|
||
from <strong>200 OK</strong> to <strong>101 UPGRADED</strong> and resends the same headers.</p>
|
||
|
||
<h2 id="3-3-cors-requests">3.3 CORS Requests</h2>
|
||
|
||
<p>To set cross origin requests to the remote api please give values to
|
||
<code>--api-cors-header</code> when running Docker in daemon mode. Set * (asterisk) allows all,
|
||
default or blank means CORS disabled</p>
|
||
|
||
<pre><code>$ docker -d -H=&quot;192.168.1.9:2375&quot; --api-cors-header=&quot;http://foo.bar&quot;
|
||
</code></pre>
|
||
</description>
|
||
</item>
|
||
|
||
<item>
|
||
<title>The Docker Hub and the Registry v1</title>
|
||
<link>http://localhost/reference/api/hub_registry_spec/</link>
|
||
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
|
||
|
||
<guid>http://localhost/reference/api/hub_registry_spec/</guid>
|
||
<description>
|
||
|
||
<h1 id="the-docker-hub-and-the-registry-v1">The Docker Hub and the Registry v1</h1>
|
||
|
||
<h2 id="the-three-roles">The three roles</h2>
|
||
|
||
<p>There are three major components playing a role in the Docker ecosystem.</p>
|
||
|
||
<h3 id="docker-hub">Docker Hub</h3>
|
||
|
||
<p>The Docker Hub is responsible for centralizing information about:</p>
|
||
|
||
<ul>
|
||
<li>User accounts</li>
|
||
<li>Checksums of the images</li>
|
||
<li>Public namespaces</li>
|
||
</ul>
|
||
|
||
<p>The Docker Hub has different components:</p>
|
||
|
||
<ul>
|
||
<li>Web UI</li>
|
||
<li>Meta-data store (comments, stars, list public repositories)</li>
|
||
<li>Authentication service</li>
|
||
<li>Tokenization</li>
|
||
</ul>
|
||
|
||
<p>The Docker Hub is authoritative for that information.</p>
|
||
|
||
<p>There is only one instance of the Docker Hub, run and
|
||
managed by Docker Inc.</p>
|
||
|
||
<h3 id="docker-registry-1-0">Docker Registry 1.0</h3>
|
||
|
||
<p>The 1.0 registry has the following characteristics:</p>
|
||
|
||
<ul>
|
||
<li>It stores the images and the graph for a set of repositories</li>
|
||
<li>It does not have user accounts data</li>
|
||
<li>It has no notion of user accounts or authorization</li>
|
||
<li>It delegates authentication and authorization to the Docker Hub Auth
|
||
service using tokens</li>
|
||
<li>It supports different storage backends (S3, cloud files, local FS)</li>
|
||
<li>It doesn&rsquo;t have a local database</li>
|
||
<li><a href="https://github.com/docker/docker-registry">Source Code</a></li>
|
||
</ul>
|
||
|
||
<p>We expect that there will be multiple registries out there. To help you
|
||
grasp the context, here are some examples of registries:</p>
|
||
|
||
<ul>
|
||
<li><strong>sponsor registry</strong>: such a registry is provided by a third-party
|
||
hosting infrastructure as a convenience for their customers and the
|
||
Docker community as a whole. Its costs are supported by the third
|
||
party, but the management and operation of the registry are
|
||
supported by Docker, Inc. It features read/write access, and delegates
|
||
authentication and authorization to the Docker Hub.</li>
|
||
<li><strong>mirror registry</strong>: such a registry is provided by a third-party
|
||
hosting infrastructure but is targeted at their customers only. Some
|
||
mechanism (unspecified to date) ensures that public images are
|
||
pulled from a sponsor registry to the mirror registry, to make sure
|
||
that the customers of the third-party provider can <code>docker pull</code>
|
||
those images locally.</li>
|
||
<li><strong>vendor registry</strong>: such a registry is provided by a software
|
||
vendor who wants to distribute docker images. It would be operated
|
||
and managed by the vendor. Only users authorized by the vendor would
|
||
be able to get write access. Some images would be public (accessible
|
||
for anyone), others private (accessible only for authorized users).
|
||
Authentication and authorization would be delegated to the Docker Hub.
|
||
The goal of vendor registries is to let someone do <code>docker pull
|
||
basho/riak1.3</code> and automatically push from the vendor registry
|
||
(instead of a sponsor registry); i.e., vendors get all the convenience of a
|
||
sponsor registry, while retaining control on the asset distribution.</li>
|
||
<li><strong>private registry</strong>: such a registry is located behind a firewall,
|
||
or protected by an additional security layer (HTTP authorization,
|
||
SSL client-side certificates, IP address authorization&hellip;). The
|
||
registry is operated by a private entity, outside of Docker&rsquo;s
|
||
control. It can optionally delegate additional authorization to the
|
||
Docker Hub, but it is not mandatory.</li>
|
||
</ul>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong> The latter implies that while HTTP is the protocol
|
||
of choice for a registry, multiple schemes are possible (and
|
||
in some cases, trivial):</p>
|
||
|
||
<ul>
|
||
<li>HTTP with GET (and PUT for read-write registries);</li>
|
||
<li>local mount point;</li>
|
||
<li>remote docker addressed through SSH.</li>
|
||
</ul>
|
||
</blockquote>
|
||
|
||
<p>The latter would only require two new commands in Docker, e.g.,
|
||
<code>registryget</code> and <code>registryput</code>,
|
||
wrapping access to the local filesystem (and optionally doing
|
||
consistency checks). Authentication and authorization are then delegated
|
||
to SSH (e.g., with public keys).</p>
|
||
|
||
<h3 id="docker">Docker</h3>
|
||
|
||
<p>On top of being a runtime for LXC, Docker is the Registry client. It
|
||
supports:</p>
|
||
|
||
<ul>
|
||
<li>Push / Pull on the registry</li>
|
||
<li>Client authentication on the Docker Hub</li>
|
||
</ul>
|
||
|
||
<h2 id="workflow">Workflow</h2>
|
||
|
||
<h3 id="pull">Pull</h3>
|
||
|
||
<p><img src="http://localhost/docker/static_files/docker_pull_chart.png" alt="" />
|
||
</p>
|
||
|
||
<ol>
|
||
<li>Contact the Docker Hub to know where I should download “samalba/busybox”</li>
|
||
<li>Docker Hub replies: a. <code>samalba/busybox</code> is on Registry A b. here are the
|
||
checksums for <code>samalba/busybox</code> (for all layers) c. token</li>
|
||
<li>Contact Registry A to receive the layers for <code>samalba/busybox</code> (all of
|
||
them to the base image). Registry A is authoritative for “samalba/busybox”
|
||
but keeps a copy of all inherited layers and serve them all from the same
|
||
location.</li>
|
||
<li>registry contacts Docker Hub to verify if token/user is allowed to download images</li>
|
||
<li>Docker Hub returns true/false lettings registry know if it should proceed or error
|
||
out</li>
|
||
<li>Get the payload for all layers</li>
|
||
</ol>
|
||
|
||
<p>It&rsquo;s possible to run:</p>
|
||
|
||
<pre><code>$ docker pull https://&lt;registry&gt;/repositories/samalba/busybox
|
||
</code></pre>
|
||
|
||
<p>In this case, Docker bypasses the Docker Hub. However the security is not
|
||
guaranteed (in case Registry A is corrupted) because there won&rsquo;t be any
|
||
checksum checks.</p>
|
||
|
||
<p>Currently registry redirects to s3 urls for downloads, going forward all
|
||
downloads need to be streamed through the registry. The Registry will
|
||
then abstract the calls to S3 by a top-level class which implements
|
||
sub-classes for S3 and local storage.</p>
|
||
|
||
<p>Token is only returned when the <code>X-Docker-Token</code>
|
||
header is sent with request.</p>
|
||
|
||
<p>Basic Auth is required to pull private repos. Basic auth isn&rsquo;t required
|
||
for pulling public repos, but if one is provided, it needs to be valid
|
||
and for an active account.</p>
|
||
|
||
<p><strong>API (pulling repository foo/bar):</strong></p>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Docker Hub) GET /v1/repositories/foo/bar/images:</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
|
||
X-Docker-Token: true
|
||
</code></pre>
|
||
|
||
<p><strong>Action</strong>:</p>
|
||
|
||
<pre><code> (looking up the foo/bar in db and gets images and checksums
|
||
for that repo (all if no tag is specified, if tag, only
|
||
checksums for those tags) see part 4.4.1)
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker Hub -&gt; Docker) HTTP 200 OK</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Token
|
||
signature=123abc,repository=”foo/bar”,access=write
|
||
X-Docker-Endpoints: registry.docker.io [,registry2.docker.io]
|
||
</code></pre>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<pre><code> Jsonified checksums (see part 4.4.1)
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Registry) GET /v1/repositories/foo/bar/tags/latest</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Token
|
||
signature=123abc,repository=”foo/bar”,access=write
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Registry -&gt; Docker Hub) GET /v1/repositories/foo/bar/images</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Token
|
||
signature=123abc,repository=”foo/bar”,access=read
|
||
</code></pre>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<pre><code> &lt;ids and checksums in payload&gt;
|
||
</code></pre>
|
||
|
||
<p><strong>Action</strong>:</p>
|
||
|
||
<pre><code> (Lookup token see if they have access to pull.)
|
||
|
||
If good:
|
||
HTTP 200 OK Docker Hub will invalidate the token
|
||
|
||
If bad:
|
||
HTTP 401 Unauthorized
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Registry) GET /v1/images/928374982374/ancestry</li>
|
||
</ol>
|
||
|
||
<p><strong>Action</strong>:</p>
|
||
|
||
<pre><code> (for each image id returned in the registry, fetch /json + /layer)
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
If someone makes a second request, then we will always give a new token,
|
||
never reuse tokens.</p>
|
||
</blockquote>
|
||
|
||
<h3 id="push">Push</h3>
|
||
|
||
<p><img src="http://localhost/docker/static_files/docker_push_chart.png" alt="" />
|
||
</p>
|
||
|
||
<ol>
|
||
<li>Contact the Docker Hub to allocate the repository name “samalba/busybox”
|
||
(authentication required with user credentials)</li>
|
||
<li>If authentication works and namespace available, “samalba/busybox”
|
||
is allocated and a temporary token is returned (namespace is marked
|
||
as initialized in Docker Hub)</li>
|
||
<li>Push the image on the registry (along with the token)</li>
|
||
<li>Registry A contacts the Docker Hub to verify the token (token must
|
||
corresponds to the repository name)</li>
|
||
<li>Docker Hub validates the token. Registry A starts reading the stream
|
||
pushed by docker and store the repository (with its images)</li>
|
||
<li>docker contacts the Docker Hub to give checksums for upload images</li>
|
||
</ol>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong>
|
||
<strong>It&rsquo;s possible not to use the Docker Hub at all!</strong> In this case, a deployed
|
||
version of the Registry is deployed to store and serve images. Those
|
||
images are not authenticated and the security is not guaranteed.</p>
|
||
|
||
<p><strong>Note:</strong>
|
||
<strong>Docker Hub can be replaced!</strong> For a private Registry deployed, a custom
|
||
Docker Hub can be used to serve and validate token according to different
|
||
policies.</p>
|
||
</blockquote>
|
||
|
||
<p>Docker computes the checksums and submit them to the Docker Hub at the end of
|
||
the push. When a repository name does not have checksums on the Docker Hub,
|
||
it means that the push is in progress (since checksums are submitted at
|
||
the end).</p>
|
||
|
||
<p><strong>API (pushing repos foo/bar):</strong></p>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Docker Hub) PUT /v1/repositories/foo/bar/</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Basic sdkjfskdjfhsdkjfh== X-Docker-Token:
|
||
true
|
||
</code></pre>
|
||
|
||
<p><strong>Action</strong>:</p>
|
||
|
||
<ul>
|
||
<li>in Docker Hub, we allocated a new repository, and set to
|
||
initialized</li>
|
||
</ul>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<p>(The body contains the list of images that are going to be
|
||
pushed, with empty checksums. The checksums will be set at
|
||
the end of the push):</p>
|
||
|
||
<pre><code> [{“id”: “9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”}]
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker Hub -&gt; Docker) 200 Created</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> WWW-Authenticate: Token
|
||
signature=123abc,repository=”foo/bar”,access=write
|
||
X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Registry) PUT /v1/images/98765432_parent/json</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Token
|
||
signature=123abc,repository=”foo/bar”,access=write
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Registry-&gt;Docker Hub) GET /v1/repositories/foo/bar/images</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Token
|
||
signature=123abc,repository=”foo/bar”,access=write
|
||
</code></pre>
|
||
|
||
<p><strong>Action</strong>:</p>
|
||
|
||
<ul>
|
||
<li>Docker Hub:
|
||
will invalidate the token.</li>
|
||
|
||
<li><p>Registry:
|
||
grants a session (if token is approved) and fetches
|
||
the images id</p></li>
|
||
|
||
<li><p>(Docker -&gt; Registry) PUT /v1/images/98765432_parent/json</p></li>
|
||
</ul>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Token
|
||
signature=123abc,repository=”foo/bar”,access=write
|
||
Cookie: (Cookie provided by the Registry)
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Registry) PUT /v1/images/98765432/json</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Cookie: (Cookie provided by the Registry)
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Registry) PUT /v1/images/98765432_parent/layer</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Cookie: (Cookie provided by the Registry)
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Registry) PUT /v1/images/98765432/layer</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> X-Docker-Checksum: sha256:436745873465fdjkhdfjkgh
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Registry) PUT /v1/repositories/foo/bar/tags/latest</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Cookie: (Cookie provided by the Registry)
|
||
</code></pre>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<pre><code> “98765432”
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Docker Hub) PUT /v1/repositories/foo/bar/images</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Basic 123oislifjsldfj== X-Docker-Endpoints:
|
||
registry1.docker.io (no validation on this right now)
|
||
</code></pre>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<pre><code> (The image, id`s, tags and checksums)
|
||
[{“id”:
|
||
“9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
|
||
“checksum”:
|
||
“b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}]
|
||
</code></pre>
|
||
|
||
<p><strong>Return</strong>:</p>
|
||
|
||
<pre><code> HTTP 204
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Note:</strong> If push fails and they need to start again, what happens in the Docker Hub,
|
||
there will already be a record for the namespace/name, but it will be
|
||
initialized. Should we allow it, or mark as name already used? One edge
|
||
case could be if someone pushes the same thing at the same time with two
|
||
different shells.</p>
|
||
</blockquote>
|
||
|
||
<p>If it&rsquo;s a retry on the Registry, Docker has a cookie (provided by the
|
||
registry after token validation). So the Docker Hub won&rsquo;t have to provide a
|
||
new token.</p>
|
||
|
||
<h3 id="delete">Delete</h3>
|
||
|
||
<p>If you need to delete something from the Docker Hub or registry, we need a
|
||
nice clean way to do that. Here is the workflow.</p>
|
||
|
||
<ol>
|
||
<li>Docker contacts the Docker Hub to request a delete of a repository
|
||
<code>samalba/busybox</code> (authentication required with user credentials)</li>
|
||
<li>If authentication works and repository is valid, <code>samalba/busybox</code>
|
||
is marked as deleted and a temporary token is returned</li>
|
||
<li>Send a delete request to the registry for the repository (along with
|
||
the token)</li>
|
||
<li>Registry A contacts the Docker Hub to verify the token (token must
|
||
corresponds to the repository name)</li>
|
||
<li>Docker Hub validates the token. Registry A deletes the repository and
|
||
everything associated to it.</li>
|
||
<li>docker contacts the Docker Hub to let it know it was removed from the
|
||
registry, the Docker Hub removes all records from the database.</li>
|
||
</ol>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
The Docker client should present an &ldquo;Are you sure?&rdquo; prompt to confirm
|
||
the deletion before starting the process. Once it starts it can&rsquo;t be
|
||
undone.</p>
|
||
</blockquote>
|
||
|
||
<p><strong>API (deleting repository foo/bar):</strong></p>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Docker Hub) DELETE /v1/repositories/foo/bar/</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Basic sdkjfskdjfhsdkjfh== X-Docker-Token:
|
||
true
|
||
</code></pre>
|
||
|
||
<p><strong>Action</strong>:</p>
|
||
|
||
<ul>
|
||
<li>in Docker Hub, we make sure it is a valid repository, and set
|
||
to deleted (logically)</li>
|
||
</ul>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<pre><code> Empty
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker Hub -&gt; Docker) 202 Accepted</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> WWW-Authenticate: Token
|
||
signature=123abc,repository=”foo/bar”,access=delete
|
||
X-Docker-Endpoints: registry.docker.io [, registry2.docker.io]
|
||
# list of endpoints where this repo lives.
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Docker -&gt; Registry) DELETE /v1/repositories/foo/bar/</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Token
|
||
signature=123abc,repository=”foo/bar”,access=delete
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>(Registry-&gt;Docker Hub) PUT /v1/repositories/foo/bar/auth</li>
|
||
</ol>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Token
|
||
signature=123abc,repository=”foo/bar”,access=delete
|
||
</code></pre>
|
||
|
||
<p><strong>Action</strong>:</p>
|
||
|
||
<ul>
|
||
<li>Docker Hub:
|
||
will invalidate the token.</li>
|
||
|
||
<li><p>Registry:
|
||
deletes the repository (if token is approved)</p></li>
|
||
|
||
<li><p>(Registry -&gt; Docker) 200 OK</p>
|
||
|
||
<pre><code>200 If success 403 if forbidden 400 if bad request 404
|
||
if repository isn't found
|
||
</code></pre></li>
|
||
|
||
<li><p>(Docker -&gt; Docker Hub) DELETE /v1/repositories/foo/bar/</p></li>
|
||
</ul>
|
||
|
||
<p><strong>Headers</strong>:</p>
|
||
|
||
<pre><code> Authorization: Basic 123oislifjsldfj== X-Docker-Endpoints:
|
||
registry-1.docker.io (no validation on this right now)
|
||
</code></pre>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<pre><code> Empty
|
||
</code></pre>
|
||
|
||
<p><strong>Return</strong>:</p>
|
||
|
||
<pre><code> HTTP 200
|
||
</code></pre>
|
||
|
||
<h2 id="how-to-use-the-registry-in-standalone-mode">How to use the Registry in standalone mode</h2>
|
||
|
||
<p>The Docker Hub has two main purposes (along with its fancy social features):</p>
|
||
|
||
<ul>
|
||
<li><p>Resolve short names (to avoid passing absolute URLs all the time):</p>
|
||
|
||
<p>username/projectname -&gt;
|
||
<a href="https://registry.docker.io/users/">https://registry.docker.io/users/</a><username>/repositories/<projectname>/
|
||
team/projectname -&gt;
|
||
<a href="https://registry.docker.io/team/">https://registry.docker.io/team/</a><team>/repositories/<projectname>/</p></li>
|
||
|
||
<li><p>Authenticate a user as a repos owner (for a central referenced
|
||
repository)</p></li>
|
||
</ul>
|
||
|
||
<h3 id="without-a-docker-hub">Without a Docker Hub</h3>
|
||
|
||
<p>Using the Registry without the Docker Hub can be useful to store the images
|
||
on a private network without having to rely on an external entity
|
||
controlled by Docker Inc.</p>
|
||
|
||
<p>In this case, the registry will be launched in a special mode
|
||
(-standalone? ne? -no-index?). In this mode, the only thing which changes is
|
||
that Registry will never contact the Docker Hub to verify a token. It will be
|
||
the Registry owner responsibility to authenticate the user who pushes
|
||
(or even pulls) an image using any mechanism (HTTP auth, IP based,
|
||
etc&hellip;).</p>
|
||
|
||
<p>In this scenario, the Registry is responsible for the security in case
|
||
of data corruption since the checksums are not delivered by a trusted
|
||
entity.</p>
|
||
|
||
<p>As hinted previously, a standalone registry can also be implemented by
|
||
any HTTP server handling GET/PUT requests (or even only GET requests if
|
||
no write access is necessary).</p>
|
||
|
||
<h3 id="with-a-docker-hub">With a Docker Hub</h3>
|
||
|
||
<p>The Docker Hub data needed by the Registry are simple:</p>
|
||
|
||
<ul>
|
||
<li>Serve the checksums</li>
|
||
<li>Provide and authorize a Token</li>
|
||
</ul>
|
||
|
||
<p>In the scenario of a Registry running on a private network with the need
|
||
of centralizing and authorizing, it&rsquo;s easy to use a custom Docker Hub.</p>
|
||
|
||
<p>The only challenge will be to tell Docker to contact (and trust) this
|
||
custom Docker Hub. Docker will be configurable at some point to use a
|
||
specific Docker Hub, it&rsquo;ll be the private entity responsibility (basically
|
||
the organization who uses Docker in a private environment) to maintain
|
||
the Docker Hub and the Docker&rsquo;s configuration among its consumers.</p>
|
||
|
||
<h2 id="the-api">The API</h2>
|
||
|
||
<p>The first version of the api is available here:
|
||
<a href="https://github.com/jpetazzo/docker/blob/acd51ecea8f5d3c02b00a08176171c59442df8b3/docs/images-repositories-push-pull">https://github.com/jpetazzo/docker/blob/acd51ecea8f5d3c02b00a08176171c59442df8b3/docs/images-repositories-push-pull.md</a></p>
|
||
|
||
<h3 id="images">Images</h3>
|
||
|
||
<p>The format returned in the images is not defined here (for layer and
|
||
JSON), basically because Registry stores exactly the same kind of
|
||
information as Docker uses to manage them.</p>
|
||
|
||
<p>The format of ancestry is a line-separated list of image ids, in age
|
||
order, i.e. the image&rsquo;s parent is on the last line, the parent of the
|
||
parent on the next-to-last line, etc.; if the image has no parent, the
|
||
file is empty.</p>
|
||
|
||
<pre><code>GET /v1/images/&lt;image_id&gt;/layer
|
||
PUT /v1/images/&lt;image_id&gt;/layer
|
||
GET /v1/images/&lt;image_id&gt;/json
|
||
PUT /v1/images/&lt;image_id&gt;/json
|
||
GET /v1/images/&lt;image_id&gt;/ancestry
|
||
PUT /v1/images/&lt;image_id&gt;/ancestry
|
||
</code></pre>
|
||
|
||
<h3 id="users">Users</h3>
|
||
|
||
<h3 id="create-a-user-docker-hub">Create a user (Docker Hub)</h3>
|
||
|
||
<pre><code>POST /v1/users:
|
||
</code></pre>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<pre><code>{&quot;email&quot;: &quot;[sam@docker.com](mailto:sam%40docker.com)&quot;,
|
||
&quot;password&quot;: &quot;toto42&quot;, &quot;username&quot;: &quot;foobar&quot;`}
|
||
</code></pre>
|
||
|
||
<p><strong>Validation</strong>:</p>
|
||
|
||
<ul>
|
||
<li><strong>username</strong>: min 4 character, max 30 characters, must match the
|
||
regular expression [a-z0-9_].</li>
|
||
<li><strong>password</strong>: min 5 characters</li>
|
||
</ul>
|
||
|
||
<p><strong>Valid</strong>:</p>
|
||
|
||
<pre><code> return HTTP 201
|
||
</code></pre>
|
||
|
||
<p>Errors: HTTP 400 (we should create error codes for possible errors) -
|
||
invalid json - missing field - wrong format (username, password, email,
|
||
etc) - forbidden name - name already exists</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
A user account will be valid only if the email has been validated (a
|
||
validation link is sent to the email address).</p>
|
||
</blockquote>
|
||
|
||
<h3 id="update-a-user-docker-hub">Update a user (Docker Hub)</h3>
|
||
|
||
<pre><code>PUT /v1/users/&lt;username&gt;
|
||
</code></pre>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<pre><code>{&quot;password&quot;: &quot;toto&quot;}
|
||
</code></pre>
|
||
|
||
<blockquote>
|
||
<p><strong>Note</strong>:
|
||
We can also update email address, if they do, they will need to reverify
|
||
their new email address.</p>
|
||
</blockquote>
|
||
|
||
<h3 id="login-docker-hub">Login (Docker Hub)</h3>
|
||
|
||
<p>Does nothing else but asking for a user authentication. Can be used to
|
||
validate credentials. HTTP Basic Auth for now, maybe change in future.</p>
|
||
|
||
<p>GET /v1/users</p>
|
||
|
||
<p><strong>Return</strong>:
|
||
- Valid: HTTP 200
|
||
- Invalid login: HTTP 401
|
||
- Account inactive: HTTP 403 Account is not Active</p>
|
||
|
||
<h3 id="tags-registry">Tags (Registry)</h3>
|
||
|
||
<p>The Registry does not know anything about users. Even though
|
||
repositories are under usernames, it&rsquo;s just a namespace for the
|
||
registry. Allowing us to implement organizations or different namespaces
|
||
per user later, without modifying the Registry&rsquo;s API.</p>
|
||
|
||
<p>The following naming restrictions apply:</p>
|
||
|
||
<ul>
|
||
<li>Namespaces must match the same regular expression as usernames (See
|
||
4.2.1.)</li>
|
||
<li>Repository names must match the regular expression [a-zA-Z0-9-_.]</li>
|
||
</ul>
|
||
|
||
<h3 id="get-all-tags">Get all tags:</h3>
|
||
|
||
<pre><code>GET /v1/repositories/&lt;namespace&gt;/&lt;repository_name&gt;/tags
|
||
|
||
**Return**: HTTP 200
|
||
[
|
||
{
|
||
&quot;layer&quot;: &quot;9e89cc6f&quot;,
|
||
&quot;name&quot;: &quot;latest&quot;
|
||
},
|
||
{
|
||
&quot;layer&quot;: &quot;b486531f&quot;,
|
||
&quot;name&quot;: &quot;0.1.1&quot;,
|
||
}
|
||
]
|
||
</code></pre>
|
||
|
||
<p><strong>4.3.2 Read the content of a tag (resolve the image id):</strong></p>
|
||
|
||
<pre><code>GET /v1/repositories/&lt;namespace&gt;/&lt;repo_name&gt;/tags/&lt;tag&gt;
|
||
</code></pre>
|
||
|
||
<p><strong>Return</strong>:</p>
|
||
|
||
<pre><code>&quot;9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f&quot;
|
||
</code></pre>
|
||
|
||
<p><strong>4.3.3 Delete a tag (registry):</strong></p>
|
||
|
||
<pre><code>DELETE /v1/repositories/&lt;namespace&gt;/&lt;repo_name&gt;/tags/&lt;tag&gt;
|
||
</code></pre>
|
||
|
||
<h3 id="4-4-images-docker-hub">4.4 Images (Docker Hub)</h3>
|
||
|
||
<p>For the Docker Hub to “resolve” the repository name to a Registry location,
|
||
it uses the X-Docker-Endpoints header. In other terms, this requests
|
||
always add a <code>X-Docker-Endpoints</code> to indicate the
|
||
location of the registry which hosts this repository.</p>
|
||
|
||
<p><strong>4.4.1 Get the images:</strong></p>
|
||
|
||
<pre><code>GET /v1/repositories/&lt;namespace&gt;/&lt;repo_name&gt;/images
|
||
|
||
**Return**: HTTP 200
|
||
[{“id”:
|
||
“9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
|
||
“checksum”:
|
||
“[md5:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087](md5:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087)”}]
|
||
</code></pre>
|
||
|
||
<h3 id="add-update-the-images">Add/update the images:</h3>
|
||
|
||
<p>You always add images, you never remove them.</p>
|
||
|
||
<pre><code>PUT /v1/repositories/&lt;namespace&gt;/&lt;repo_name&gt;/images
|
||
</code></pre>
|
||
|
||
<p><strong>Body</strong>:</p>
|
||
|
||
<pre><code>[ {“id”:
|
||
“9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f”,
|
||
“checksum”:
|
||
“sha256:b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087”}
|
||
]
|
||
</code></pre>
|
||
|
||
<p><strong>Return</strong>:</p>
|
||
|
||
<pre><code>204
|
||
</code></pre>
|
||
|
||
<h3 id="repositories">Repositories</h3>
|
||
|
||
<h3 id="remove-a-repository-registry">Remove a Repository (Registry)</h3>
|
||
|
||
<p>DELETE /v1/repositories/<namespace>/<repo_name></p>
|
||
|
||
<p>Return 200 OK</p>
|
||
|
||
<h3 id="remove-a-repository-docker-hub">Remove a Repository (Docker Hub)</h3>
|
||
|
||
<p>This starts the delete process. see 2.3 for more details.</p>
|
||
|
||
<p>DELETE /v1/repositories/<namespace>/<repo_name></p>
|
||
|
||
<p>Return 202 OK</p>
|
||
|
||
<h2 id="chaining-registries">Chaining Registries</h2>
|
||
|
||
<p>It&rsquo;s possible to chain Registries server for several reasons:</p>
|
||
|
||
<ul>
|
||
<li>Load balancing</li>
|
||
<li>Delegate the next request to another server</li>
|
||
</ul>
|
||
|
||
<p>When a Registry is a reference for a repository, it should host the
|
||
entire images chain in order to avoid breaking the chain during the
|
||
download.</p>
|
||
|
||
<p>The Docker Hub and Registry use this mechanism to redirect on one or the
|
||
other.</p>
|
||
|
||
<p>Example with an image download:</p>
|
||
|
||
<p>On every request, a special header can be returned:</p>
|
||
|
||
<pre><code>X-Docker-Endpoints: server1,server2
|
||
</code></pre>
|
||
|
||
<p>On the next request, the client will always pick a server from this
|
||
list.</p>
|
||
|
||
<h2 id="authentication-and-authorization">Authentication and authorization</h2>
|
||
|
||
<h3 id="on-the-docker-hub">On the Docker Hub</h3>
|
||
|
||
<p>The Docker Hub supports both “Basic” and “Token” challenges. Usually when
|
||
there is a <code>401 Unauthorized</code>, the Docker Hub replies
|
||
this:</p>
|
||
|
||
<pre><code>401 Unauthorized
|
||
WWW-Authenticate: Basic realm=&quot;auth required&quot;,Token
|
||
</code></pre>
|
||
|
||
<p>You have 3 options:</p>
|
||
|
||
<ol>
|
||
<li>Provide user credentials and ask for a token</li>
|
||
</ol>
|
||
|
||
<p><strong>Header</strong>:</p>
|
||
|
||
<pre><code> Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
|
||
X-Docker-Token: true
|
||
</code></pre>
|
||
|
||
<p>In this case, along with the 200 response, you&rsquo;ll get a new token
|
||
(if user auth is ok): If authorization isn&rsquo;t correct you get a 401
|
||
response. If account isn&rsquo;t active you will get a 403 response.</p>
|
||
|
||
<p><strong>Response</strong>:</p>
|
||
|
||
<pre><code> 200 OK
|
||
X-Docker-Token: Token
|
||
signature=123abc,repository=”foo/bar”,access=read
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>Provide user credentials only</li>
|
||
</ol>
|
||
|
||
<p><strong>Header</strong>:</p>
|
||
|
||
<pre><code> Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
|
||
</code></pre>
|
||
|
||
<ol>
|
||
<li>Provide Token</li>
|
||
</ol>
|
||
|
||
<p><strong>Header</strong>:</p>
|
||
|
||
<pre><code> Authorization: Token
|
||
signature=123abc,repository=”foo/bar”,access=read
|
||
</code></pre>
|
||
|
||
<h3 id="6-2-on-the-registry">6.2 On the Registry</h3>
|
||
|
||
<p>The Registry only supports the Token challenge:</p>
|
||
|
||
<pre><code>401 Unauthorized
|
||
WWW-Authenticate: Token
|
||
</code></pre>
|
||
|
||
<p>The only way is to provide a token on <code>401 Unauthorized</code>
|
||
responses:</p>
|
||
|
||
<pre><code>Authorization: Token signature=123abc,repository=&quot;foo/bar&quot;,access=read
|
||
</code></pre>
|
||
|
||
<p>Usually, the Registry provides a Cookie when a Token verification
|
||
succeeded. Every time the Registry passes a Cookie, you have to pass it
|
||
back the same cookie.:</p>
|
||
|
||
<pre><code>200 OK
|
||
Set-Cookie: session=&quot;wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&amp;timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4=&quot;; Path=/; HttpOnly
|
||
</code></pre>
|
||
|
||
<p>Next request:</p>
|
||
|
||
<pre><code>GET /(...)
|
||
Cookie: session=&quot;wD/J7LqL5ctqw8haL10vgfhrb2Q=?foo=UydiYXInCnAxCi4=&amp;timestamp=RjEzNjYzMTQ5NDcuNDc0NjQzCi4=&quot;
|
||
</code></pre>
|
||
|
||
<h2 id="document-version">Document version</h2>
|
||
|
||
<ul>
|
||
<li>1.0 : May 6th 2013 : initial release</li>
|
||
<li>1.1 : June 1st 2013 : Added Delete Repository and way to handle new
|
||
source namespace.</li>
|
||
</ul>
|
||
</description>
|
||
</item>
|
||
|
||
</channel>
|
||
</rss> |