A Dockerfile instruction is a directive written as INSTRUCTION arguments that controls image construction. Dockerfiles may contain comments and instructions, and must begin with FROM. FROM selects a base image, which Docker modifies into a new immutable image. section 13.3.1
A practical Dockerfile combines instructions that:
- Copy application files with COPY and select the container working directory with WORKDIR. section 13.3.1
- Publish network metadata with EXPOSE and define startup behavior with ENTRYPOINT. section 13.3.1
- Build applications in separate stages with RUN and COPY --from, producing a smaller runtime image. section 13.3.1
Listing 13.2 Dockerfile for AsciiArtSvc
# Use the official .NET 6 container FROM mcr.microsoft.com/dotnet/sdk:6.0 # Copy files from the current folder on your machine to # the /src folder in the container COPY . /src # Set working directory in the container WORKDIR /src # Expose HTTP port from "docker" launch profile EXPOSE 5101 # Run the application when the container is started ENTRYPOINT ["dotnet", "run", "--launch-profile", "docker"]
A complete Dockerfile shows base-image selection, file copying, working-directory configuration, port exposure, and application startup. section 13.3.1
Multi-stage image construction
A build stage runs dotnet publish into /publish. A second ASP.NET runtime stage copies that output, exposes port 80, and starts AsciiArtSvc.dll with ENTRYPOINT. section 13.3.1


