Create a new image from a container Run in API Explorer
Query parameters
-
The ID or name of the container to commit
-
Repository name for the created image
-
Tag name for the create image
-
Commit message
-
Whether to pause the container before committing
Default value is
true
. -
Dockerfile
instructions to apply while committing
Body
The container configuration
-
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.
curl \
--request POST 'http://api.example.com/v1.49/commit' \
--header "Content-Type: application/json" \
--data '{"Hostname":"439f4e91bd1d","Domainname":"string","User":"123:456","AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"ExposedPorts":{"80/tcp":{},"443/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"],"Healthcheck":{"Test":["string"],"Interval":42,"Timeout":42,"Retries":42,"StartPeriod":42,"StartInterval":42},"ArgsEscaped":false,"Image":"example-image:1.0","Volumes":{"additionalProperty1":{},"additionalProperty2":{}},"WorkingDir":"/public/","Entrypoint":["string"],"NetworkDisabled":true,"MacAddress":"string","OnBuild":["string"],"Labels":{"com.example.some-label":"some-value","com.example.some-other-label":"some-other-value"},"StopSignal":"SIGTERM","StopTimeout":10,"Shell":["/bin/sh","-c"]}'
{
"Hostname": "439f4e91bd1d",
"Domainname": "string",
"User": "123:456",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"80/tcp": {},
"443/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh"
],
"Healthcheck": {
"Test": [
"string"
],
"Interval": 42,
"Timeout": 42,
"Retries": 42,
"StartPeriod": 42,
"StartInterval": 42
},
"ArgsEscaped": false,
"Image": "example-image:1.0",
"Volumes": {
"additionalProperty1": {},
"additionalProperty2": {}
},
"WorkingDir": "/public/",
"Entrypoint": [
"string"
],
"NetworkDisabled": true,
"MacAddress": "string",
"OnBuild": [
"string"
],
"Labels": {
"com.example.some-label": "some-value",
"com.example.some-other-label": "some-other-value"
},
"StopSignal": "SIGTERM",
"StopTimeout": 10,
"Shell": [
"/bin/sh",
"-c"
]
}
{
"Id": "string"
}
{
"message": "No such container: c2ada9df5af8"
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}
{
"message": "Something went wrong."
}