Create Docker Image using VS Code and Push to Azure Container Registry or Docker Hub

April 25, 2020 ,

Create Docker Image using VS Code and Push to Azure Container Registry or Docker Hub

This post demonstrates how to dockerized .Net Core Application and push the image to Azure Registry or Docker Hub using the VS Code. Below is the structure of the project that will be used to show the demo. If you want to know how to add a docker file in the project then click here.

You can download the DockerFile code from below and change it as per your project name.


Build Docker Image

1. To build a Docker image, open command prompt, and navigate to the project folder. Below command creates a docker image of your application named demoimage.

docker build -t demoimage .



2. You can see the docker image has created with tag latest.

docker images

3.  Verify the application is running fine within the container. Use the docker run command to run the application as a container. 

docker run -d -p 8081:80 myapp demoimage

4. Open web browser application on port number 8081 and you can see your application is running in the container locally.


Push Image to Azure Container Registry

1.  I have already created an Azure container registry. You can follow the instruction here to create it if you have not created yet. First, you have to log in to your Azure registry. Use docker login command with your login server name of Azure Container Registry and provide the username and password. You can find username and password under the 'Access Key' tab of registry on the Azure portal. 

docker login

2. You have to tag your image with your registry name.

docker tag demoimage

3. Now you are ready to push the image to the registry. Run below command


4. Switch to Azure portal and you can see the image in  Azure Container  Registry.


Push Image to Docker Hub 

1. Log in to Docker Hub using your Docker Hub credential.

docker login

2. Tag the image as per the docker hub registry.

docker tag demoimage/demoimage:1

3. Push the image. 

docker push sakaldeep/demoimage:1

4. Verify on Docker Hub.


Video demonstration

The next post will demonstrate how to run this image/application on Azure Kubernetes Service (AKS). I hope you enjoyed the post and it gave you fair information to start with. Please visit for more posts.