mirror of
https://github.com/docker/docs.git
synced 2026-03-27 22:38:54 +07:00
vendor: github.com/docker/cli 01f933261885
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
@@ -1,24 +1,7 @@
|
||||
command: docker commit
|
||||
aliases: docker container commit, docker commit
|
||||
short: Create a new image from a container's changes
|
||||
long: |-
|
||||
It can be useful to commit a container's file changes or settings into a new
|
||||
image. This allows you to debug a container by running an interactive shell, or to
|
||||
export a working dataset to another server. Generally, it is better to use
|
||||
Dockerfiles to manage your images in a documented and maintainable way.
|
||||
[Read more about valid image names and tags](tag.md).
|
||||
|
||||
The commit operation will not include any data contained in
|
||||
volumes mounted inside the container.
|
||||
|
||||
By default, the container being committed and its processes will be paused
|
||||
while the image is committed. This reduces the likelihood of encountering data
|
||||
corruption during the process of creating the commit. If this behavior is
|
||||
undesired, set the `--pause` option to false.
|
||||
|
||||
The `--change` option will apply `Dockerfile` instructions to the image that is
|
||||
created. Supported `Dockerfile` instructions:
|
||||
`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`LABEL`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
|
||||
long: Create a new image from a container's changes
|
||||
usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
|
||||
pname: docker
|
||||
plink: docker.yaml
|
||||
@@ -37,7 +20,6 @@ options:
|
||||
shorthand: c
|
||||
value_type: list
|
||||
description: Apply Dockerfile instruction to the created image
|
||||
details_url: '#change'
|
||||
deprecated: false
|
||||
hidden: false
|
||||
experimental: false
|
||||
@@ -76,72 +58,6 @@ inherited_options:
|
||||
experimentalcli: false
|
||||
kubernetes: false
|
||||
swarm: false
|
||||
examples: |-
|
||||
### Commit a container
|
||||
|
||||
```console
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
c3f279d17e0a ubuntu:22.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:22.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
|
||||
$ docker commit c3f279d17e0a svendowideit/testimage:version3
|
||||
|
||||
f5283438590d
|
||||
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG ID CREATED SIZE
|
||||
svendowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB
|
||||
```
|
||||
|
||||
### Commit a container with new configurations (--change) {#change}
|
||||
|
||||
```console
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
c3f279d17e0a ubuntu:22.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:22.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
|
||||
$ docker inspect -f "{{ .Config.Env }}" c3f279d17e0a
|
||||
|
||||
[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin]
|
||||
|
||||
$ docker commit --change "ENV DEBUG=true" c3f279d17e0a svendowideit/testimage:version3
|
||||
|
||||
f5283438590d
|
||||
|
||||
$ docker inspect -f "{{ .Config.Env }}" f5283438590d
|
||||
|
||||
[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true]
|
||||
```
|
||||
|
||||
### Commit a container with new `CMD` and `EXPOSE` instructions
|
||||
|
||||
```console
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
c3f279d17e0a ubuntu:22.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:22.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
|
||||
$ docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a svendowideit/testimage:version4
|
||||
|
||||
f5283438590d
|
||||
|
||||
$ docker run -d svendowideit/testimage:version4
|
||||
|
||||
89373736e2e7f00bc149bd783073ac43d0507da250e999f3f1036e0db60817c0
|
||||
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
89373736e2e7 testimage:version4 "apachectl -DFOREGROU" 3 seconds ago Up 2 seconds 80/tcp distracted_fermat
|
||||
c3f279d17e0a ubuntu:22.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:22.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
```
|
||||
deprecated: false
|
||||
experimental: false
|
||||
experimentalcli: false
|
||||
|
||||
Reference in New Issue
Block a user