Red Hat Bugzilla – Bug 1267357
Dockerfile VOLUME instruction masks directory changes
Last modified: 2015-10-29 11:59:16 EDT
Created attachment 1078452 [details]
Dockerfile that reproduces the problem
Description of problem:
Modifying a file in a directory AFTER using the VOLUME instruction causes all further changes to that directory to be ignored/not tracked. Moving the VOLUME instruction after the changes works properly.
Version-Release number of selected component (if applicable):
docker-1.7.1-115.el7.x86_64 (RHEL AH 7.1.5
Steps to Reproduce:
1. Stick Dockerfile into an empty directory
2. docker build -t test context
cat: /root/foobar: No such file or directory
Expecting contents of directory referenced in VOLUME instruction, to be tracked just like any other file changes, irrespective of VOLUME instruction order.
e.g. move the VOLUME instruction one line down (below echo, above cat), rebuild and it will work as expected.
Unfortunately this is how it's implemented in Docker. It's stated here https://docs.docker.com/reference/builder/#volume.
The content is not going to be modified because it's going to the volume and not the container fs. Volumes do not get committed to an image. And each new RUN is a new container with a new volume.