Docker for Beginner – How to use Docker Hub

Docker Hub is an internet registry service that allows us to download docker images built by communities. Or, we can also upload our own images to the Docker hub and share it with communities. I will explain a bit more about Docker Hub on this post. I am not a Docker pro, I just started learning docker and I think it is good to share my learning experiece with anyone who just started to learn Docker like my self.

Docker Hub Sign Up

It is not mandatory to have Docker Hub account. Without the Docker Hub account, we still able to download images from the community. But, if we want to upload our images, we need this account. To create new account, simply go to this website and enter your credentials.

Docker Hub Sign Up Portal

docker hub.png

Explore Docker Hub

In order to explore Docker Hub, we don’t need an account. Simply click the following url to browse and explore any applications, images developed by community.

https://hub.docker.com/explore/

docker hub explore.png

But now, thre is a new place to discover Public Docker content at Docker store. In Docker store, you can find free and also commercial Docker contents.

Pull Image from Docker Hub/Docker Store

Search any application from Docker Store. In this example, I use mariadb at this link.

For example:

docker pull mariadb

Output:

mariadb pull docker.png

Now we can list the images available locally with docker images command

root@ubuntu-server:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@ubuntu-server:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mariadb latest ea0322bb4096 11 days ago 395.2 MB

Run a container from the image

After we pulled the image, we can now run a container using the image we’ve downloaded. There should be a detailed information in the docker hub about how to run the container using the image.

mariadb docker.png

docker run –name mariadb_01 -e MYSQL_ROOT_PASSWORD=12345678 -d mariadb:latest

Output

ubuntu@ubuntu-server:~$ sudo docker run –name mariadb_01 -e MYSQL_ROOT_PASSWORD=12345678 -d mariadb:latest
9bcd07f4b929e31b5a7d5c5395d7ba77961e22d9747c0176d1f9479ffe9a5949

At this point, a new container is up and running using the image we’ve pulled previously.

Be the first to comment

Leave a Reply