127
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
A Dockerfile like this will work. However, you can substantially optimize your images, especially your
production images.
In the container and
microservices model, you are constantly starting containers. The typical way of
using containers does not
restart a sleeping container, because the container is disposable.
Orchestrators (like Kubernetes and Azure Service Fabric) create new instances of images. What this
means is that you would need to optimize by precompiling the application when it
is built so the
instantiation process will be faster. When the container is started, it should be ready to run. Don’t
restore and compile at run time using the
dotnet restore
and
dotnet build
CLI commands as you
may see in blog posts about .NET and Docker.
The .NET team has been doing important work to make .NET and ASP.NET Core a container-optimized
framework. Not only is .NET a lightweight framework with a small memory footprint;
the team has
focused on optimized Docker images for three main scenarios and published them in the Docker Hub
registry at
dotnet/
, beginning with version 2.1:
1.
Dostları ilə paylaş: