LinuxCommandLibrary

docker-commit

create image from container changes

TLDR

Create image from container

$ docker commit [container_id] [image_name:tag]
copy
Commit with author info
$ docker commit --author "[name]" [container_id] [image:tag]
copy
Commit with message
$ docker commit -m "[Added config files]" [container_id] [image:tag]
copy
Commit with changed CMD
$ docker commit --change "CMD ['/app/start.sh']" [container_id] [image:tag]
copy

SYNOPSIS

docker commit [options] container [repository[:tag]]

DESCRIPTION

docker commit creates a new image from a container's changes. This captures the current state of a container's filesystem as a new image layer by examining all modifications made since the container was created.
While useful for debugging, experimentation, or saving a working state, this approach is not recommended for production workflows. Dockerfiles provide better reproducibility, version control, and documentation of the build process. Committed images lack the transparent layer history that Dockerfiles provide, making them harder to maintain and audit.

PARAMETERS

-a, --author string

Author of the image.
-c, --change list
Apply Dockerfile instructions to the image.
-m, --message string
Commit message.
-p, --pause
Pause container during commit (default true).

CAVEATS

Does not include data in volumes. The resulting image lacks build history and is not reproducible.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community