Learn To Push Custom Build Docker Image on Docker HUB (Repository) - Part 5
Docker Linux Tutorials

Learn To Push Custom Build Docker Image on Docker HUB (Repository) – Part 5

In our previous article we Learned To Install, Run And Delete Applications Inside Docker Containers and in the same article we learned to create and build our own custom image on our local system and we also learned to create our Docker Hub account to pull Docker Images.

Now if we want to keep your Custom Build Image on Docker HUB so that these Custom Build Image can be used by everyone else and to do so we have to host our Custom Build Image on Public repositories(within Docker HUB).

We also downloaded CentOS images which are available on Docker Hub and there are many images such as Ubuntu, Mongo, and Lamp which are all publicly available for all. We are also going to do the same and we will make our images available by publishing it to the public repository on Docker Hub.

For this example, we will use the same image Docker Image (centos-apache) which we created in PART 4.

Just in case, if you did Miss Previous tutorial regarding Docker, You can read here:

Part 1: What Is Docker And Concept Of Containers With Virtualization?
Part 2: How To Install Docker On CentOS/RHEL 6/7? And Learn Docker HUB Registration
Part 3A: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 A
Part 3B: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 B
Part 4: Learn To Install, Run And Delete Applications Inside Docker Containers – Part 4

Scenario:

Host OS: CentOS 7 x86_64
Host IP: 192.168.1.188
RAM: 4GB memory,
Network Port: 1GB/s
HDD: 1000GB of disk space.
Pre-Build Docker Image: centos-apache
DockerHUB Account: [email protected]


Note: If you are a SUDO user then prefix every command with sudo, like #sudo ifconfig

As per scenario, we have Pre-Build Docker Image centos-apache (Build in Part 4). Follow the following steps

Step 1: Login Docker HUB Account

To do this you need to login into your Docker HUB account so go to https://hub.docker.com/ and log in with your credentials and create your repository. The repository is the same place where your image will be stored for public access.

docker login

Step 2 − Crete Repository

After Logging in click on the button “Create Repository” and create a repository with the name “my_repo” (You may name according to you) and while creating this repository make sure you that the repository is publically visible/accessible.

Create Repo
After Repository is created you will get a PULL command for this repository so note it for future reference

Step 4 − Docker Login Via Terminal

Now login into your Docker account via terminal. The Docker login command will prompt you for the username and password to the Docker Hub repository. After fulfilling security formalities.



Step 5: Tag Your Docker Image

Now our first task after logging into Docker HUB via terminal is to tag our new Docker Image (centos-apache) to the newly created Docker HUB repository. So in the terminal of Docker Host use the following Tag command

Syntax: Docker tag imageID Repo_Name

Where ImageID is the ImageID which needs to be tagged to the repository and Repo_Name is the repository name to which the ImageID needs to be tagged. After Tagging you will see your Tag got the change like below.

Step 6: Push Image On Docker HUB

We have successfully tagged our newly created image and we will after this now we can push the image to the Docker Hub repository. For doing this we need to hit a simple command.

Syntax: docker push Repo_Name

Repo_Name is the repository name which needs to be pushed to the Docker Hub.

Step 7: Verify Your Work

Now go to your Docker HUB Account page and go to your repository tab you will be able to see the same tag you just created.

Create Repo Created Under TAG

Step 8: Pull Your Image

Now you can test your repository with pulling the image but before that, you need to delete your images (centos-apace) from the local Docker Host system so follow the group of command.

Now let’s pull your image from the Docker Hub repository with PULL command.

I hope this was helpful. Next Article for creating DockerFile Coming Soon

Part 1: What Is Docker And Concept Of Containers With Virtualization?
Part 2: How To Install Docker On CentOS/RHEL 6/7? And Learn Docker HUB Registration
Part 3A: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 A
Part 3B: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 B
Part 4: Learn To Install, Run And Delete Applications Inside Docker Containers – Part 4


Kapendra
Love to write technical stuff with personal experience as I am working as a Sr. Linux Admin. and every day is a learning day and Trust me being tech geek is really cool.
http://kapendra.com

Leave a Reply