Image

Create a new image from a container

Changed on
post/commit

Request

  • Base URL
    /v1.57 (relative, and the document was published on a file host, not at the API’s origin)
  • Auth
    none declared

Query parameters

containerstring

The ID or name of the container to commit

repostring

Repository name for the created image

tagstring

Tag name for the create image

commentstring

Commit message

authorstring

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

pauseboolean

Whether to pause the container before committing

changesstring

Dockerfile instructions to apply while committing

Request body

Hostnamestring

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

Domainnamestring

The domain name to use for the container.

Userstring

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

AttachStdinboolean

Whether to attach to stdin.

AttachStdoutboolean

Whether to attach to stdout.

AttachStderrboolean

Whether to attach to stderr.

ExposedPortsobject nullable

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

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

Ttyboolean

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

OpenStdinboolean

Open stdin

StdinOnceboolean

Close stdin after one attached client disconnects

Envstring[]

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.

Cmdstring[]

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

ArgsEscapedboolean nullable

Command is already escaped (Windows only)

Imagestring

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

Volumesobject

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

WorkingDirstring

The working directory for commands to run in.

Entrypointstring[]

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

NetworkDisabledboolean nullable

Disable networking for the container.

OnBuildstring[] nullable

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

Labelsobject

User-defined key/value metadata.

StopSignalstring nullable

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

StopTimeoutinteger nullable

Timeout to stop a container in seconds. If omitted, the daemon-wide default (default-stop-timeout) is used.

Shellstring[] nullable

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

Example request

{
  "Hostname": "439f4e91bd1d",
  "User": "123:456",
  "ExposedPorts": {
    "80/tcp": {},
    "443/tcp": {}
  },
  "Env": [
    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
  ],
  "Cmd": [
    "/bin/sh"
  ],
  "Image": "example-image:1.0",
  "WorkingDir": "/public/",
  "Entrypoint": [],
  "OnBuild": [],
  "Labels": {
    "com.example.some-label": "some-value",
    "com.example.some-other-label": "some-other-value"
  },
  "StopSignal": "SIGTERM",
  "Shell": [
    "/bin/sh",
    "-c"
  ]
}

Response

no error

Idstring required

The id of the newly created object.

Changes

    • breaking

      removed the request body

    • breaking

      removed the success response with the status

    • info

      api tag Image added

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the success response with the status

    • breaking

      request body became required

    • breaking

      for the query request parameter pause, default value true was removed

    • breaking

      removed the enum value {} of the request property /

    • breaking

      removed the enum value {} of the request property /

    • breaking

      the / request property format changed from no format to int32

    • breaking

      the request property format changed from no format to int32

    • breaking

      removed the success response with the status

    • info

      api tag Image removed

    • info

      the request property default value {} was removed

    • info

      the request property default value {} was removed

    • info

      the request property default value false was removed

    • info

      the request property default value true was removed

    • info

      the request property default value false was removed

    • info

      the request property default value true was removed

    • info

      the request property default value false was removed

    • info

      the request property default value false was removed

    • info

      the request property default value 10 was removed

    • info

      the request property default value false was removed

    • info

      removed the non-success response with the status

    • info

      removed the non-success response with the status

    • info

      added the success response with the status