Ticket #14920 (new defect)
VboxSF volumes mounted in Docker containers do not update file contents
|Reported by:||doozr||Owned by:|
|Host type:||Mac OS X|
When using vboxsf to share a folder to a VM and that folder is mounted as a volume in a container, the contents of the files are inconsistent depending which program is used to view it. Some programs see the file contents as they were when the volume was mounted, and other see the current file contents.
List the steps to reproduce the issue:
- Mount vboxfs share as a volume in a container
- Edit a file in the volume outside the container
- Observe that some processes in the container see different content to others
Describe the results you received:
Some processes (e.g. python, cat) always see the files as if they had not been edited, but others (e.g. vi, less) always see the current version.
Describe the results you expected:
All processes see the latest version of the files.
Provide additional info you think is important:
Worked example using Docker 1.9.1
Install VirtualBox 5.0.4 and build a VM with Ubuntu 14.04 x64. This bug has also been reproduced with CentOS 7.1 on the VM. The test hosts were Mac OS X 10.11.1 El Capitan and Ubuntu 14.04.
Create a Dockerfile as follows
FROM alpine:3.2 RUN apk add --update python ENTRYPOINT ["sh", "-c"] CMD ["while true; do sleep 10; done"]
Build the image
$ docker build -t testimage .
Mount a directory via into a VirtualBox VM using vboxfs containing a single file, test.py:
$ ls /path/to/mount test.py
Run a container, mounting the shared folder:
$ docker run -d -v /path/to/mount:/files testimage a7741514db36343c7f9df7f94685555a75072e6eb3c9de72ddec983f050ec401
Exec a shell on the container and run the python script, and cat its contents:
$ docker exec -it a7741514db36 sh # cd /files # python test.py HELLO # cat test.py print "HELLO" # less test.py (contents are: print "HELLO") # vi test.py (contents are: print "HELLO")
Edit the file on the host machine, changing HELLO to GOODBYE. Then use docker exec again:
$ docker exec -it a7741514db36 sh # cd /files # python test.py HELLO # cat test.py print "HELLO" # less test.py (contents are: print "GOODBYE") # vi test.py (contents are: print "GOODBYE")
As demonstrated, the python and cat executables still see the original contents of the file, but the less and vi executables see the new contents.
One final demonstration; edit the file inside the container using vi, then execute it with python:
# vi /files/test.py (change GOODBYE to TESTING) # python /files/test.py HELLO # cat /files/test.py print "HELLO" # less /files/test.py (contents are: print "TESTING")
Python again executes the original contents of the file, and cat sees the same. Vi and less see, again, the edited files.
$ docker --version Docker version 1.9.1, build a34a1d5