Site icon i2tutorials

Docker – Images

Docker Images

 

An image is a combination of a file system and parameters in Docker.

$ docker run hello-world 

Let’s use the CentOS image available on Docker Hub to run CentOS on Ubuntu. Execute the following command on Ubuntu to do so.

$ sudo docker run -it centos /bin/bash

Here’s what you need to know about sudo

Displaying Docker Images

The following command will show you the Docker images on your system.

$ docker images

You can use this command to see all your images.

Output

We’ll get the following result when we run the above command

You can see in the above output that the server has an image called centos. It has the following attributes:

Downloading Docker Images

Using Docker pull, we’ll download images from Docker Hub.

Syntax

Use the following syntax to run a Docker image in a Docker container.

$ docker pull image 

Options

Example

$ sudo docker run centos

Running this command will download the centos image and run it as a container, if it’s not already there.

The CentOS Docker image should be visible when we run the Docker images command.

Removing Docker Images

Let’s look at the docker rmi command in more detail to see how to remove Docker images.

$ docker rmi -f

Docker images can be removed with this command.

Syntax

$ docker rmi -f imageID

Options

Return Value

You will receive the Image ID of the deleted image in the output.

Example

$ sudo docker rmi -f 5d0da3dc9764

Here, 5d0da3dc9764 is my Centos Image ID.

Output

We’ll get the following result when we run the above command −

Let’s see some more Docker commands.

$ docker images -q

You can use this command to get just the image IDs.

Syntax

$ docker images -q

Options

Return Value

It will only show the Image IDs of the Docker images.

Example

$ docker images -

Output

We’ll get the following result when we run the above command

docker inspect

You can use this command to see details about an image or container.

Syntax

$ docker inspect Repository 

Options

Return Value

You’ll get detailed info on the image.

Example

$ sudo docker inspect centos

Output

Here’s what you’ll get from the above command:

Exit mobile version