title: dotnet restore incredibly slow inside docker-compose build
body: <p>I have a .NET Core project that I'm building into a docker image. The Dockerfile looks like this:</p>
  
  <pre><code>FROM mcr.microsoft.com/dotnet/core/sdk:3.0-alpine AS restore
  WORKDIR /tmp/build
  COPY ./*.sln .
  COPY ./*/*.csproj ./
  # Put project files back into their own project directories
  RUN for file in $(ls *.csproj); do mkdir -p ${file%.*}/ &amp;&amp; mv $file ${file%.*}/; done
  RUN dotnet restore
  
  # Copy in the source files
  FROM restore AS build
  WORKDIR /tmp/build
  COPY . .
  RUN dotnet publish -o output MyApp/MyApp.csproj
  
  FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-alpine AS runtime
  WORKDIR /app
  COPY --from=build /tmp/build/output .
  ENTRYPOINT [ "dotnet", "MyApp.dll"]
  </code></pre>
  
  <p>If I <code>cd</code> into the directory and run <code>dotnet restore</code>, the packages are restored very quickly without any problems. But when it hits the <code>RUN dotnet restore</code> line of the build process in Docker, the restore command operates incredibly slowly, sometimes even timing out.</p>
  
  <p>I can only assume this is somehow an issue with Docker's network connection, but I have no idea where to begin. This is on Linux, specifically Deepin.</p>