liveBook · Manning

From instruction

As explained in .NET in Action, Second Edition

The FROM instruction selects a base image and begins a build stage in a Dockerfile.

The FROM instruction must begin a Dockerfile and selects the base image to modify. Because images are immutable, each build starts from a base and saves changes into a new image. section 13.3.1

A Dockerfile may contain multiple FROM instructions for separate build stages, allowing published application output to move from an SDK image into a smaller runtime image. section 13.3.1

Selecting a .NET base image

FROM mcr.microsoft.com/dotnet/sdk:6.0 selects the official .NET 6 SDK container. Subsequent COPY, WORKDIR, EXPOSE, and ENTRYPOINT instructions modify that starting 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"]

Inspect the complete Dockerfile to see how FROM establishes the base for copying source files and configuring application startup. section 13.3.1

How .NET in Action, Second Edition covers it

How deep it goes
Explains base-image selection, immutability, and multiple stages, then demonstrates SDK-to-runtime image transfer.
Examples
Uses .NET 6 SDK and ASP.NET images in single-stage and named multi-stage Dockerfiles.
What it assumes
Assumes Docker Desktop and command-line Docker work, while explaining Dockerfile instruction syntax and immutable-image modification.
What you can do after
Build it from scratch by selecting .NET base images in a Dockerfile and producing tagged images with docker build.
How it connects
Connects Dockerfile instructions with base images, container images, Docker build, and multi-stage builds.

Also explained in

Compare how 3 books explain from instruction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.