# Docker Image Specification v1.2.0 An *Image* is an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime. This specification outlines the format of these filesystem changes and corresponding parameters and describes how to create and use them for use with a container runtime and execution tool. This version of the image specification was adopted starting in Docker 1.12. ## Terminology This specification uses the following terms:
sha256:a9561eb1b190625c9adb5a9513e72c4dedafc1cb2d4c5236c9a6957ec7dfd5a9
.
Layers must be packed and unpacked reproducibly to avoid changing the
layer ID, for example by using tar-split to save the tar headers. Note
that the digest used as the layer ID is taken over an uncompressed
version of the tar.
ChainID
. For a
single layer (or the layer at the bottom of a stack), the
ChainID
is equal to the layer's DiffID
.
Otherwise the ChainID
is given by the formula:
ChainID(layerN) = SHA256hex(ChainID(layerN-1) + " " + DiffID(layerN))
.
sha256:a9561eb1b190625c9adb5a9513e72c4dedafc1cb2d4c5236c9a6957ec7dfd5a9
.
Since the configuration JSON that gets hashed references hashes of each
layer in the image, this formulation of the ImageID makes images
content-addressable.
[a-zA-Z0-9_.-]
, except they may not start with a .
or -
character. Tags are limited to 128 characters.
:
). For example, in an image tagged with the name
my-app:3.1.4
, my-app
is the Repository
component of the name. A repository name is made up of slash-separated
name components, optionally prefixed by a DNS hostname. The hostname
must comply with standard DNS rules, but may not contain
_
characters. If a hostname is present, it may optionally
be followed by a port number in the format :8080
.
Name components may contain lowercase characters, digits, and
separators. A separator is defined as a period, one or two underscores,
or one or more dashes. A name component may not start or end with
a separator.
string
string
string
string
struct
null
, in
which case any execution parameters should be specified at creation of
the container.
string
The username or UID which the process in the container should run as. This acts as a default value to use when the value is not specified when creating a container.
All of the following are valid:
user
uid
user:group
uid:gid
uid:group
user:gid
If group
/gid
is not specified, the
default group and supplementary groups of the given
user
/uid
in /etc/passwd
from the container are applied.
integer
integer
-1
to
disable swap. This acts as a default value to use when the
value is not specified when creating a container.
integer
struct
map[string]struct{}
and is represented in JSON as
an object mapping its keys to an empty object. Here is an
example:
{ "8080": {}, "53/udp": {}, "2356/tcp": {} }Its keys can be in the format of:
"port/tcp"
"port/udp"
"port"
"tcp"
if not
specified.
These values act as defaults and are merged with any specified
when creating a container.
array of strings
VARNAME="var value"
.
These values act as defaults and are merged with any specified
when creating a container.
array of strings
array of strings
Entrypoint
value is
not specified, then the first entry of the Cmd
array should be interpreted as the executable to run.
struct
{ "Test": [ "CMD-SHELL", "/usr/bin/check-health localhost" ], "Interval": 30000000000, "Timeout": 10000000000, "Retries": 3 }The object has the following fields.
array of strings
[]
: inherit healthcheck from base image["NONE"]
: disable healthcheck["CMD", arg1, arg2, ...]
: exec arguments directly["CMD-SHELL", command]
: run command with system's default shellinteger
integer
integer
struct
map[string]struct{}
and is represented in
JSON as an object mapping its keys to an empty object. Here is
an example:
{ "/var/my-app-data/": {}, "/etc/some-config.d/": {}, }
string
struct
type
is usually set to layers
.
diff_ids
is an array of layer content hashes (DiffIDs
), in order from bottom-most to top-most.
"rootfs": { "diff_ids": [ "sha256:c6f988f4874bb0add23a778f753c65efe992244e148a1d2ec2a8b664fb66bbd1", "sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef", "sha256:13f53e08df5a220ab6d13c58b2bf83a59cbdc2e04d0a3f041ddf4b0ba4112d49" ], "type": "layers" }
struct
history
is an array of objects describing the history of
each layer. The array is ordered from bottom-most layer to top-most
layer. The object has the following fields.
created
: Creation time, expressed as a ISO-8601 formatted
combined date and time
author
: The author of the build point
created_by
: The command which created the layer
comment
: A custom message set when creating the layer
empty_layer
: This field is used to mark if the history
item created a filesystem diff. It is set to true if this history
item doesn't correspond to an actual layer in the rootfs section
(for example, a command like ENV which results in no change to the
filesystem).
"history": [ { "created": "2015-10-31T22:22:54.690851953Z", "created_by": "/bin/sh -c #(nop) ADD file:a3bc1e842b69636f9df5256c49c5374fb4eef1e281fe3f282c65fb853ee171c5 in /" }, { "created": "2015-10-31T22:22:55.613815829Z", "created_by": "/bin/sh -c #(nop) CMD [\"sh\"]", "empty_layer": true } ]