General docker questions for a newbie

Hi

I am using Docker, just learning it. I had a few general questions:

Take these commands:

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY [“Src/Web/Api/Api.csproj”, “Src/Web/Api/”]

  1. Does WORKDIR /src make this folder in the root of the Docker image?

  2. The copy command copies the csproj into a folder of “Src/Web/Api” on the remote container?

Thanks

Yes, on both points.

By using “AS build”, it appears if you are doing a multi-stage build. The /src will not be created in the image of the second stage. That is the very purpose of muti-stage builds - you can throw into the build stage file system whatever mess you like, and in the second stage pick up the nice, tidy build artifacts and copy them into a clean image, leaving the build debris behind. If that is exactly as you intended - fine. If you expect the /src directory to appear even in the final image, you must create it in the second stage as well.