Using containers fo r new (“green - field”) projects Containers are commonly used in conjunction with a microservices architecture, although they can
also be used to containerize web apps or services that follow any architectural pattern. You can use
.NET Framework on Windows Containers, but the modularity and lightweight nature of .NET 7 makes
it perfect for containers and microservices architectures. When you create and deploy a container, its
image is far smaller with .NET 7 than with .NET Framework.
Create and deploy microservices on containers You could use the traditional .NET Framework for building microservices-based applications (without
containers) by using plain processes. That way, because the .NET Framework is already installed and
shared across processes, processes are light and fast to start. However, if you are using containers, the
image for the traditional .NET Framework is also based on Windows Server Core and that makes it too
heavy for a microservices-on-containers approach. However, teams have been looking for
opportunities to improve the experience for .NET Framework users as well. Recently, size of the
Windows Server Core container images have been reduced to >40% smaller
.
On the other hand, .NET 7 is the best candidate if you’re embracing a microservices
-oriented system
that is based on containers because .NET 7 is lightweight. In addition, its related container images, for
either Linux or Windows Nano Server, are lean and small, making containers light and fast to start.
A microservice is meant to be as small as possible: to be light when spinning up, to have a small
footprint, to have a small Bounded Context (check DDD,
Domain-Driven Design
), to represent a small
area of concerns, and to be able to start and stop fast. For those requirements, you will want to use
small and fast-to-instantiate container images like the .NET 7 container image.
A microservices architecture also allows you to mix technologies across a service boundary. This
approach enables a gradual migration to .NET 7 for new microservices that work in conjunction with
other microservices or with services developed with Node.js, Python, Java, GoLang, or other
technologies.