Create a container
POST /containers/create
Create a container
Example request:
Example response:
Json Parameters:
Hostname - A string value containing the hostname to use for the container.
IGNORED
Domainname - A string value containing the domain name to use for the container.IGNORED
User - A string value specifying the user inside the container.IGNORED
Memory - Memory limit in bytes.IGNORED
MemorySwap - Total memory limit (memory + swap); set-1
to disable swapYou must use this with
memory
and make the swap value larger thanmemory
.IGNORED
MemoryReservation - Memory soft limit in bytes.IGNORED
KernelMemory - Kernel memory limit in bytes.IGNORED
CpuShares - An integer value containing the container's CPU Shares(ie. the relative weight vs other containers).
IGNORED
CpuPeriod - The length of a CPU period in microseconds.IGNORED
CpuQuota - Microseconds of CPU time that the container can get in a CPU period.IGNORED
Cpuset - Deprecated please don't use. UseCpusetCpus
instead.IGNORED
CpusetCpus - String value containing thecgroups CpusetCpus
to use.IGNORED
CpusetMems - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.IGNORED
BlkioWeight - Block IO weight (relative weight) accepts a weight value between 10 and 1000.IGNORED
BlkioWeightDevice - Block IO weight (relative device weight) in the form of:"BlkioWeightDevice": [{"Path": "device_path", "Weight": weight}]
IGNORED
BlkioDeviceReadBps - Limit read rate (bytes per second) from a device in the form of:"BlkioDeviceReadBps": [{"Path": "device_path", "Rate": rate}]
, for example:"BlkioDeviceReadBps": [{"Path": "/dev/sda", "Rate": "1024"}]"
IGNORED
BlkioDeviceWriteBps - Limit write rate (bytes per second) to a device in the form of:"BlkioDeviceWriteBps": [{"Path": "device_path", "Rate": rate}]
, for example:"BlkioDeviceWriteBps": [{"Path": "/dev/sda", "Rate": "1024"}]"
IGNORED
BlkioDeviceReadIOps - Limit read rate (IO per second) from a device in the form of:"BlkioDeviceReadIOps": [{"Path": "device_path", "Rate": rate}]
, for example:"BlkioDeviceReadIOps": [{"Path": "/dev/sda", "Rate": "1000"}]
IGNORED
BlkioDeviceWiiteIOps - Limit write rate (IO per second) to a device in the form of:"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]
, for example:"BlkioDeviceWriteIOps": [{"Path": "/dev/sda", "Rate": "1000"}]
IGNORED
MemorySwappiness - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.IGNORED
OomKillDisable - Boolean value, whether to disable OOM Killer for the container or not.IGNORED
OomScoreAdj - An integer value containing the score given to the container in order to tune OOM killer preferences.AttachStdin - Boolean value, attaches to
stdin
.AttachStdout - Boolean value, attaches to
stdout
.AttachStderr - Boolean value, attaches to
stderr
.Tty - Boolean value, Attach standard streams to a
tty
, includingstdin
if it is not closed.OpenStdin - Boolean value, opens stdin,
StdinOnce - Boolean value, close
stdin
after the 1 attached client disconnects.Env - A list of environment variables in the form of
["VAR=value"[,"VAR2=value2"]]
Labels - Adds a map of labels to a container. To specify a map:
{"key":"value"[,"key2":"value2"]}
Cmd - Command to run specified as a string or an array of strings.
Entrypoint - Set the entry point for the container as a string or an array
of strings.
Image - A string specifying the image name to use for the container.
Mounts - An array of mount points in the container.
WorkingDir - A string specifying the working directory for commands to
run in.
IGNORED
NetworkDisabled - Boolean value, when true disables networking for thecontainer
ExposedPorts - An object mapping ports to an empty object in the form of:
"ExposedPorts": { "<port>/<tcp|udp>: {}" }
IGNORED
StopSignal - Signal to stop a container as a string or unsigned integer.SIGTERM
by default.HostConfig
Binds – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
container_path
to create a new volume for the containerhost_path:container_path
to bind-mount a host path into the containerhost_path:container_path:ro
to make the bind-mount read-only inside the container.volume_name:container_path
to bind-mount a volume managed by a volume plugin into the container.volume_name:container_path:ro
to make the bind mount read-only inside the container.
Links - A list of links for the container. Each link entry should be
in the form of
container_name:alias
.PortBindings - A map of exposed container ports and the host port they
should map to. A JSON object in the form
{ <port>/<protocol>: [{ "HostPort": "<port>" }] }
Take note that
port
is specified as a string and not an integer value.PublishAllPorts - Allocates a random host port for all of a container's
exposed ports. Specified as a boolean value.
IGNORED
Privileged - Gives the container full access to the host. Specified asa boolean value.
ReadonlyRootfs - Mount the container's root filesystem as read only.
Specified as a boolean value.
IGNORED
Dns - A list of DNS servers for the container to use.IGNORED
DnsOptions - A list of DNS optionsIGNORED
DnsSearch - A list of DNS search domainsIGNORED
ExtraHosts - A list of hostnames/IP mappings to add to thecontainer's
/etc/hosts
file. Specified in the form["hostname:IP"]
.VolumesFrom - A list of volumes to inherit from another container.
Specified in the form
<container name>[:<ro|rw>]
IGNORED
CapAdd - A list of kernel capabilities to add to the container.IGNORED
Capdrop - A list of kernel capabilities to drop from the container.IGNORED
GroupAdd - A list of additional groups that the container process will run asRestartPolicy – The behavior to apply when the container exits. The
NetworkMode - Sets the networking mode for the container. Supported
values are:
bridge
,host
, andcontainer:<name|id>
IGNORED
Devices - A list of devices to add to the container specified as a JSON object in theform
{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}
IGNORED
Ulimits - A list of ulimits to set in the container, specified as{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }
, for example:Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }
IGNORED
SecurityOpt: A list of string values to customize labels for MLSsystems, such as SELinux.
LogConfig - Log configuration for the container, specified as a JSON object in the form
{ "Type": "<driver_name>", "Config": {"key1": "val1"}}
.Available types:
json-file
,syslog
,journald
,gelf
,awslogs
,splunk
,none
.json-file
logging driver.IGNORED
CgroupParent - Path tocgroups
under which the container'scgroup
is created. If the path is not absolute, the path is considered to be relative to thecgroups
path of the init process. Cgroups are created if they do not already exist.VolumeDriver - Driver that this container users to mount volumes.
IGNORED
ShmSize - Size of/dev/shm
in bytes. The size must be greater than 0. If omitted the system uses 64MB.
Query Parameters:
name – Assign the specified name to the container. Must
match
/?[a-zA-Z0-9_-]+
.
Status Codes:
201 – no error
404 – no such container
406 – impossible to attach (container not running)
500 – server error
Last updated