Since lesson 2.9.5, the Kladde has run once in Azure, and you didn't write a single line of Docker for it: dotnet publish -t:PublishContainer built the image. That was the right way: success first, depth second. In this lesson and the three that follow, you
look under the hood. You write the recipe for the image yourself, a Dockerfile, and understand along the way what the SDK decided
for you. At the end of the lesson, Docker builds the Kladde from your own Dockerfile, and a change in the code rebuilds in seconds,
without downloading all the packages again.
Why a Dockerfile of your own
The way from lesson 2.9.2 stays good. You need a Dockerfile as soon as one of these questions is answered with yes:
- Does something have to run during the build that isn't
dotnet? An operating system package, a tool for generating files, a step that only a command line can do. - Does someone else build the image? A build service that only knows Dockerfiles, such as
az acr buildin lesson 2.9.8, or a team without .NET. - Do you want to make every decision yourself? Base image, user, layers and what's in the image.
And even if you stay with dotnet publish: once you've written a Dockerfile, you read every image differently. That's exactly what this
is about.