Build Docker Image of .NET Core Application using Visual Studio 2019

Author: Sakaldeep Yadav

April 10, 2020

Deploying Kubernetes with sample image from Docker Hub or any other registry is straight forward and easy but when we need to build the image of your own application for Kubernetes then we start looking here and there if you are from the non-development background and new to the container world like me :).

In this post, I will show how to create a docker image of your .Net application using Visual Studio 2019. Here, I am assuming you are familiar with basic Docker command and docker is already installed in your machine. Docker image is created based on the DockerFile. If you are good at creating DockerFile then you don't need to use Visual Studio, you can use any command-line tool. If you are a beginner then its visual studio is a good place to start.  I am here using Visual Studio to generate DockerFile rather than writing DockerFile.

 1. Below is the sample.NetCore application and it's running fine locally. We want to run this application in Docker as a container. There is no DockerFile yet.


2. To add/generate DockerFile for the application.

3. DockerFIle has added and content of it as below.


4. Press Ctrl+F5 to build the docker image. You can see the build has completed an application is running in docker. Verify it with below docker command.


5. We can also check this with Docker command - docker ps.


6. Below is the video demonstration of creating  Docker Image and running the application locally. 

I hope you enjoyed the post and it gave you fair information to start with. Please visit sakaldeep.com.np for more posts. 

Total visits : 228