Concept of Docker Images

Last updated on Sep 17 2022
Neha Warghade

Table of Contents

Concept of Docker Images

Docker – Images

In Docker, everything is based on Images. An image is a combination of a file system and parameters. Let’s take an example of the subsequent command in Docker.

docker run hello-world

  • The Docker command is specific and tells the Docker program on the Operating System that something needs to be done.
  • The run command is employed to mention that we want to create an instance of an image, which is then called a container.
  • Finally, “hello-world” represents the image from which the container is made.

Now let’s look at how we can use the CentOS image available in Docker Hub to run CentOS on our Ubuntu machine. We can do this by executing the subsequent command on our Ubuntu machine −

sudo docker run centos –it /bin/bash

Note the subsequent points about the above sudo command −

  • We are using the sudo command to ensure that it runs with root
  • Here, centos is the name of the image we want to download from Docker Hub and install on our Ubuntu machine.
  • ─it is employed to mention that we want to run in interactive mode.
  • /bin/bash is employed to run the bash shell once CentOS is up and running.

Displaying Docker Images

To see the list of Docker images on the system, you can issue the subsequent command.

docker images

This command is employed to display all the images currently installed on the system.

Syntax

docker images

Options

None

Return Value

The output will provide the list of images on the system.

Example

sudo docker images

Output

When we run the above command, it will produce the subsequent result −

doc 40

From the above output, you can see that the server has three images: centos, newcentos, and jenkins. Each image has the subsequent attributes −

  • TAG − This is employed to logically tag images.
  • Image ID − This is employed to uniquely identify the image.
  • Created − The number of days since the image was created.
  • Virtual Size − The size of the image.

Downloading Docker Images

Images can be downloaded from Docker Hub using the Docker run command. Let’s see in detail how we can do this.

Syntax

The subsequent syntax is employed to run a command in a Docker container.

docker run image

Options

  • Image − This is the name of the image which is employed to run the container.

Return Value

The output will run the command within the desired container.

Example

sudo docker run centos

This command will download the centos image, if it is not already present, and run the OS as a container.

Output

When we run the above command, we will get the subsequent result −

doc 41

You’ll now see the CentOS Docker image downloaded. Now, if we run the Docker images command to see the list of images on the system, we ought to  be able to see the centos image as well.

doc 42

Removing Docker Images

The Docker images on the system can be removed via the docker rmi command. Let’s look at this command in more detail.

docker rmi

This command is employed to remove Docker images.

Syntax

docker rmi ImageID

Options

  • ImageID − This is the ID of the image which needs to be removed.

Return Value

The output will provide the Image ID of the deleted Image.

Example

sudo docker rmi 7a86f8ffcb25

Here, 7a86f8ffcb25 is the Image ID of the newcentos image.

Output

When we run the above command, it will produce the subsequent result −

doc 43

Let’s see some more Docker commands on images.

docker images -q

This command is employed to return only the Image ID’s of the images.

Syntax

docker images

Options

  • q − It tells the Docker command to return the Image ID’s only.

Return Value

The output will show only the Image ID’s of the images on the Docker host.

Example

sudo docker images -q

Output

When we run the above command, it will produce the subsequent result −

doc 44

docker inspect

This command is employed see the details of an image or container.

Syntax

docker inspect Repository

Options

  • Repository − This is the name of the Image.

Return Value

The output will show detailed information on the Image.

Example

sudo docker inspect jenkins

Output

When we run the above command, it will produce the subsequent result −

doc 45

So, this brings us to the end of blog. This Tecklearn ‘Concept of Docker Images’ blog helps you with commonly asked questions if you are looking out for a job in DevOps. If you wish to learn Docker and build a career in DevOps domain, then check out our interactive, Containerization using Docker Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/containerization-using-docker/

Containerization using Docker Training

About the Course

Tecklearn has specially designed this Containerization using Docker Training Course to advance your skills for a successful career in this domain. his Docker training online course will help you learn Docker containerization, running Docker containers, Docker image creation, Dockerfile, Docker orchestration, security best practices and more through hands-on projects and case studies. Upon completion of this online training, you will hold a solid understanding and hands-on experience with Docker.

Why Should you take Containerization using Docker Training?

  • Average salary of Docker Expert is $110k – Indeed.com
  • According to Grand View Research, the DevOps market size is estimated to be worth $12.85 billion by 2025. DevOps professionals are highly paid and in-demand throughout industries including retail, eCommerce, finance, and technology.
  • Intuit, PayPal, Splunk, Uber & many other MNC’s worldwide use Docker across industries

What you will Learn in this Course?

Introduction to DevOps

  • What is Software Development
  • Software Development Life Cycle
  • Why DevOps?
  • What is DevOps?
  • DevOps Lifecycle
  • DevOps Tools
  • Benefits of DevOps
  • How DevOps is related to Agile Delivery
  • DevOps Implementation

Containerization using Docker – Part 1

  • Introduction to Docker
  • Understanding Docker Lifecycle
  • Docker Architecture
  • Components of Docker Ecosystem
  • Common Docker Operations
  • Committing changes in a Container
  • Hands On

Containerization using Docker – Part 2

  • Building Custom Docker Images
  • Docker Image
  • Introduction to Docker Swarm
  • Deploying a 2-Node Cluster using Docker Swarm
  • Hands on

 

0 responses on "Concept of Docker Images"

Leave a Message

Your email address will not be published. Required fields are marked *