Member-only story

Optimizing Docker Images is More Than Just a One-and-Done Thing in .NET.

I still remember my first time working with Docker in .NET. It felt like magic — wrapping up an entire application in a neat little container and running it anywhere.

Sukhpinder Singh | C# .Net
Write A Catalyst
Published in
4 min readFeb 15, 2025

Created by Author using Canva

But that magic wore off quickly when our CI/CD pipeline started to slow down, our cloud bills crept up, and debugging issues inside containers became a nightmare. Optimizing Docker images isn’t just a one-time fix; it’s an ongoing process that requires careful attention to detail, especially when working with .NET applications.

The Initial Excitement — and the First Signs of Trouble

Like many engineers, I started with a basic Dockerfile that looked something like this:

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o /app
FROM base AS final
COPY --from=build /app .
ENTRYPOINT ["dotnet", "MyApp.dll"]

At first glance, everything seemed fine. The image worked as expected, and deployments were smooth. But soon, I noticed that our…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Write A Catalyst
Write A Catalyst

Published in Write A Catalyst

Write A Catalyst and Build it into Existence.

Sukhpinder Singh | C# .Net
Sukhpinder Singh | C# .Net

Written by Sukhpinder Singh | C# .Net

.Net developer 👨‍💻 who's 100% convinced my bugs are funnier than yours. 🐛💥 #BugLife Pubs: https://medium.com/c-sharp-programming

Responses (2)

What are your thoughts?