Create a container Run in API Explorer
Query parameters
-
Assign the specified name to the container. Must match
/?[a-zA-Z0-9][a-zA-Z0-9_.-]+
. -
Platform in the format
os[/arch[/variant]]
used for image lookup.When specified, the daemon checks if the requested image is present in the local image cache with the given OS and Architecture, and otherwise returns a
404
status.If the option is not set, the host's native OS and Architecture are used to look up the image in the image cache. However, if no platform is passed and the given image does exist in the local image cache, but its OS or architecture does not match, the container is created with the available image, and a warning is added to the
Warnings
field in the response, for example;WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
Default value is empty.
Body
Required
Container to create
-
The hostname to use for the container, as a valid RFC 1123 hostname.
-
The domain name to use for the container.
-
Commands run as this user inside the container. If omitted, commands run as the user specified in the image the container was started from.
Can be either user-name or UID, and optional group-name or GID, separated by a colon (
<user-name|UID>[<:group-name|GID>]
). -
Whether to attach to
stdin
.Default value is
false
. -
Whether to attach to
stdout
.Default value is
true
. -
Whether to attach to
stderr
.Default value is
true
. -
An object mapping ports to an empty object in the form:
{"<port>/<tcp|udp|sctp>": {}}
-
Attach standard streams to a TTY, including
stdin
if it is not closed.Default value is
false
. -
Open
stdin
Default value is
false
. -
Close
stdin
after one attached client disconnectsDefault value is
false
. -
A list of environment variables to set inside the container in the form
["VAR=value", ...]
. A variable without=
is removed from the environment, rather than to have an empty value. -
Command to run specified as a string or an array of strings.
-
A test to perform to check that the container is healthy.
-
Command is already escaped (Windows only)
Default value is
false
. -
The name (or reference) of the image to use when creating the container, or which was used when the container was created.
-
An object mapping mount point paths inside the container to empty objects.
-
The working directory for commands to run in.
-
The entry point for the container as a string or an array of strings.
If the array consists of exactly one empty string (
[""]
) then the entry point is reset to system default (i.e., the entry point used by docker when there is noENTRYPOINT
instruction in theDockerfile
). -
Disable networking for the container.
-
MAC address of the container.
Deprecated: this field is deprecated in API v1.44 and up. Use EndpointSettings.MacAddress instead.
-
ONBUILD
metadata that were defined in the image'sDockerfile
. -
User-defined key/value metadata.
-
Signal to stop a container as a string or unsigned integer.
-
Timeout to stop a container in seconds.
Default value is
10
. -
Shell for when
RUN
,CMD
, andENTRYPOINT
uses a shell. -
Container configuration that depends on the host we are running on
-
NetworkingConfig represents the container's networking configuration for each of its interfaces. It is used for the networking configs specified in the
docker create
anddocker network connect
commands.
Body
Required
Container to create
-
The hostname to use for the container, as a valid RFC 1123 hostname.
-
The domain name to use for the container.
-
Commands run as this user inside the container. If omitted, commands run as the user specified in the image the container was started from.
Can be either user-name or UID, and optional group-name or GID, separated by a colon (
<user-name|UID>[<:group-name|GID>]
). -
Whether to attach to
stdin
.Default value is
false
. -
Whether to attach to
stdout
.Default value is
true
. -
Whether to attach to
stderr
.Default value is
true
. -
An object mapping ports to an empty object in the form:
{"<port>/<tcp|udp|sctp>": {}}
-
Attach standard streams to a TTY, including
stdin
if it is not closed.Default value is
false
. -
Open
stdin
Default value is
false
. -
Close
stdin
after one attached client disconnectsDefault value is
false
. -
A list of environment variables to set inside the container in the form
["VAR=value", ...]
. A variable without=
is removed from the environment, rather than to have an empty value. -
Command to run specified as a string or an array of strings.
-
A test to perform to check that the container is healthy.
-
Command is already escaped (Windows only)
Default value is
false
. -
The name (or reference) of the image to use when creating the container, or which was used when the container was created.
-
An object mapping mount point paths inside the container to empty objects.
-
The working directory for commands to run in.
-
The entry point for the container as a string or an array of strings.
If the array consists of exactly one empty string (
[""]
) then the entry point is reset to system default (i.e., the entry point used by docker when there is noENTRYPOINT
instruction in theDockerfile
). -
Disable networking for the container.
-
MAC address of the container.
Deprecated: this field is deprecated in API v1.44 and up. Use EndpointSettings.MacAddress instead.
-
ONBUILD
metadata that were defined in the image'sDockerfile
. -
User-defined key/value metadata.
-
Signal to stop a container as a string or unsigned integer.
-
Timeout to stop a container in seconds.
Default value is
10
. -
Shell for when
RUN
,CMD
, andENTRYPOINT
uses a shell. -
Container configuration that depends on the host we are running on
-
NetworkingConfig represents the container's networking configuration for each of its interfaces. It is used for the networking configs specified in the
docker create
anddocker network connect
commands.
curl \
--request POST 'http://api.example.com/v1.49/containers/create' \
--header "Content-Type: application/json" \
--data '{"Cmd":["date"],"Env":["FOO=bar","BAZ=quux"],"Tty":false,"User":"","Image":"ubuntu","Labels":{"com.example.vendor":"Acme","com.example.license":"GPL","com.example.version":"1.0"},"Volumes":{"/volumes/data":{}},"Hostname":"","OpenStdin":false,"StdinOnce":false,"Domainname":"","Entrypoint":"","HostConfig":{"Dns":["8.8.8.8"],"Binds":["/tmp:/tmp"],"Links":["redis3:redis"],"CapAdd":["NET_ADMIN"],"Memory":0,"CapDrop":["MKNOD"],"Devices":[],"PidMode":"","ShmSize":67108864,"Ulimits":[{}],"CpuQuota":50000,"GroupAdd":["newgroup"],"NanoCpus":500000,"CpuPeriod":100000,"CpuShares":512,"DnsSearch":[""],"LogConfig":{"Type":"json-file","Config":{}},"PidsLimit":0,"AutoRemove":true,"CpuPercent":80,"CpusetCpus":"0,1","CpusetMems":"0,1","DnsOptions":[""],"MemorySwap":0,"Privileged":false,"StorageOpt":{},"BlkioWeight":300,"MaximumIOps":0,"NetworkMode":"bridge","OomScoreAdj":500,"SecurityOpt":[],"VolumesFrom":["parent","other:ro"],"CgroupParent":"","MaximumIOBps":0,"PortBindings":{"22/tcp":[{"HostPort":"11022"}]},"VolumeDriver":"","RestartPolicy":{"Name":"","MaximumRetryCount":0},"DeviceRequests":[{"Count":-1,"Driver":"nvidia","Options":{"property1":"string","property2":"string"},"DeviceIDs\"":["0","1","GPU-fef8089b-4820-abfc-e83e-94318197576e"],"Capabilities":[["gpu","nvidia","compute"]]}],"OomKillDisable":false,"ReadonlyRootfs":false,"PublishAllPorts":false,"MemorySwappiness":60,"BlkioWeightDevice":[{}],"CpuRealtimePeriod":1000000,"MemoryReservation":0,"BlkioDeviceReadBps":[{}],"CpuRealtimeRuntime":10000,"BlkioDeviceReadIOps":[{}],"BlkioDeviceWriteBps":[{}],"BlkioDeviceWriteIOps":[{}]},"MacAddress":"12:34:56:78:9a:bc","StopSignal":"SIGTERM","WorkingDir":"","AttachStdin":false,"StopTimeout":10,"AttachStderr":true,"AttachStdout":true,"ExposedPorts":{"22/tcp":{}},"NetworkDisabled":false,"NetworkingConfig":{"EndpointsConfig":{"database_nw":{},"isolated_nw":{"Links":["container_1","container_2"],"Aliases":["server_x","server_y"],"IPAMConfig":{"IPv4Address":"172.20.30.33","IPv6Address":"2001:db8:abcd::3033","LinkLocalIPs":["169.254.34.68","fe80::3468"]}}}}}'
curl \
--request POST 'http://api.example.com/v1.49/containers/create' \
--header "Content-Type: application/octet-stream"
{
"Cmd": [
"date"
],
"Env": [
"FOO=bar",
"BAZ=quux"
],
"Tty": false,
"User": "",
"Image": "ubuntu",
"Labels": {
"com.example.vendor": "Acme",
"com.example.license": "GPL",
"com.example.version": "1.0"
},
"Volumes": {
"/volumes/data": {}
},
"Hostname": "",
"OpenStdin": false,
"StdinOnce": false,
"Domainname": "",
"Entrypoint": "",
"HostConfig": {
"Dns": [
"8.8.8.8"
],
"Binds": [
"/tmp:/tmp"
],
"Links": [
"redis3:redis"
],
"CapAdd": [
"NET_ADMIN"
],
"Memory": 0,
"CapDrop": [
"MKNOD"
],
"Devices": [],
"PidMode": "",
"ShmSize": 67108864,
"Ulimits": [
{}
],
"CpuQuota": 50000,
"GroupAdd": [
"newgroup"
],
"NanoCpus": 500000,
"CpuPeriod": 100000,
"CpuShares": 512,
"DnsSearch": [
""
],
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"PidsLimit": 0,
"AutoRemove": true,
"CpuPercent": 80,
"CpusetCpus": "0,1",
"CpusetMems": "0,1",
"DnsOptions": [
""
],
"MemorySwap": 0,
"Privileged": false,
"StorageOpt": {},
"BlkioWeight": 300,
"MaximumIOps": 0,
"NetworkMode": "bridge",
"OomScoreAdj": 500,
"SecurityOpt": [],
"VolumesFrom": [
"parent",
"other:ro"
],
"CgroupParent": "",
"MaximumIOBps": 0,
"PortBindings": {
"22/tcp": [
{
"HostPort": "11022"
}
]
},
"VolumeDriver": "",
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"DeviceRequests": [
{
"Count": -1,
"Driver": "nvidia",
"Options": {
"property1": "string",
"property2": "string"
},
"DeviceIDs\"": [
"0",
"1",
"GPU-fef8089b-4820-abfc-e83e-94318197576e"
],
"Capabilities": [
[
"gpu",
"nvidia",
"compute"
]
]
}
],
"OomKillDisable": false,
"ReadonlyRootfs": false,
"PublishAllPorts": false,
"MemorySwappiness": 60,
"BlkioWeightDevice": [
{}
],
"CpuRealtimePeriod": 1000000,
"MemoryReservation": 0,
"BlkioDeviceReadBps": [
{}
],
"CpuRealtimeRuntime": 10000,
"BlkioDeviceReadIOps": [
{}
],
"BlkioDeviceWriteBps": [
{}
],
"BlkioDeviceWriteIOps": [
{}
]
},
"MacAddress": "12:34:56:78:9a:bc",
"StopSignal": "SIGTERM",
"WorkingDir": "",
"AttachStdin": false,
"StopTimeout": 10,
"AttachStderr": true,
"AttachStdout": true,
"ExposedPorts": {
"22/tcp": {}
},
"NetworkDisabled": false,
"NetworkingConfig": {
"EndpointsConfig": {
"database_nw": {},
"isolated_nw": {
"Links": [
"container_1",
"container_2"
],
"Aliases": [
"server_x",
"server_y"
],
"IPAMConfig": {
"IPv4Address": "172.20.30.33",
"IPv6Address": "2001:db8:abcd::3033",
"LinkLocalIPs": [
"169.254.34.68",
"fe80::3468"
]
}
}
}
}
}
{
"Id": "ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743",
"Warnings": [
"string"
]
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "No such image: c2ada9df5af8"
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}