Create a new image from a container Run in API Explorer

POST /commit

Query parameters

  • container string

    The ID or name of the container to commit

  • repo string

    Repository name for the created image

  • tag string

    Tag name for the create image

  • comment string

    Commit message

  • author string

    Author of the image (e.g., John Hannibal Smith <hannibal@a-team.com>)

  • pause boolean

    Whether to pause the container before committing

    Default value is true.

  • changes string

    Dockerfile instructions to apply while committing

application/json

Body

The container configuration

  • Hostname string

    The hostname to use for the container, as a valid RFC 1123 hostname.

  • Domainname string

    The domain name to use for the container.

  • User string

    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>]).

  • AttachStdin boolean

    Whether to attach to stdin.

    Default value is false.

  • AttachStdout boolean

    Whether to attach to stdout.

    Default value is true.

  • AttachStderr boolean

    Whether to attach to stderr.

    Default value is true.

  • ExposedPorts object

    An object mapping ports to an empty object in the form:

    {"<port>/<tcp|udp|sctp>": {}}

    Hide ExposedPorts attribute Show ExposedPorts attribute object
    • * object Additional properties

      Default value is {} (empty).

  • Tty boolean

    Attach standard streams to a TTY, including stdin if it is not closed.

    Default value is false.

  • OpenStdin boolean

    Open stdin

    Default value is false.

  • StdinOnce boolean

    Close stdin after one attached client disconnects

    Default value is false.

  • Env array[string]

    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.

  • Cmd array[string]

    Command to run specified as a string or an array of strings.

  • Healthcheck object

    A test to perform to check that the container is healthy.

    Hide Healthcheck attributes Show Healthcheck attributes object
    • Test array[string]

      The test to perform. Possible values are:

      • [] inherit healthcheck from image or parent image
      • ["NONE"] disable healthcheck
      • ["CMD", args...] exec arguments directly
      • ["CMD-SHELL", command] run command with system's default shell
    • Interval integer(int64)

      The time to wait between checks in nanoseconds. It should be 0 or at least 1000000 (1 ms). 0 means inherit.

    • Timeout integer(int64)

      The time to wait before considering the check to have hung. It should be 0 or at least 1000000 (1 ms). 0 means inherit.

    • Retries integer

      The number of consecutive failures needed to consider a container as unhealthy. 0 means inherit.

    • StartPeriod integer(int64)

      Start period for the container to initialize before starting health-retries countdown in nanoseconds. It should be 0 or at least 1000000 (1 ms). 0 means inherit.

    • StartInterval integer(int64)

      The time to wait between checks in nanoseconds during the start period. It should be 0 or at least 1000000 (1 ms). 0 means inherit.

  • ArgsEscaped boolean

    Command is already escaped (Windows only)

    Default value is false.

  • Image string

    The name (or reference) of the image to use when creating the container, or which was used when the container was created.

  • Volumes object

    An object mapping mount point paths inside the container to empty objects.

    Hide Volumes attribute Show Volumes attribute object
    • * object Additional properties

      Default value is {} (empty).

  • WorkingDir string

    The working directory for commands to run in.

  • Entrypoint array[string]

    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 no ENTRYPOINT instruction in the Dockerfile).

  • NetworkDisabled boolean

    Disable networking for the container.

  • MacAddress string

    MAC address of the container.

    Deprecated: this field is deprecated in API v1.44 and up. Use EndpointSettings.MacAddress instead.

  • OnBuild array[string]

    ONBUILD metadata that were defined in the image's Dockerfile.

  • Labels object

    User-defined key/value metadata.

    Hide Labels attribute Show Labels attribute object
    • * string Additional properties
  • StopSignal string

    Signal to stop a container as a string or unsigned integer.

  • StopTimeout integer

    Timeout to stop a container in seconds.

    Default value is 10.

  • Shell array[string]

    Shell for when RUN, CMD, and ENTRYPOINT uses a shell.

Responses

  • 201 application/json

    no error

    Hide response attribute Show response attribute object
    • Id string Required

      The id of the newly created object.

  • 404 application/json

    no such container

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

  • 500 application/json

    server error

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

POST /commit
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"]}'
Request examples
{
  "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"
  ]
}
Response examples (201)
{
  "Id": "string"
}
Response examples (404)
{
  "message": "No such container: c2ada9df5af8"
}
Response examples (404)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}