2021-10-13 16:57:11 +01:00
|
|
|
|
# docker commit
|
|
|
|
|
|
|
|
|
|
> Create a new image from a container’s changes.
|
|
|
|
|
> More information: <https://docs.docker.com/engine/reference/commandline/commit/>.
|
|
|
|
|
|
|
|
|
|
- Create an image from a specific container:
|
|
|
|
|
|
|
|
|
|
`docker commit {{container}} {{image}}:{{tag}}`
|
|
|
|
|
|
|
|
|
|
- Apply a `CMD` Dockerfile instruction to the created image:
|
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
|
`docker commit --change "CMD {{command}}" {{container}} {{image}}:{{tag}}`
|
2021-10-13 16:57:11 +01:00
|
|
|
|
|
|
|
|
|
- Apply an `ENV` Dockerfile instruction to the created image:
|
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
|
`docker commit --change "ENV {{name}}={{value}}" {{container}} {{image}}:{{tag}}`
|
2021-10-13 16:57:11 +01:00
|
|
|
|
|
|
|
|
|
- Create an image with a specific author in the metadata:
|
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
|
`docker commit --author "{{author}}" {{container}} {{image}}:{{tag}}`
|
2021-10-13 16:57:11 +01:00
|
|
|
|
|
|
|
|
|
- Create an image with a specific comment in the metadata:
|
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
|
`docker commit --message "{{comment}}" {{container}} {{image}}:{{tag}}`
|
2021-10-13 16:57:11 +01:00
|
|
|
|
|
|
|
|
|
- Create an image without pausing the container during commit:
|
|
|
|
|
|
2024-04-18 19:38:25 +01:00
|
|
|
|
`docker commit --pause {{false}} {{container}} {{image}}:{{tag}}`
|
2021-10-13 16:57:11 +01:00
|
|
|
|
|
|
|
|
|
- Display help:
|
|
|
|
|
|
|
|
|
|
`docker commit --help`
|