title: chown not working when coping a file in a dockerfile
body: <p>I'm running docker engine on windows and am trying to add my own file to the image. Problem is that when I copy the file its ownership is always root:root but it needs to be heartbeat:heartbeat (exisitng user on image). Mounting a single file with the -v parameter und docker run doesn't seam to be possible on windows atm. Thats why I tried to create my own image with a docker file:</p>
  <pre><code>FROM docker.elastic.co/beats/heartbeat:7.16.3
  USER root
  COPY --chown=heartbeat:heartbeat yml/heartbeat.yml /usr/share/heartbeat/heartbeat.yml
  RUN chown -R heartbeat:heartbeat /usr/share/heartbeat
  </code></pre>
  <p>The --chown parameter behind the coping does nothing. It is still root when I check and the RUN chown command results in a error. Here the output:</p>
  <pre><code>docker image build ./ -t custom/heartbeat:7.16.3
  Sending build context to Docker daemon  10.75kB
  Step 1/4 : FROM docker.elastic.co/beats/heartbeat:7.16.3
   ---&gt; b64ad4b42006
  Step 2/4 : USER root
   ---&gt; Using cache
   ---&gt; 922a9121e51b
  Step 3/4 : COPY --chown=heartbeat:heartbeat yml/heartbeat.yml /usr/share/heartbeat/heartbeat.yml
   ---&gt; Using cache
   ---&gt; f30eb4934dca
  Step 4/4 : RUN chown -R heartbeat:heartbeat /usr/share/heartbeat
   ---&gt; [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (windows/amd64) and no specific platform was requested
   ---&gt; Running in 2ae3bfdd5422
  The command '/bin/sh -c chown -R heartbeat:heartbeat /usr/share/heartbeat' returned a non-zero code: 4294967295: failed to shutdown container: container 2ae3bfdd5422e81461a14896db0908e4cd67af1a6f99c629abff1e588f62fc32 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110): subsequent terminate failed container 2ae3bfdd5422e81461a14896db0908e4cd67af1a6f99c629abff1e588f62fc32 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110)
  </code></pre>
  <p>All help is welcome...</p>
  <p>Running with --platform:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>PS C:\SynteticMonitoring&gt; docker image build ./ -t custom/heartbeat:7.16.3
  Sending build context to Docker daemon  9.728kB
  Step 1/4 : FROM --platform=linux/amd64 docker.elastic.co/beats/heartbeat:7.16.3
   ---&gt; b64ad4b42006
  Step 2/4 : USER root
   ---&gt; Using cache
   ---&gt; 922a9121e51b
  Step 3/4 : COPY --chown=heartbeat:heartbeat yml/heartbeat.yml /usr/share/heartbeat/heartbeat.yml
   ---&gt; Using cache
   ---&gt; f30eb4934dca
  Step 4/4 : RUN chmod +r /usr/share/heartbeat/heartbeat.yml
   ---&gt; Using cache
   ---&gt; e9a075d2ab53
  Successfully built e9a075d2ab53
  Successfully tagged custom/heartbeat:7.16.3
  PS C:\SynteticMonitoring&gt; docker run --interactive --tty --entrypoint /bin/sh custom/heartbeat:7.16.3
  sh-4.2# ls -l
  total 106916
  -rw-r--r-- 1 root root     13675 Jan  7 00:47 LICENSE.txt
  -rw-r--r-- 1 root root   1964303 Jan  7 00:47 NOTICE.txt
  -rw-r--r-- 1 root root       851 Jan  7 00:47 README.md
  drwxrwxr-x 2 root root      4096 Jan  7 00:48 data
  -rw-r--r-- 1 root root    374197 Jan  7 00:47 fields.yml
  -rwxr-xr-x 1 root root 107027952 Jan  7 00:47 heartbeat
  -rw-r--r-- 1 root root     69196 Jan  7 00:47 heartbeat.reference.yml
  -rw-rw-rw- 1 root root      1631 Jan 26 06:49 heartbeat.yml
  drwxr-xr-x 2 root root      4096 Jan  7 00:47 kibana
  drwxrwxr-x 2 root root      4096 Jan  7 00:48 logs
  drwxr-xr-x 2 root root      4096 Jan  7 00:47 monitors.d
  sh-4.2# pwd
  /usr/share/heartbeat</code></pre>
  </div>
  </div>
  </p>