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