Azure User Group Nepal
Learn and understand the cloud technology using Microsoft Azure platform
April 25, 2020 ,
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.
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.
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.
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 yourLoginServer.azurecr.io
2. You have to tag your image with your registry name.
docker tag demoimage yourLoginServer.azurecr.io/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.
1. Log in to Docker Hub using your Docker Hub credential.
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.
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 sakaldeep.com.np for more posts.