I have a working docker-compose and Dockerfile but I had to put in what seems like an unnecessary step and I’m hoping someone can explain to me why its necessary and help me understand.
Relevant piece of docker-compose.ylm
build: context: . dockerfile: src/Web/Dockerfile target: build volumes: - C:\repos\Repo\src\Web:/app
The first part of my Dockerfile is:
FROM microsoft/dotnet:2.1-sdk AS build WORKDIR /app
Here I would expect to be working directly in my mounted volume. However, if I simply execute a
RUN dotnet restore
It complains that the .csproj does not exist (the .csproj is in this directory).
It seems that the context setting of ‘.’ from the docker-compose.ylm is overwriting the WORKDIR command in my Dockerfile because to get my file to work I had to update this piece to:
COPY ./src/Web . RUN dotnet restore
Which seems unnecessary and seems like I am copying files over themselves, which does not seem to be occurring.
Can anyone explain this to me? How the mounted volume alias, context setting and WORKDIR play together?