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:

  • How do i get postgres data to persist using docker-compose
  • Docker - Can't access MySQL CLI in container
  • Dockerize MySQL with database and tables
  • How to run Consul on docker with initial key-value pair data?
  • Why can't composer find a composer.json file inside my Docker container?
  • permission issue with docker under windows
    • it works in the same RUN with && ls
    • it does not work in another RUN

    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
     ---> 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?

  • build from docker image using environment variable
  • Cannot get boot2docker port forwarding to work on docker mac os X
  • How to remove entrypoint from parent Image on Dockerfile
  • Anyway to specify a different user to the host machine for docker volume?
  • How to make a container visible to the outside network, and handle I.P addresses in production
  • Dockerfile: RUN command with special parameters
  • One Solution collect form web for “Dockerfile unexpected behaviour between RUN commands”

    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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.