-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bind-mounted single files don't stay in sync after inode of file changes on host #6011
Comments
That's expected. What happens with
We could add a warning to the docs, but there is no way to "fix" this. |
What @jpetazzo said. @tomfotherby you could bind mount the directory above, and then Not perfect I agree. |
Respectfully, that might be expected by you, but it was not expected by me 😕 . Bear in mind I am more "dev" than "ops" and had to Google what a inode was while debugging and writing up the reproducible steps! I agree adding a warning in the docs would be absolutely great to avoid future confusion. The current document (https://docs.docker.com/userguide/dockervolumes/) doesn't really mention single-file mounts so maybe they are not recommended anyway? @tiborvass - thanks for the useful suggestion. As an aside, my use-case for bind-mounting a single file wasn't very smart. I found a better way to modify a file at run time from the host is to expose it as a volume and then run a adhoc docker command that uses |
Hi Tom, Yes, sorry, I didn't mean to dismiss your remark; I was merely trying to explain the "logic" (mark the quotes :D) behind it. Technically, it might be possible to poll the bind-mount sources and issue a warning when their inode number changes. That would actually be pretty easy, and the resource usage would be negligible. However, I wonder (assuming that we would implement that) where such a warning should show up? |
I wanted to test this comment. First, I tested with a folder:
Second, I tested with a file
OK - this is better!
So I think in the latest version of docker they made some changes and now you get a error so you can't accidentally "break" the bind-mounting. Cool, closing ticket. |
From docker v 0.10.0 changelog:
When I bind-mount a single file into a container, the file does not stay in-sync between the host and the container.
To reproduce:
echo $(date) > /tmp/test
ls -i /tmp/test
docker run -it -v /tmp/test:/tmp/test ubuntu:trusty /bin/bash
echo $(date) >> /tmp/test
cat /tmp/test
and you will see the change. So far so good.sed --in-place "s/2014/CHANGED/g" /tmp/test
ls -i /tmp/test
cat /tmp/test
and you will not see the change. 👎Use-case: I have ngnix containerised with only the
nginx.conf
file bind-mounted to the host. I want to change the file on the host (e.g. change the proxy IP address), then send the nginx process a SIGHUP signal (kill -HUP
) to reload the config. This doesn't work because when I change thenginx.conf
file on the host, the container cant see the changes. Hence I'm opening this issue.My host info (asked for in guidelines for contributing):
uname -a
:Linux Pochama 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: