title: Dockerfile COPY does not work with wildcards
body: <p>According to <a href="https://docs.docker.com/engine/reference/builder/#copy" rel="nofollow noreferrer">this documentation</a> the COPY instruction of Dockerfile should work with wildcards. But when I try to build the Dockerfile below on a Windows machine, it throws an &quot;invalid operation&quot; without giving further details.</p>
  <pre><code>FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 AS build
  WORKDIR /app
  
  COPY . ./
  
  RUN dotnet build -c Debug -o out
  RUN dotnet pack ./MyApp -c Debug
  
  FROM mcr.microsoft.com/dotnet/core/runtime:3.1-nanoserver-1809
  WORKDIR /app
  
  COPY --from=build /app/out .
  COPY --from=build /app/MyApp/bin/Debug/*.nupkg .
  
  ENTRYPOINT [&quot;dotnet&quot;, &quot;MyApp.dll&quot;]
  </code></pre>
  <p>The app in question is a simple Hello World which I wanted to use to test something entirely unrealted, but this really bothers me. I know this has been brought up in a lot of questions on this site, but non of them seem to give an actual answer why this function, that is statet in the documentation, does not work. Instead the answers either say &quot;The documentation says that it works&quot;, &quot;[insert weird workaround]&quot; or &quot;It was caused by some other bug&quot;. I also didn't see that specific error beeing mentioned.</p>
  <p><strong>Update</strong></p>
  <p>I've narrowed down the problem to copying files between two images in a multi-stage build. Consider the following Dockerfile:</p>
  <pre><code>FROM mcr.microsoft.com/dotnet/core/sdk:3.1-nanoserver-1809 AS build
  
  COPY *.txt ./
  
  FROM mcr.microsoft.com/dotnet/core/runtime:3.1-nanoserver-1809
  
  COPY --from=build *.txt ./
  </code></pre>
  <p>If you execute <em>docker build</em>, the first step works, provided you have a .txt file parallel to your Dockerfile. The second step however, fails with an invalid function error. If you replace the asterix with the name of the .txt file, it works.</p>