How to List / Search / Pull docker images on Linux

What is a Docker Image

Docker images are a read-only template which is a base foundation to create a container from. We need an image to start the container. Ther are a lot of pre-built images out there on the docker hub. You can also have your own custom image built with the help of Dockerfile and the command “docker build”.

Searching a Docker Image

To search an image on a Docker registry, run the following command.

# docker search [search term]

The search term can be anything like centos, if you want to search for a image having centos OS. For Example :

# docker search centos

Here,
NAME : Is the name of the docker image.
DESCRIPTION : A short description on what the image is about.
STARS : How many people have liked the image.
OFFICIAL : Specifies whether the image is built from a trusted source.
AUTOMATED : Tells whether the images is built automatically with a push in GitHub or Bitbucket repositories.

You can combine more options here like number of minimum stars the image has and/or is the images has the AUTOMATED flag set to [OK]. For Example:

# docker search --filter=stars=30 --filter=is-automated=true centos
NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
ansible/centos7-ansible           Ansible on Centos7                              103                                     [OK]
jdeathe/centos-ssh                CentOS-6 6.9 x86_64 / CentOS-7 7.4.1708 x8...   90                                      [OK]
imagine10255/centos6-lnmp-php56   centos6-lnmp-php56                              31                                      [OK]

To find more options and functionalities with “docker search” command, use the help option.

# docker search --help

Pulling a Docker Image

To pull an image from the Docker registry, run the following command:

# docker pull NAME[:TAG]

here,
NAME – The main group of images with similar role. For Example centos.
TAG – Image with a specific tag such as centos7.

For Example, to pull centos 6 image :

# docker pull centos:centos6
centos6: Pulling from library/centos
b26de5a391ad: Pull complete 
Digest: sha256:ddb5ab83f18fb3d619c262b2c3aeb553857c9cab6aa864b5b6e7d7abf738d0b0
Status: Downloaded newer image for centos:centos6

By default, if you do not specify the optional tag field in the above command, the image with the latest tag gets pulled. You can also pull all the images from a specific tag. For Example :

# docker pull --all-tags fedora

Listing Docker Images

Run the below command to list all the images available locally on the system:

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
fedora              latest              422dc563ca32        3 days ago          252MB
ubuntu              latest              dd6f76d9cc90        2 weeks ago         122MB
hello-world         latest              725dcfab7d63        2 weeks ago         1.84kB
centos              centos6             ea096efd33cc        2 weeks ago         194MB
Related Post