December 2019
Intermediate to advanced
510 pages
11h 33m
English
Let's apply the concept of a multi-stage build to the previously defined Docker image. Multi-stage builds are a new feature that requires Docker 17.05 or higher. Multi-stage builds are useful for anyone who has struggled to optimize Dockerfiles while keeping them easy to read and maintain.
Let's explore how it is possible to apply the multi-stage build process by taking a look at the catalog service Dockerfile:
FROM microsoft/dotnetCOPY . /appWORKDIR /appRUN dotnet restoreRUN dotnet buildRUN chmod +x ./entrypoint.shCMD /bin/bash ./entrypoint.sh
The previously defined file can be changed in the following way:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS baseWORKDIR /appFROM mcr.microsoft.com/
Read now
Unlock full access