github.com/tompao/docker@v1.9.1/docs/reference/commandline/commit.md (about) 1 <!--[metadata]> 2 +++ 3 title = "commit" 4 description = "The commit command description and usage" 5 keywords = ["commit, file, changes"] 6 [menu.main] 7 parent = "smn_cli" 8 +++ 9 <![end-metadata]--> 10 11 # commit 12 13 Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] 14 15 Create a new image from a container's changes 16 17 -a, --author="" Author (e.g., "John Hannibal Smith <hannibal@a-team.com>") 18 -c, --change=[] Apply specified Dockerfile instructions while committing the image 19 --help=false Print usage 20 -m, --message="" Commit message 21 -p, --pause=true Pause container during commit 22 23 It can be useful to commit a container's file changes or settings into a new 24 image. This allows you debug a container by running an interactive shell, or to 25 export a working dataset to another server. Generally, it is better to use 26 Dockerfiles to manage your images in a documented and maintainable way. 27 28 The commit operation will not include any data contained in 29 volumes mounted inside the container. 30 31 By default, the container being committed and its processes will be paused 32 while the image is committed. This reduces the likelihood of encountering data 33 corruption during the process of creating the commit. If this behavior is 34 undesired, set the 'p' option to false. 35 36 The `--change` option will apply `Dockerfile` instructions to the image that is 37 created. Supported `Dockerfile` instructions: 38 `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`LABEL`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` 39 40 ## Commit a container 41 42 $ docker ps 43 ID IMAGE COMMAND CREATED STATUS PORTS 44 c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours 45 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours 46 $ docker commit c3f279d17e0a SvenDowideit/testimage:version3 47 f5283438590d 48 $ docker images 49 REPOSITORY TAG ID CREATED VIRTUAL SIZE 50 SvenDowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB 51 52 ## Commit a container with new configurations 53 54 $ docker ps 55 ID IMAGE COMMAND CREATED STATUS PORTS 56 c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours 57 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours 58 $ docker inspect -f "{{ .Config.Env }}" c3f279d17e0a 59 [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin] 60 $ docker commit --change "ENV DEBUG true" c3f279d17e0a SvenDowideit/testimage:version3 61 f5283438590d 62 $ docker inspect -f "{{ .Config.Env }}" f5283438590d 63 [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true] 64 65 ## Commit a container with new `CMD` and `EXPOSE` instructions 66 67 $ docker ps 68 ID IMAGE COMMAND CREATED STATUS PORTS 69 c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours 70 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours 71 72 $ docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a SvenDowideit/testimage:version4 73 f5283438590d 74 75 $ docker run -d SvenDowideit/testimage:version4 76 89373736e2e7f00bc149bd783073ac43d0507da250e999f3f1036e0db60817c0 77 78 $ docker ps 79 ID IMAGE COMMAND CREATED STATUS PORTS 80 89373736e2e7 testimage:version4 "apachectl -DFOREGROU" 3 seconds ago Up 2 seconds 80/tcp 81 c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours 82 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours