Create a new image from stopped container in Docker

Commit a new image with stopped container in Docker

Check the stopped container in Docker

#docker ps -a

sunny@Oracle1:/etc$ docker ps -a

CONTAINER ID   IMAGE         COMMAND     CREATED       STATUS                     PORTS     NAMES

eeb55035fffe   orcl2-image   "/bin/sh"   3 hours ago   Exited (0) 3 seconds ago             fervent_herschel

sunny@Oracle1:/etc$ 

Create an image from the stopped container:

#docker commit <imageid> <new image name>

or

#docker commit <imagename> <new image name>

sunny@Oracle1:/etc$ docker commit eeb55035fffe image-oracle

sha256:fead993590ebd2eacb4a367cc2a057ebb6c7b1ab5e920a790a0fb45ece1db95f

Verify the created image:

sunny@Oracle1:/etc$ docker images

REPOSITORY                                       TAG         IMAGE ID       CREATED          SIZE

image-oracle                                     latest      fead993590eb   27 seconds ago   15.8GB

orcl2-image                                      latest      e28a1ae656c2   3 hours ago      15.8GB

Run the image for testing purpose:

sunny@Oracle1:/etc$ docker run -it image-oracle 

sh-4.2$ 

sh-4.2$ 

sh-4.2$ ls

setPassword.sh

sh-4.2$ 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.