egt
egt

Reputation: 185

Dockerfile unexpected behaviour between RUN commands

I have a weird issue trying to execute several RUN commands sequentially.

The goal is to copy a folder. If I list the files in target folder:

Here is the trace:

Step 6 : RUN cp -rf /app/httpd/htdocs/* /opt/rh/httpd24/root/var/www/html/ && ls /opt/rh/httpd24/root/var/www/html/
 ---> Running in 05842445d075
modules
tests
 ---> 05c51d512f60
Removing intermediate container 05842445d075
Step 7 : RUN ls /opt/rh/httpd24/root/var/www/html/
 ---> Running in aa217a8edc37
 ---> 095c9f8ac8e7

Do you have any idea what is going wrong?

Upvotes: 1

Views: 94

Answers (1)

VonC
VonC

Reputation: 1328262

As seen here, that could happen if the Dockerfile declared first a VOLUME.

Any file copied into a VOLUME would be discarded, as each build-step creates a new volume based on the image's content, discarding the volume that was used in the previous build step.

Upvotes: 1

Related Questions