.NET

Docker & Containerization

Dockerfile, docker-compose, multi-stage builds, container optimization, environment configuration

16 pytań z rozmów·
Mid-Level
1

What is the primary role of a Dockerfile in a .NET application?

Odpowiedź

The Dockerfile defines instructions to create a reproducible Docker image containing the .NET application and its dependencies. It specifies the base image, build commands, files to copy, and the execution command. This ensures the application runs identically across all environments.

2

Which base image is recommended for an ASP.NET Core application in production?

Odpowiedź

The mcr.microsoft.com/dotnet/aspnet image is optimized for running ASP.NET Core applications in production. It contains only the necessary .NET runtime, without SDK or build tools, which significantly reduces the final image size and improves security. For building, use mcr.microsoft.com/dotnet/sdk in a multi-stage build.

3

What is a multi-stage build in a .NET Dockerfile?

Odpowiedź

A multi-stage build uses multiple FROM instructions in a Dockerfile to create intermediate images. The first stage uses the SDK image to compile the application, while the final stage uses the lighter runtime image and copies only the compiled binaries. This reduces the final image size by several hundred MB by excluding build tools and source files.

4

Why copy the .csproj file before the rest of the source code in a Dockerfile?

5

Which command builds a Docker image from a Dockerfile?

+13 pytań z rozmów

Opanuj .NET na następną rozmowę

Uzyskaj dostęp do wszystkich pytań, flashcards, testów technicznych, ćwiczeń code review i symulatorów rozmów.

Zacznij za darmo