github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/man/docker-commit.1.md (about) 1 % DOCKER(1) Docker User Manuals 2 % Docker Community 3 % JUNE 2014 4 # NAME 5 docker-commit - Create a new image from a container's changes 6 7 # SYNOPSIS 8 **docker commit** 9 [**-a**|**--author**[=*AUTHOR*]] 10 [**-c**|**--change**[=\[*DOCKERFILE INSTRUCTIONS*\]]] 11 [**--help**] 12 [**-m**|**--message**[=*MESSAGE*]] 13 [**-p**|**--pause**[=*true*]] 14 CONTAINER [REPOSITORY[:TAG]] 15 16 # DESCRIPTION 17 Create a new image from an existing container specified by name or 18 container ID. The new image will contain the contents of the 19 container filesystem, *excluding* any data volumes. Refer to **docker-tag(1)** 20 for more information about valid image and tag names. 21 22 While the `docker commit` command is a convenient way of extending an 23 existing image, you should prefer the use of a Dockerfile and `docker 24 build` for generating images that you intend to share with other 25 people. 26 27 # OPTIONS 28 **-a**, **--author**="" 29 Author (e.g., "John Hannibal Smith <hannibal@a-team.com>") 30 31 **-c** , **--change**=[] 32 Apply specified Dockerfile instructions while committing the image 33 Supported Dockerfile instructions: `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`LABEL`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` 34 35 **--help** 36 Print usage statement 37 38 **-m**, **--message**="" 39 Commit message 40 41 **-p**, **--pause**=*true*|*false* 42 Pause container during commit. The default is *true*. 43 44 # EXAMPLES 45 46 ## Creating a new image from an existing container 47 An existing Fedora based container has had Apache installed while running 48 in interactive mode with the bash shell. Apache is also running. To 49 create a new image run `docker ps` to find the container's ID and then run: 50 51 # docker commit -m="Added Apache to Fedora base image" \ 52 -a="A D Ministrator" 98bd7fc99854 fedora/fedora_httpd:20 53 54 Note that only a-z0-9-_. are allowed when naming images from an 55 existing container. 56 57 ## Apply specified Dockerfile instructions while committing the image 58 If an existing container was created without the DEBUG environment 59 variable set to "true", you can create a new image based on that 60 container by first getting the container's ID with `docker ps` and 61 then running: 62 63 # docker commit -c="ENV DEBUG true" 98bd7fc99854 debug-image 64 65 # HISTORY 66 April 2014, Originally compiled by William Henry (whenry at redhat dot com) 67 based on docker.com source material and in 68 June 2014, updated by Sven Dowideit <SvenDowideit@home.org.au> 69 July 2014, updated by Sven Dowideit <SvenDowideit@home.org.au> 70 Oct 2014, updated by Daniel, Dao Quang Minh <daniel at nitrous dot io> 71 June 2015, updated by Sally O'Malley <somalley@redhat.com>