
Docker & Containerization
Dockerfile, docker-compose, multi-stage builds, container optimization, environment configuration
1What is the primary role of a Dockerfile in a .NET application?
What is the primary role of a Dockerfile in a .NET application?
답변
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.
2Which base image is recommended for an ASP.NET Core application in production?
Which base image is recommended for an ASP.NET Core application in production?
답변
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.
3What is a multi-stage build in a .NET Dockerfile?
What is a multi-stage build in a .NET Dockerfile?
답변
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.
Why copy the .csproj file before the rest of the source code in a Dockerfile?
Which command builds a Docker image from a Dockerfile?
+13 면접 질문