Pushing a custom image to DockeHub and creating container on Azure using an image

How to push a custom image on DockerHub and create container on Azure using a Docker image

Category: Docker Tags: Container, Cloud, Azure, Docker

    In last article, we learned how to run a python script on Docker container and printed “hello world”. In this article, we will learn how we can push this custom image to DockerHub and create a container on Azure by pulling same image from DockerHub. Benefit of creating custom images on DockerHub is we can deploy it on cloud by just giving name of repository and image name and it will deploy our code with platform required to run it.

We learned some command in previous article to build and run the container. Once we are successfully able to build image it will be saved on local machine with a unique image id. We will have to push it to DockerHub.

Pushing custom image to DockerHub

Step 1: Finding Image Id

Use command given below which will give all images on local machine:

docker images

Docker images list command
Fig 1: Docker images list command

Step 2: Login to DockerHub

SignUp on DockerHub and create a username, public repositories are free create. Run the command to login:

docker login --username=myusername

It will prompt for password, below I have logged into my account

Login to DockerHub command
Fig 2: Login to DockerHub command

Step 3: Tag your image with repository name and image name

Run below command, image id we can see in step 1:

docker tag ce549b4e9ee3 nikhiljsh22/helloworldapp:helloworldapp

Above format is: ImageID username/repositoryname:imagename

Step 4: Push the image

Use below command to push the image

docker push nikhiljsh22/helloworldapp

It will take some time, once it is done we can see image on DockerHub in our account and we can pull it from any other system. Since we created it on public repository anyone can download this image.

Creating container on Azure from DockerHub image

Now let’s create container from this image on Azure. Login to Azure and go to Create a resource -> containers -> Container Instances. Give container name and image name as shown below. I have this image on public repository you can use this image “nikhiljsh22/helloworldapp:helloworldapp” without creating your own.

Creating container on Azure
Fig 3: Creating container on Azure

Select subscription, resource group and click OK

Creating container on Azure
Fig 4: Creating container on Azure

And change configuration if you want to and click OK

Creating container on Azure
Fig 5: Creating container on Azure

Once validation is passed you can hit OK. I will take some time to create container. Once it is successfully created we can go to the container from All resources -> MyContainerName -> Containers -> Logs.

Refreshing container on azure
Fig 6: Refreshing container on Azure


Once we go to logs and click refresh container restarts and we can see “hello world” in logs which is printed by our python script.

Like 0 People
Last modified on 20 May 2019
Nikhil Joshi

Nikhil Joshi
Ceo & Founder at Dotnetlovers
Atricles: 136
Questions: 12
Given Best Solutions: 12 *


No Comments Yet

You are not loggedin, please login or signup to add comments:

Existing User

Login via:

New User