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

Changes to a file belonging to a host mounted volume are not detected by nginx. #652

Open
madtechsupport opened this Issue Nov 27, 2014 · 16 comments

Comments

Projects
None yet
@madtechsupport
Copy link

madtechsupport commented Nov 27, 2014

I'm using boot2docker 1.3.2 on OS X 10.9.5 and after starting boot2docker and exporting the environment variables I start docker with this command:

docker run -d -p 80:80 -v "$(pwd)"/html:/usr/share/nginx/html nginx

Where in "$(pwd)/html" I have a simple index.html file. Visiting http://192.168.59.103/ displays the page for "$(pwd)/html/index.html" (as expected), but changes made to "$(pwd)/html/index.html" are not displayed when reloading the page.

To force the changes to the file to appear on the page I find it is necessary to move "$(pwd)/html/index.html" to some other filename (index.html.moved for example), reload the page for which nginx generates a "403 Fobidden" error (as no index.html exists), then move the file back to its original location (i.e. mv html/index.html.moved html/index.html), after which reloading the page will show the changes made to index.html.

Is there a better way for changes made to a file in a host mounted volume to be detected by a processes running inside the docker container?

Warren.

@madtechsupport

This comment has been minimized.

Copy link

madtechsupport commented Nov 28, 2014

Hi,

Thanks for the feedback. What I'm doing amounts to the steps described
here:
https://github.com/boot2docker/boot2docker/blob/master/README.md#virtualbox-guest-additions

As I'm using OS X, the mount I'm creating is "docker run -v
/Users/warren/Docker/nginx/html:/usr/share/nginx/html ...", which aligns
correctly to the "/Users share at /Users" that boot2docker creates. In fact
when I make a change the change appear at:

/Users/warren/Docker/nginx/html/index.html <--- on OS X
/Users/warren/Docker/nginx/html/index.html <--- on boot2docker VM
/usr/share/nginx/html/index.html <--- in the Docker container

The change appears correctly in the Docker container, only nginx does not
detect the change and continues to display the earlier version of the file.

Is this expect boot2docker behavior or not?

Regards,

Warren.

On Fri, Nov 28, 2014 at 2:07 AM, Sergey Zolotorev notifications@github.com
wrote:

Perhaps you need to read about folder sharing in
https://github.com/boot2docker/boot2docker/blob/master/README.md


Reply to this email directly or view it on GitHub
#652 (comment)
.

@madtechsupport

This comment has been minimized.

Copy link

madtechsupport commented Nov 28, 2014

I've worked this out. This is a sendfile bug that affects Virtualbox. More information be found here:

https://www.virtualbox.org/ticket/9069

The same problem affects Vagrant:

hashicorp/vagrant#351

@SvenDowideit

This comment has been minimized.

Copy link
Contributor

SvenDowideit commented Dec 1, 2014

I'm going to re-open this, as its another vbox pain we should try to work around

@SvenDowideit SvenDowideit reopened this Dec 1, 2014

@CleanCut

This comment has been minimized.

Copy link

CleanCut commented Dec 12, 2014

@SvenDowideit @madtechsupport

There's another Virtualbox bug for this here:

https://www.virtualbox.org/ticket/12597

I added my feedback to it, but it doesn't look like it's getting any attention upstream. This issue is preventing my organization from using containers for development.

@haggen

This comment has been minimized.

Copy link

haggen commented Apr 28, 2015

Very annoying, +1 for fixing or working around it.

People mentioned that disabling sendfile or changing the disk controller from sata to ide fixes the issue. Has anyone tried those ?

@manadan999

This comment has been minimized.

Copy link

manadan999 commented Apr 28, 2015

Its a big pain. +1

@CleanCut

This comment has been minimized.

Copy link

CleanCut commented Apr 29, 2015

@haggen Yes, in my case getting everything to avoid using sendfile made it so I could work around the bug. It took me weeks to find exactly what was using it, though.

@haggen

This comment has been minimized.

Copy link

haggen commented Apr 29, 2015

