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
Leave How to Dockerize Sample .NET Core API/Web Application to:
Read more #docker posts
Best Posts From Rasa Govinda das
We have not curated any of tomas-petrauskas's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Rasa Govinda das
- Developers: how much memory do you need?
- Big Sur is out!!! First Impressions?
- Nuckindosh
- SSH/SFTP Authentication with SSH Private Key
- How to Dockerize Sample .NET Core API/Web Application
- How to Install GitVersion on Mac OS X
- How to Install Git Flow on Mac OS X
- Export non-exportable Certificate in Microsoft Windows
- GPS Clock v0.1 - Simple Prototype
- Disable Viber Ads for Mac OS X / Linux
- Undo Git Commit and Commit again