Introduction to Docker Hub

Ads
 

Introduction to Docker Hub

In this tutorial we are introducing you with the Docker Hub which is online repository service to host Docker images.

In this tutorial we are introducing you with the Docker Hub which is online repository service to host Docker images.

Introducing the Docker Hub and downloading image from Hub Hub

In the previous section we have installed Docker on the Ubuntu 18.04 and executed our first "Hello World" Docker container. In this section we are going to explore the Docker Hub, which is a public repository for pre-build Docker images.

In this tutorial we are going to download the nginx image and the run on Docker. You can manually pull (download) Docker image by Docker pull command or if you run the Docker by specifying image name, Docker will download if the image is not present on your machine.

There is another service called Docker Cloudthat provides a centralised, secure, distributed, and affordable platform for deploying and managing Docker images. It allows users to deploy applications that run on servers that run all the common application server components such as application servers, load balancers, data centers, and cloud services. You can easily connect the Docker Cloud to Cloud provide to deploy your images to run your applications in production instances.

What is Docker Hub?

Docker Hub is an online public/private repository for the distribution of pre-build Docker Images, which can be used to distribute Docker Images to publicly or privately. If the image is distributed as a public image then everyone will be able to download and use in Docker based applications. If you want to host your Docker image then you have to register on the site and select any of the packages for distribution of your custom image. There are limitations for free users, but you can also select paid membership as per your business needs.

You can visit Docker Hub at https://hub.docker.com/ and here you can search the available Docker Images.

Here is the home page of Docker Hub:

Docker Hub Home Page

If you search mysql on Docker Hub portal it will display following output:

Docker Hub Search

 

So, on the Docker Hub official website you will be able to search already available docker images. The command line tool will also search and list down the images published on the Docker Hub. Now we will se how to pull images from Docker Hub?

How to pull images from Docker Hub?

The command line tool docker will help you in searching and pulling the images from Docker Hub. To search you can use the docker search <image_name> command and to pull you can use docker pull <image_name> command. In the following section we will show you the usage of both these command with an example.

How to pull a Docker image?

Before actually pulling the image from Docker Hub you should search to see if an image with the given name exists. To search nginx image run following command:

docker search nginx

Above command will show the following output.

docker pull nginx

To download or pull the nginx image on your machine you can run the following command.

docker pull nginx

Above command will display the following output on the console.

Docker Pull Nginx

On the Docker Hub home page you will be able to see many top images of Docker.

Running nginx proxy in Docker

Now we will show you how you can run nginx proxy server in Docker container?  NGINX is an open source proxy server for serving the web content on the internet and it can be configured to work as a front-end for your application that handles the client requests and delegates with back-end servers. You can use NGINX as load balancer and HTTP/HTTPS proxy server in your production environment.

You can run NGINX on docker with following command:

docker run -it --rm -d -p 8080:80 --name web  nginx

This will run NGINX in the docker container and expose on 8080 port on your machine.

You should open your browser and then type http://localhost:8080. Your browser show display the default nginx page as shown below:

Nginx Running on Docker Hub

To stop the container run following command:

docker stop web

Above command will stop the running NGINX container. You can easily run NGINX in Docker containers to work as load balancer and proxy server for your back-end applications.

In this section we learned about the Docker Hub, pulled an NGINX image and ran it on our Docker installation.

In the next section we will learn about the Docker images and see how to pull some of the common images from Docker Hub for experimenting it on your computer. Working with the already package images will be your next step towards learning Docker.

Here are more tutorials of Docker:

Ads

Ads