.nh .TH "DOCKER" "1" "Jan 2024" "Docker Community" "Docker User Manuals" .SH NAME .PP docker-container-commit - Create a new image from a container's changes .SH SYNOPSIS .PP \fBdocker container commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]\fP .SH DESCRIPTION .PP Create a new image from an existing container specified by name or container ID. The new image will contain the contents of the container filesystem, \fIexcluding\fP any data volumes. Refer to \fBdocker-tag(1)\fP for more information about valid image and tag names. .PP While the \fBdocker commit\fR command is a convenient way of extending an existing image, you should prefer the use of a Dockerfile and \fBdocker build\fR for generating images that you intend to share with other people. .SH EXAMPLES .SH Creating a new image from an existing container .PP An existing Fedora based container has had Apache installed while running in interactive mode with the bash shell. Apache is also running. To create a new image run \fBdocker ps\fR to find the container's ID and then run: .EX $ docker commit -m="Added Apache to Fedora base image" \\ -a="A D Ministrator" 98bd7fc99854 fedora/fedora_httpd:20 .EE .PP Note that only a-z0-9-_. are allowed when naming images from an existing container. .SH Apply specified Dockerfile instructions while committing the image .PP If an existing container was created without the DEBUG environment variable set to "true", you can create a new image based on that container by first getting the container's ID with \fBdocker ps\fR and then running: .EX $ docker container commit -c="ENV DEBUG=true" 98bd7fc99854 debug-image .EE .SH OPTIONS .PP \fB-a\fP, \fB--author\fP="" Author (e.g., "John Hannibal Smith hannibal@a-team.com \[la]mailto:hannibal@a\-team.com\[ra]") .PP \fB-c\fP, \fB--change\fP= Apply Dockerfile instruction to the created image .PP \fB-h\fP, \fB--help\fP[=false] help for commit .PP \fB-m\fP, \fB--message\fP="" Commit message .PP \fB-p\fP, \fB--pause\fP[=true] Pause container during commit .SH SEE ALSO .PP \fBdocker-container(1)\fP