@CleanCut Since the bug is in vboxsf, and it's also slow as hell, I replaced the shared folders with a nfs mount and documented the whole thing, here it is:

https://gist.github.com/haggen/f84f55e3ed2c9c930335

@felixrabe

This comment has been minimized.

Copy link

felixrabe commented May 22, 2015

I just had this same issue, see nginxinc/docker-nginx#24.

@kudos

This comment has been minimized.

Copy link

kudos commented Jul 10, 2015

I'm seeing the same problem with the vmwarefusion driver and docker-machine. It may not be a vbox bug.

@gerrywastaken

This comment has been minimized.

Copy link

gerrywastaken commented Sep 25, 2015

@kudos I agree, it seems that everybody (on the 20+ threads I've found for various projects) is just assuming it's a Virtualbox issue because Virtualbox hasn't responded for years. However running stat shows the file being updated the the file contents are showing as updating, so I'm wondering what it is about sendfile or nginx, that is not picking up the change.

Some more info: http://smotko.si/nginx-static-file-problem/
And the closed nginx ticket which it seems was not investigated on their end: https://trac.nginx.org/nginx/ticket/245
They both point to a comment on reddit which suggests that it's due to a limitatation of the shared file system provided by Virtuallbox. However as mentioned, the file is showing as changed on the file server so I still suspect this is not a problem with Virtualbox.

@sleemer

This comment has been minimized.

Copy link

sleemer commented Nov 4, 2015

Same problem... But what I found out is:
When I update file in shared folder on my mac it reflects correctly to docker container, BUT something strange is happening with file in virtualbox vm... What I mean by strange... If, for example, I change file index.html with content 'Hello world' to 'Hi' then content of files would be:
'Hi' - /Users/username/Docker/nginx/html/index.html <--- on OS X
'Hel' - /Users/username/Docker/nginx/html/index.html <--- on VM
'Hi' - /usr/share/nginx/html/index.html <--- in the Docker container
If I change file index.html again to 'Hi again to all of you' then content of files would be:
'Hi again to all of you' - /Users/username/Docker/nginx/html/index.html <--- on OS X
'Hello world' - /Users/username/Docker/nginx/html/index.html <--- on VM
'Hi again to all of you' - /usr/share/nginx/html/index.html <--- in the Docker container

... and, of cause, nginx, with default settings, returns version of file from VM...

UPDATED: After restarting the VM:
'Hi again to all of you' - /Users/username/Docker/nginx/html/index.html <--- on OS X
'Hi again to all of you' - /Users/username/Docker/nginx/html/index.html <--- on VM
'Hi again to all of you' - /usr/share/nginx/html/index.html <--- in the Docker container

nginx returns 'Hi again to all of you' .

@jredl-va

This comment has been minimized.

Copy link

jredl-va commented Nov 24, 2015

Just a heads up for others on this thread, I found this little tool very helpful with OSX docker development: https://github.com/brikis98/docker-osx-dev

The tool gets rsync up and running and is a great workaround for the send file issues.

@ImranAhmed

This comment has been minimized.

Copy link

ImranAhmed commented Jul 5, 2017

Is this still ongoing? I hit this issue today on Windows 7, Docker Toolbox.

@yosifkit

This comment has been minimized.

Copy link
Contributor

yosifkit commented Jul 5, 2017

@ImranAhmed, yes, as far as I know it is still a bug/limitation when using VirtualBox Shared Folders.

@joe-at-startupmedia

This comment has been minimized.

Copy link

joe-at-startupmedia commented Nov 10, 2017

Still an issue for me using gulp on the host machine and hosting the index file on the client. I just run this bash script against the index file on the client machine for the time being:

#!/bin/bash

### Set initial time of file
LTIME=`stat -c %Z $1`

while true
do
   ATIME=`stat -c %Z $1`

   if [[ "$ATIME" != "$LTIME" ]]
   then
     echo "" >> $1
     echo "File Saved."
     LTIME=`stat -c %Z $1`
   fi
   sleep 3
done

@wglambert wglambert added the Issue label Jul 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment