Dockerize your .NET Core project

As one of the .NET developers, traditionally we build and publish our code then host our web applications on IIS. Now, there's an alternative - Docker.

What's Docker?

You can find the answer at https://en.wikipedia.org/wiki/Docker_(software)


This post is going to introduce how to use Docker to create an image of a .NET Core webapi project. And later on, we are going to push this image to Docker Hub.

If you don't want to read the content but just want to find some source code sample you can go straight to get it here https://github.com/sskset/dockerize-dotnet-core.

Prerequisites:

Create a .NET Core 2.2 webapi project

Open it in Visual Studio Code


Start it up


Open Browser to test it


Publish


Add Dockerfile



Docker build image

docker run -t sskset/dockerize-dotnet-core .

Push image to Docker Hub


Open hub.docker.com to view your image

As it's public, you can also view it by searching image name - sskset/dockerize-dotnet-core


Done

That's pretty much it. I'll introduce how to use it in next post.

This post's source code can be found at https://github.com/sskset/dockerize-dotnet-core

Comments

Popular posts from this blog