docker commit

Command Name: 

docker commit

Description:

docker  commit  Create a new image from a container’s changes.

Sometimes we take a standard image and make changes in it and customize it. So the container which we have in running condition that we wanted to store as an image.

Docker commit is a useful command to create an image from that running container so that we can use it as an image and create as many as containers from it.

Syntax:

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

Example:

easywhatis$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
easywhatis$ docker run -it --rm -d busybox
1357e68b12b9bfa65b95132fc44e6fb839bbc514e3f41fba95a8474c81cc515b
easywhatis$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
1357e68b12b9        busybox             "sh"                4 seconds ago       Up 3 seconds                            sharp_lovelace
easywhatis$ docker commit 1357e68b12b9 busybox/test:1.1
sha256:d6b60f8d8167c04f4776920a642382fea99a1c2ccc5f13dc13e8f9a89516f2f2
easywhatis$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox/test        1.1                 d6b60f8d8167        2 seconds ago       1.22MB