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


Create an image from the stopped container:

#docker commit <imageid> <new image name>


#docker commit <imagename> <new image name>

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


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$ ls



Leave a Reply

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

You are commenting using your 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.