Prerequisites
Docker Desktop
Visual Studio Code
Step 1: Creating .Net Core App and Publish
dotnet new webapi
dotnet build
dotnet run
dotnet publish -c release -o /app
Step 2: Creating Docker file
The Dockerfile file is used by the docker build
command to create a container image
FROM microsoft/dotnet:2.2-aspnetcore-runtime
WORKDIR /app
COPY /app /app
ENTRYPOINT ["dotnet", ".dll"]
Step 3: Docker Ignore
Docker ignore will improvise docker build performance based on eliminating content defined on .dockerignore
bin/
obj/
Step 4: Build Docker Container
The docker build command builds Docker images from a Dockerfile and a “context”.
docker build -t
Step 5: Running the Docker Image
The docker run command first creates a writeable container layer over the specified image.
docker run -p 8080:80
Step 6: Test Application
http://localhost:8080/api/values
Resource
Github: https://github.com/deepaksvjois/dotnetcore_docker
One thought on “Dockerize an ASP.NET Core application”