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
File mount does not update with changes from host #15793
Comments
Can you provide output of |
To check if the data was up-to date, I did this : I'm running all these containers in on a linux host. Here is the Dockerfile for the nginx container. It
Here is the
Not sure whether the |
I bet I know what's happening here... If you are using some editor like vim, when you save the file it does not save the file directly, rather it creates a new file and copies it into place. This is a known limitation of file-mounts and is not fixable. Does this accurately describe the issue? |
I just restarted my container, used nano to do the editing and it works! Thanks a lot. Feel free to close this, I am not sure if it should be considered as a bug or not. |
Closing, it's not really a bug, just how linux works unfortunately. |
Is there any workaround for this? I don't think using nano is really viable in a project larger than 1 file. I'm using Sublime Text and I'd like to keep it that way. |
After reading this, I guess if I type |
@OscarOrSomething Mount a dir instead of a file. |
Are you sure ? That's really strange… @cpuguy83 : maybe he is mounting a file and a dir (dunno if this is possible). |
@greg0ire I try use |
I don't know, but I'm interested in your results.
|
I made some tests @greg0ire, and this is the result. With or without Thank you guys. |
And thank you for your feedback, it is interesting. |
This issue has come back for me a few days later. In both Sublime Text (3, with atomic save false) and Atom, The inode doesn't change at all. I assume this is an issue with the editors? |
It doesn't seem to be an editor issue (at least on atom) The files do update but only after around a minute which is better but still incredibly annoying. |
@OscarOrSomething I suspect that's because VirtualBox shared folders don't support inotify; https://www.virtualbox.org/ticket/10660 |
@thaJeztah I'm not using Virtual box. Arch Linux Docker version 1.9.1, build a34a1d5-dirty |
@OscarOrSomething oh, ignore my comment then 👍 (I know many people ran into that when using boot2docker/VirtualBox) |
Turning off sendfile off for Nginx solved this issue for me. Just put this in your vhost conf:
The equivalent for Apache it is "EnableSendfile off". |
@Sebwebdev : thanks, but I think you are a bit off topic : obviously, you are not mounting the file you are providing with your vhost one by one. The issue at hand is about file mounts. |
You are right, but @OscarOrSomething 's problem sounds exactly like my issue. Maybe it points someone in the right direction. |
I reread @OscarOrSomething and, after all he does not state if he was having the issue with the nginx configuration or with assets served by his webserver (but since he is having the issue with several files, the latter is more likely). So you might have the same problem indeed. @OscarOrSomething : if you are having problems with assets, you should probably check the contents of the file from inside docker directly to know if the problems lies with docker or your webserver. The problem could be an HTTP caching problem if the webserver is at fault. |
Hi, I checked and they are updating on the docker so it must be Apache. Is this right?
|
I'm facing this problem too, none of the suggestions worked for me. Any help? This kind of problem keeps me from developing in docker :( which I really want to Im running docker machine in my OSX 10.11.4
docker version:
|
@betoharres Either don't use virtualbox, or disable sendfile in apache/nginx. |
@cpuguy83 thanks, disabling sendfile didn't worked at all, now the files sometimes changes and sometimes changes back to previous state when reloading the page without updating to the newest changes, urgh |
I just have a node express app running in docker using docker-compose volume to map my html files to the container. Getting the same behavior. It is not updating in the docker container. i did the same with vim and add |
I'm having the same issue with phpstorm and docker via virtualbox. The apache sendfile change didn't seem to help. I've also tried adjusting the save settings in phpstprm and no change. |
have the same problem volumes:
- ./nginx/conf.d:/etc/nginx/conf.d i change for this and it work volumes:
- /work/docker/nginx/conf.d:/etc/nginx/conf.d i think the reason is ./ |
Volume-mounting individual files is unreliable due to limitations with the way Docker handles inode changes. If editing a file creates a new inode, then those changes will unexpectedly not be propagated into the container. See moby/moby#15793 (comment). To fix this, we will avoid volume-mounting files. We move the `.env` file to `config/env`, so that we can reuse the `config` directory volume-mount. We also create a symlink to `.env` for the convenience of docker-compose commands (since it reads `.env` by default).
The |
I edit a copy of file and after |
Ouch. So this is why we sometimes have to reload our containers inexplicably. This is a dreadful bug, I must say that I don't really agree with it being closed. When explicitly volume binding a file name I would expect changes to the file with that name to be reflected in the container without the need to have knowledge about the intricacies of the file system. Is it really impossible to monitor for example the modified time stamp and update the inode reference accordingly? |
It's how the linux kernel works 🤷♂️ you can try it on your host (on a linux machine, but probably works on macOS as well); # create your file on the host
echo "# my-file" > myfile.txt
# create a directory (this is the "container's filesystem")
mkdir container
# create the mountpoint inside the container's filesystem
touch container/myfile.txt
# mount the file from the host into the container
mount -o ro,bind myfile.txt container/myfile.txt
# read the bind-mounted file "inside the container"
cat container/myfile.txt
# my-file
# "modify" the file, in this case, using `sed`, which uses a temporary file, then replaces the file
sed -i 's/my-file/my-file-updated/g' myfile.txt
# check that the file "on the host" is updated
cat myfile.txt
# my-file-updated
# check the mounted file "inside the container:
cat container/myfile.txt
# my-file
# unmount the file
umount container/myfile.txt |
This thread is amazing. I was running into this problem and effectively, yes, I was using vim and yes, |
In Vim you can use
|
hey, I am facing the same issue, did you start the docker container and used nano to edit the nginx.conf and save, I just tried it but didn't work, can you elaborate how you overcome this issue, big help, thanks |
nvim: * Use grubvox * Create mapping to edit files in place when saving. (By default, vim/neovim create a new file when the opened file is saved and then replaces the opened file by the new one, effectively modifying the inode at every write). This helps a lot when editing mounted files in docker using vim/neovim. moby/moby#15793 (comment) Signed-off-by: Antonio Gutierrez <chibby0ne@gmail.com>
I have this nginx container, on which I'm mounting a vhost configuration file (indirectly, in fact, I'm using a data volume container). I would like to reload the configuration without stopping the container, with
docker-compose kill -s HUP webserver
, but when I change the configuration file on the host, it does not change on the guest, and vice versa. When I restart the container however, the guest takes into account the host changes. Here is an excerpt of my docker-compose.yml :The text was updated successfully, but these errors were encountered: