title: Dockerfile: Copy files from parent image
body: <p>I'm building a multistage docker image where we have a base image that will be extended to build the actual final image. However I can't seem to copy files that are coming from the parent image into the child.</p>
  <p><strong>Base image</strong></p>
  <pre><code>FROM debian:10.9-slim AS base
  
  # PHP Version
  ONBUILD ARG PHP_VERSION
  ONBUILD ENV PHP_VERSION=${PHP_VERSION:-7.4}
  
  # More stuff.
  ...
  
  # Copy PHP settings into the image
  COPY ./php/pool.d/*.conf /build-php/pool.d/
  COPY ./php/conf.d/*.ini /build-php/conf.d/
  
  # Onbuild copy the settings to the correct PHP version
  ONBUILD COPY /build-php/pool.d/*.conf /etc/php/${PHP_VERSION}/fpm/pool.d/
  ONBUILD COPY /build-php/conf.d/*.ini /etc/php/${PHP_VERSION}/fpm/conf.d/
  ONBUILD COPY /build-php/conf.d/*.ini /etc/php/${PHP_VERSION}/cli/conf.d/
  </code></pre>
  <p><strong>Specific image</strong></p>
  <pre><code>ARG PHP_VERSION=8.0
  
  FROM abcdef.amazonaws.com/php-base:v1.14.0 AS base
  </code></pre>
  <p>When building the secondary image I get the following error</p>
  <pre><code>$ docker build -t php8.0:base .
  ...
   =&gt; ERROR [7/1] COPY /build-php/pool.d/*.conf /etc/php/8.0/fpm/pool.d/                                                                                                                                   0.0s
  ------
   &gt; [7/1] COPY /build-php/pool.d/*.conf /etc/php/8.0/fpm/pool.d/:
  ------
  lstat /var/lib/docker/tmp/buildkit-mount474178567/build-php/pool.d: no such file or directory
  </code></pre>
  <p>I checked the parent image and the files are copied fine into <code>/build-php</code>. Also when building the child image (with the onbuild copy disabled) the files are present at <code>/build-php</code>. I don't understand why the onbuild copy can't find the files.</p>