Get Started with Docker – Part 1 : Docker Hub, Pulling Images, and Basic Containers Manipulation


In this part 1 of our series “Get Started with Docker”, I’ll guide you to explore the Docker world, Here you’ll find easy and important steps to get started with Docker containers, you’ll learn how to search for and pull images from Decker hub, create your first Docker container, attach to a running containers, stop, start, delete containers, and finally execute commands in a container. This article will contain important info and I tried to use simple steps.

This is our first explanation part of our Docker series. This article is targeting developers/sysadmin who want to start using Docker. Let’s start.


Before we dive into Docker containers, we need to install the Docker daemon first. According to your Linux OS here’s our installation articles for different Linux releases:

Now, you successfully installed Docker on your Linux machine, let’s start diving into Docker world.

Part 1: Exploring the Docker Hub Repositories

This is an introduction part to Docker Hub, if you do not have the time either you can quickly read it or skip to the next part.

Great, you’ve the time to read this part and we’ll start with this question  What is Docker hub?

Docker Hub is a cloud-based registry service which allows you to link to code repositories, build your images and test them, stores manually pushed images, and links to Docker Cloud so you can deploy images to your hosts. It provides a centralized resource for container image discovery, distribution and change management, user and team collaboration, and workflow automation throughout the development pipeline.

Simply, Docker hub is a cloud register you will use to pull images “official or user’s images”, store/push your images to it to use it later. Docker hub stores multiple version of  each image in a separate repository, it uses a naming convention image_name:tag to differentiate between different version of an image, if you don’t provide a tag when you pull/push image from/to a repository, it will use latest as a tag for this image. In Docker hub you can find two types of repositories Public and Private. Public repositories can be either official “created by organizations” or non-official “creates by users”. Private repositories is a non-official repositories created by users or companies for using within a private groups/teams.

Docker Hub provides the following major features:

  • Image Repositories: Find and pull images from community and official libraries, and manage, push to, and pull from private image libraries to which you have access.
  • Automated Builds: Automatically create new images when you make changes to a source code repository.
  • Webhooks: A feature of Automated Builds, Webhooks let you trigger actions after a successful push to a repository.
  • Organizations: Create work groups to manage access to image repositories.
  • GitHub and Bitbucket Integration: Add the Hub and your Docker Images to your current workflows.

Explore repositories

You can find public repositories and images from Docker Hub in two ways. You can “Search” from the Docker Hub website, or you can use the Docker command line tool to run the docker search command. For example if you were looking for an CentOS image, here’s the Docker hub web site results:



As you see, we have 13796 public repositories, the first one is the official one, the others are users repositories. Exploring the Docker hub website is not the ideal case

Ideally, you’ll use the following command line search to explore Docker hub repositories, here’s the search results for CentOS:

    $ docker search CentOS


As you see, the first one is the official one, the others are users repositories.

Both methods list the available public repositories on Docker Hub which match the search term.

Private repositories do not appear in the repository search results. To see all the repositories you can access and their status, view your “Dashboard” page on Docker Hub.

Use Official Repositories

Docker Hub contains a number of Official Repositories. These are public, certified repositories from vendors and contributors to Docker. They contain Docker images from vendors like Canonical, Oracle, and Red Hat that you can use as the basis to building your applications and services.

With Official Repositories you know you’re using an optimized and up-to-date image that was built by experts to power your applications.

Before moving to the next part, you may want to create your Docker ID, Docker hub provide a free ID for users with unlimited Public repositories and only one private repository, if you need more private repositories, you can upgrade your Docker ID and of course pay a monthly fees.

Creating a Docker ID is simple as shown below:


Simply, you’ll be asked for a username, and email, and a password. Now let’s proceed to the next part.


1. You do not need to have a Docker ID to explore the public repositories.

Part 2: Pulling Images from Public Repositories on Docker Hub “Public Images”

In the previous part, we explored the images on docker hub using the web site but as I mentioned previously, we’ll use CLI in almost all our work from now on. In order to start and run a Docker container, first an image must be downloaded from Docker Hub on your host. This part will deal with pulling images from Docker Hub to your host. Docker Hub offers a great deal of free images from its repositories.

Before pulling images, you need to search for a Docker image on Docker hub, CentOS for example, run the following command:

$ docker search centos

Here’s the results of the above command:


As you see, the first one is the official one, the others are users repositories. Docker search only shows public repositories. Always use official repositories.

Now, we’ll pull CentOS image from Docker Hub, pulling is a process of downloading and saving image locally,run the following command:

# docker pull centos


As you see, we are pulling centos image with tag latest, this because we didn’t specify a tag when we pulled the centos image.

But if we need to pull image with a certain tag “assuming we know the tag by browsing Docker Hub web site”, we’ll use the same pull command but with appending the tag to the image as following:

# docker pull centos:6.7


As you see, latest in the first image replaced with 6.7.


1. CLI does not allow searching/listing tags in a repository.
2. To pull a certain tag of an image, you must know this tag first from Docker Hub web site.

To list all the available Docker images on your host,run the following command:

# docker images


This command lists all local images on my host.

Suppose you don’t need a Docker image “centos:6.7 for example” anymore and you want to remove it from the host, run the following command:

# docker rmi centos:6.7


As seen, we successfully deleted centos:6.7 image from local host without any problems. Now we will try to remove hello-world image using “docker rmi" command as the following:

# docker rmi hello-world
Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container adef4b21354c is using its referenced image 48b5124b2768

Error, why the above command fails, this because we previously created a container from it “container with id adef4b21354c“, so to successfully delete this image either first delete the container created from it “container with id adef4b21354c” the use the above command to delete it or force deletion of this image by adding -f option to the above command.

Here, we will force the deletion of the image by adding -f option to the above command as the following:

# docker rmi -f hello-world


As you see, we deleted the image successfully. And this is the end of this part, now let’s proceed to the next part “in the next page”.

If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

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