title: COPY . . command in Dockerfile for ASP.NET
body: <p>The Visual Studio tooling for Docker creates a Dockerfile for ASP.NET projects containing a <code>COPY . .</code> command as below:</p>
  
  <pre><code>WORKDIR /src
  COPY *.sln ./
  ...
  COPY . .
  </code></pre>
  
  <p>From what I've read, the <code>&lt;src&gt;</code> parameter is relative to the context, so isn't affected by the <code>WORKDIR /src</code> command. The <code>&lt;dest&gt;</code> however is relative to the <code>WORKDIR</code> so will be pointing at <code>/src</code>. </p>
  
  <p>Is this command just bringing over the remaining files from the root for packaging (docker-compose.yml, .dockerignore, etc.)? If so, then why is this done ahead of the <code>RUN dotnet build...</code> command?</p>
  
  <p>Full Dockerfile below:</p>
  
  <pre><code>FROM microsoft/aspnetcore:2.0 AS base
  WORKDIR /app
  EXPOSE 80
  
  FROM microsoft/aspnetcore-build:2.0 AS build
  WORKDIR /src
  COPY *.sln ./
  COPY MyProject/MyProject.csproj MyProject/
  RUN dotnet restore
  COPY . . # The line mentioned above
  WORKDIR /src/MyProject
  RUN dotnet build -c Release -o /app
  
  FROM build AS publish
  RUN dotnet publish -c Release -o /app
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app .
  ENTRYPOINT ["dotnet", "MyProject.dll"]
  </code></pre>