How to Dockerize Sample .NET Core API/Web Application
I always use docker to run or publish my applications. It makes life so easy to build, publish and update applications on servers.
Example files
I uploaded all example files in to my GitHub Repository.
Sample Application
Use sample code to create .NET Core Web Application
Docker Ignore
To build an application we only need Source Code, let's ignore unnecessary files like ./obj or ./bin.
Dockerfile
We will use Microsoft official SDK and Runtime Docker Containers to Build and Run .NET Core Application. This will make Application Container lighter since it will not include Source Code, only artifacts and libraries etc. Please replace Application name if needed.
Build
Build Docker Container from Dockerfile file in current directory:
docker build -t web-application .
Execute
Run built web-application container in detached mode with api name and Port 80 accessible to localhost:
docker run -d -p 80:80 --name api web-application
Test
To test if Application runs, open http://localhost URL in a Web Browser.
Stop and Remove Container
docker stop api && docker rm api
Congratulations @tomas-petrauskas! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Vote for @Steemitboard as a witness to get one more award and increased upvotes!