What is Docker Image & How To Create Docker Image

Here in this article we will cover what is docker image and how to create docker images. As this docker image is being used mostly by the software developer. Because of its tremendous benefits and easy to use.

  • We will also see the use of docker images.
  • And also see how to find the history of docker images.
  • We will be looking how to get all details about docker images.

After that we will see the multiple methods of creating docker images from scratch. There are majorly three methods of creating docker images. Which I have described below in detail.

And finally the last one is how we can delete the docker images. So let’s get started now.

Definition of Docker Image

Docker Image is a package of software or we can say it as a template of the software. Docker images also contains the set of rules with default command. Which are used later to create the docker containers. Docker images are very light weight in terms of size.

Docker Images can be identified by Image_ID or Image_Name.

We can create multiple docker images of same package by changing the Repository and Image_Tag

Package of Software like

  1. Operating System (Window, Linux, etc)
  2. Web Server (Apache, Nginx, etc)
  3. Database (MySql, Mariadb, etc)
  4. Etc

Use Of Docker Image

  1. Docker images are used for creating Docker containers.
  2. We can create multiple containers from a single docker images.

How to Check Docker Images List

We can get all the available docker images list in a single docker command.

Default Command

sudo docker images

New Command

sudo docker image ls

How To See History Of Docker Images

This command will provide you all the history of docker images.

sudo docker image history <Image_Name>

How To Check All Details of Docker Images

You will see all the details about docker images.

sudo docker image inspect <Image_Name> 

How To Create Docker Image

We can create a docker image from scratch by using three (3) methods.

  1. Download Image
  2. Create Image Using Dockerfile
  3. Create Image From Container

Method 1> Download Image

We can directly download the docker images from the docker hub repository. And the command which is used for downloading the image is Pull.

Download Image Command

sudo docker pull <Image_Name> 

Check the Downloaded Image

sudo docker images

Method 2> Create Image Using Dockerfile

Dockerfile is used to create the custom images. Which you can use for application purpose.

This Dockerfile will always be saved by the name of Dockerfile.

It contains multiple commands. Like

  1. FROM
  2. RUN
  3. ADD
  4. COPY
  5. CMD
  6. Etc

Step 1> Create a File.

Create any file with the extension of dockerfile.

Step 2> Add the commands in Dockerfile.

You can add command according to your application requirements.

Step 3> Save the file by name Dockerfile.

Step 4> Execute the Dockerfile

Docker build command is used to execute the Dockerfile.

sudo docker build <Dockerfile-location> -t <give-any-name>

Step 5> Check the Docker Images.

sudo docker images

Method 3> Create Image From Container

When you want to create a docker images from the docker container. Then first you have to go into the docker container.

Step 1> Enter into the Container.

Docker exec command is used to go into the container.

sudo docker exec -it <container-ID> bash

Step 2> Modify the Container.

Add or change anything inside the container which helps in running your application.

Step 3> Exit from Container.


Step 4> Create Docker Image of Modified Container.

Docker commit can be used to create the new docker images.

sudo docker commit <container-ID> Docker-Hub-Username/New-Image-Name

Step 5> Check the Docker images

sudo docker images

How to Delete Docker Image

Delete One Image

sudo docker rmi <Image_Name>

Delete Multiple Image

sudo docker rmi <Image_Name_1> <Image_Name_2>

Remove All Unused Image

sudo docker image prune -a


In conclusion so finally we have finished what is docker image. And also seen the tremendous uses of docker images. We have also covered how we get all history as well as all the details of docker images.  And the most important one is how we can create the docker images. We have seen three methods of creating the docker images. Those methods are described in complete details. After that we finished how we can delete a one and multiple docker images. We have also used the prune command.

I hope this article was very helpful to you in getting a bit more detailed information about docker images.

So thank you very much for reading this topic, what is a docker images.?