Docker Image Building

Containerize your .NET apps

Posted by Rodrigo Castro on February 14, 2025

Docker lets you package your .NET apps and run them in any environment.

🏗️ Basic Dockerfile

1
2
3
4
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "MyApp.dll"]
  • Place this file as Dockerfile at your project root.

🚀 Build and Run

1
2
docker build -t myapp .
docker run -p 8080:80 myapp

🛠️ Tips

  • Use multi-stage builds for smaller images.
  • Store configuration in environment variables.

🌍 Deploy Anywhere

  • Azure, AWS, on-premises, or any Docker-compatible platform.

Next: Automated unit testing!