docker-container-commit
Create a new image from a container
TLDR
Create an image from a specific container
Apply a CMD Dockerfile instruction to the created image
Apply an ENV Dockerfile instruction to the created image
Create an image with a specific author in the metadata
Create an image with a specific comment in the metadata
Create an image without pausing the container during commit
Display help
SYNOPSIS
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
PARAMETERS
-a, --author string
Author of the image (e.g., "Bill Murray <bill.murray@imaginary.com>")
-c, --change list
Apply Dockerfile instructions to created image (e.g., CMD, ENV, EXPOSE)
-m, --message string
Commit message describing changes
-p, --pause bool
Pause container during commit (default true)
DESCRIPTION
The docker commit command creates a new Docker image from an existing container by capturing all filesystem changes made during the container's lifetime. This is particularly useful for debugging, quick prototyping, or saving intermediate states without a Dockerfile.
Specify a running or stopped container by ID or name, followed optionally by a repository name and tag for the new image (e.g., myimage:v1). By default, the container is paused during the commit process to ensure consistency, though this can be disabled.
Options allow customizing the commit: set an author name/email, add a descriptive message, apply Dockerfile-like changes (e.g., CMD, ENV, EXPOSE), or squash layers (deprecated). The resulting image includes the container's current state, including any modifications to files, installed packages, or configurations.
While convenient, docker commit is discouraged for production workflows as it creates opaque, non-reproducible images. Layers may bloat if large files are modified, and it's harder to track changes compared to layered builds via docker build. Always tag and push committed images for sharing.
CAVEATS
Avoid for production; produces non-reproducible, bloated images. Prefer Dockerfiles. Deprecated --squash option ignored in recent versions.
EXAMPLE
docker commit abc123 myimage:latest
docker commit -m "Added nginx" -a "John Doe" mycontainer myrepo/nginx:v1
OUTPUT
Returns new image ID/SHA (e.g., sha256:abc123...) or error if container not found.
HISTORY
Introduced in Docker 0.6 (2013); stabilized in Docker 1.0. Evolved with layer squashing (later deprecated) to optimize image size.
SEE ALSO
docker(1), docker-build(1), docker-images(1), docker-ps(1), docker-tag(1)


