How To Pull A Docker Image And Run A Container

This quick tutorial is going to cover how to pull a Docker image and run a container.

1. List or Search For a Docker Image

Before we can pull a Docker image and run a container, we should know its name first. And to do that, we can go to the Docker hub or Docker store to search for any name.

The alternative way is to use the docker search command to list or search for a Docker image. Let’s see the following example which we search for an Ubuntu docker from the default public registry:

As we can see the docker names, number of stars, and whether a Docker is official or not.

2. Pull A Docker Image

2.1. Pull A Docker Image From The Public Registry

To pull a Docker image from the public registry, we can use the docker pull command which has the following syntax:

Some command options:

Name, shorthand Default Description
–all-tags, -a false Download all tagged images in the repository
–disable-content-trust true Skip image verification

Let’s see how we pull an official Ubuntu docker image from the public registry.

Example output:

2.2. Pull A Docker Image From A Private Registry

To pull a Docker image from a private registry, we can use the same docker pull command and provide exactly the full name of the Docker image on that private registry. Let’s see an example which we pull a ubuntu-java8 image from an private registry localregistry.com:

3. Run a Docker Container

After we pull a Docker image from Docker registry, to run a Docker container from that image, we can use the docker run command which has basic syntax as following:

Let’s see an example which we run the above ubuntu docker image:

4. Conclusion

The tutorial has just illustrated list or search for a Docker image from public and private registries. After that we can pull a Docker image and run a container from that image. These are basic steps for us to get started with Docker. Here are other tutorials for your references:

Here are other tutorials for your reference:

Attach and Detach from Docker Container

How To Remove Unused Docker Images, Containers, Volumes, and Networks

Copy Files, Folders from Host to Docker Container and Vice Versa

Install Docker on Ubuntu 16.04, 15.10, 14.04 Step By Step

Install Docker on CentOS 7.X

Introduction to Docker Compose

Vagrant Docker Provider Tutorial

Using Apache Kafka Docker

Insecure docker registry

How to Get IP Address of a Docker Container