DotNet Developping a Blazor App running in a docker container
Overview
Using DockerFile
Create an empty Text file named “dockerfile”.
|
|
To build the project and create the docker image :
docker build -t blazor-myproject .
The image will expect the Blazor app to run on port 8080. To link to the current machine :
docker run --name myproject -p 8080:8080 -d blazor-myproject
to run the app, open your favorite browser with this address : http://localhost:8080/
.
To stop and cleanup:
docker container stop myproject
docker container prune
Remark : To reduce the size of the container, I’ve used the following image as base : docker pull mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled
Size went down from 210 Mb to 112 Mb.