title: Why Docker COPY doesn't change file permissions? (--chmod)
body: <p>Given this <code>Dockerfile</code>:</p>
  <pre><code>FROM docker.io/alpine
  
  RUN mkdir test
  
  # RUN umask 0022
  COPY README /test/README
  COPY --chmod=777 README /test/README-777
  COPY --chmod=755 README /test/README-755
  
  COPY FORALL /test/FORALL
  COPY --chmod=777 FORALL /test/FORALL-777
  COPY --chmod=755 FORALL /test/FORALL-755
  
  RUN ls -la /test
  </code></pre>
  <p>I'd expect to have the <code>read</code>, <code>write</code>, <code>execute</code> permissions be set accordingly by Docker during the build process (<code>docker build ./</code>).</p>
  <p>But the last command returns</p>
  <pre><code>total 8
  drwxr-xr-x    1 root     root          4096 Jun  9 19:20 .
  drwxr-xr-x    1 root     root          4096 Jun  9 19:20 ..
  -rwxrwxrwx    1 root     root             0 Jun  9 19:19 FORALL
  -rwxrwxrwx    1 root     root             0 Jun  9 19:19 FORALL-755
  -rwxrwxrwx    1 root     root             0 Jun  9 19:19 FORALL-777
  -rw-rw-r--    1 root     root             0 Jun  9 19:19 README
  -rw-rw-r--    1 root     root             0 Jun  9 19:19 README-755
  -rw-rw-r--    1 root     root             0 Jun  9 19:19 README-777
  </code></pre>
  <p><strong>No file permission was changed, and no error was raised</strong>.</p>
  <p><em>Why doesn't it work?</em><br />
  <em>How to fix this?</em></p>