Skip to content
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 mount inotify events not delivered after container restart #681

Open
genei09 opened this issue Sep 20, 2016 · 48 comments
Open

bind mount inotify events not delivered after container restart #681

genei09 opened this issue Sep 20, 2016 · 48 comments

Comments

@genei09
Copy link

genei09 commented Sep 20, 2016

Expected behavior

changes to OSx filesystem are picked up by the webpack process

Actual behavior

Even though the files are changed, no change is detected
Using the same docker image in Dinghy produces the expected results

Information

  - Full output of the diagnostics from "Diagnose & Feedback" in the menu
Docker for Mac: version: 1.12.1 (2d5b4d9)
OS X: version 10.11.6 (build: 15G31)
logs: /tmp/F23DDA4B-1399-4A2B-90FD-C7D873FCEDD5/20160920-140135.tar.gz
[OK]     docker-cli
[OK]     virtualization kern.hv_support
[OK]     menubar
[OK]     moby-syslog
[OK]     dns
[OK]     disk
[OK]     system
[OK]     app
[OK]     osxfs
[OK]     virtualization VT-X
[OK]     db
[OK]     slirp
[OK]     logs
[OK]     env
[OK]     vmnetd
[OK]     moby-console
[OK]     moby
[OK]     driver.amd64-linux

Steps to reproduce the behavior

Dockerfile:

FROM qajenkins.windsorcircle.com/centos:7

ENV PGTZ=UTC
VOLUME /tmp
Run yum -y update; yum clean all &&\
 yum -y install tkinter openjpeg2-devel openjpeg2 libtiff-devel freetype-devel lcms2-devel libwebp-devel libwebp-tools &&\
 yum -y install logwatch sendmail-cf sysstat patch python-pip python-devel libpqxx-devel libxml++-devel python-lxml libjpeg-devel libxslt-devel libxml2-devel libyaml-devel git bzip2 freetype fontconfig gcc gcc-c++ make tar wget epel-release sudo; yum clean all &&\
 yum -y install inotify-tools &&\
 yum -y reinstall glibc-common &&\
 yum clean all

make a shell script inotifyrun and mount that directory as a volume
script:

#!/bin/sh
FORMAT=$(echo -e "\033[1;33m%w%f\033[0m written")
"$@"
while inotifywait -qre close_write --format "$FORMAT" .
do
    "$@"
done

example docker run command

docker run -it --name test_inotify --volume ~/Repos/APP_REPOS/:/opt/APP_REPOS 634faa2f65e8 bash

run the shell script
cd /opt/APP_REPOS
./inotifyrun.sh tail test.log

using VIM or other local file editor make a test.log file in the mounted dir and see no change

stop the shell script
copy to ~/
run the same experiment but exec into the container and use VI to make/modify the file.
the changes are detected and the tail command runs.

@dsheets
Copy link
Contributor

dsheets commented Sep 20, 2016

Another user reports at https://forums.docker.com/t/docker-for-mac-inotify-events-only-working-from-vim/18772/5 that file saves from vim are propagated correctly but Atom file saves fail. I will investigate both reports but a repro case (as you have mentioned) would be very helpful. Thanks for your report!

@genei09
Copy link
Author

genei09 commented Sep 20, 2016

I saw that report about VIM working, but I find even VIM edits are not propagating.
This is rather critical for our node developers so I'm also trying to downgrade version back to 1.12.0

@dsheets
Copy link
Contributor

dsheets commented Sep 20, 2016

From your issue edition with reproduction, the IN_CLOSE_WRITE inotify event is not currently supported. This is documented at https://docs.docker.com/docker-for-mac/osxfs/#file-system-events. What software are you using that demands this event? I believe webpack should pick up file modification events regardless of the presence of IN_CLOSE_WRITE.

@genei09
Copy link
Author

genei09 commented Sep 20, 2016

ah, I didn't realize close_write wasn't supported. I'll rerun the example with modify. I was simply trying to simplify the case.

modify does work. I'll try and build a simple webpack example and see if that repros

@genei09
Copy link
Author

genei09 commented Sep 21, 2016

after restarting the issue seems to have cleared itself and webpack is able to pick up changes. However several restarts of both docker and the full OS were tried, and the issue has been repeated on multiple machines. I'll continue to try and nail down a solid repro

@dawnerd
Copy link

dawnerd commented Sep 22, 2016

Same issue here. Restarting breaks docker so I have to restart the computer for it to work. Breaks it so much the diagnostics doesn't even run.

@holman
Copy link

holman commented Sep 22, 2016

Also seeing similar things on 1.12.1-beta26.1, also with webpack-dev-server. Unable to track things down exactly, but pretty sure this started happening once I installed the new beta update. Restarting my computer doesn't seem to have any affect, and seeing the same behavior regardless of editor (Atom and vim, mainly) I'm using.

@dsheets
Copy link
Contributor

dsheets commented Sep 23, 2016

@dawnerd could you be more specific about how "restarting break docker"? Are you using the 'restart' button in the menu/preferences? Are you quitting and starting the app again? Do diagnostics work after you restart the machine? What are the symptoms of the broken docker? If diagnostics work, we'd really appreciate it if you could file a new issue with the details of what you did, what happened, and a diagnostic id (it's likely that logs were still being written even when Docker was very broken and this could help us track down the defect).

@holman does Diagnose & Feedback from the 🐳 menu work? Could you please run and upload the diagnostics and post your diagnostic ID back here?

@dawnerd
Copy link

dawnerd commented Sep 23, 2016

@dsheets Would love to provide more info if I could. Used the restart button and the icon showed it had come back up. Clicking Diagnostics didn't load, just an empty window. If logs are dumped on the machine somewhere I could try to look for them.

@dsheets
Copy link
Contributor

dsheets commented Sep 23, 2016

@dawnerd You can run /Applications/Docker.app/Contents/Resources/bin/docker-diagnose -u to run a diagnostic and upload the result. You can also run syslog -w -F '$Time $Host $(Sender)[$(Facility)][$(PID)\n<$((Level)(str))>: $Message' -k Sender Seq Docker -o -k Sender Seq docker -o -k Message Seq Docker -o -k Message Seq docker if you'd like to see (some) Docker log messages streamed in real-time. Your diagnostic/restart problem is likely distinct from the inotify event delivery problem so it would be great if you could open a new issue for it to avoid derailing this one. :-) Thanks for your patience and cooperation.

@holman
Copy link

holman commented Sep 27, 2016

@holman does Diagnose & Feedback from the 🐳 menu work? Could you please run and upload the diagnostics and post your diagnostic ID back here?

All of it is showing up as [OK] for me. Strangely, though, everything seemed to start working again for me in the last few days. I don't think I've really changed anything, so it must be ✨magic✨. I'll keep an eye on it and see if it happens again and, if so, will post the full diagnostics and details here.

@genei09
Copy link
Author

genei09 commented Sep 28, 2016

Had a developer encounter the same issue. It went from working to not working without any change in version.

our normal setup (which he had working):
Ordinarily we have node_modules installed in the containers file system and then symlink to where the project source is.
The project source is volume mounted from the OSx FS.

what he changed:
he removed the symlink and installed node_modules into the source on OSx.

what fixed it:
rm -rf /Library/PrivilegedHelperTools/com.docker.vmnetd

@genei09
Copy link
Author

genei09 commented Oct 7, 2016

the afore mentioned "fix" later rendered Docker for Mac completely unusable for him.

@genei09
Copy link
Author

genei09 commented Oct 8, 2016

I installed the latest beta (1.12.2 rc1 beta 27)
and applied the fix in #668

running my script, modify events are not being picked up from outside the container. from inside the container modified files are detected as expected

@genei09
Copy link
Author

genei09 commented Oct 8, 2016

after installing 1.12.0 10871
modify events were still not being passed into the container
I quit docker and noticed that com.docker.vmnetd process was still running
I killed that process and started docker
modify events were being picked up by inotify as evidenced by the shell script referenced above, and 1 event was caught by webpack, but all events after were not. These were all simple modifications of 1 line in 1 file.

Even when modifying the file from within the container webpack did not pick up on changes (source files still in the volume mount)

I restarted webpack and it started picking up changes from within the container

I modified my script to run touch instead of echo on the file modification detected by inotify

webpack successfully triggers from changes made outside the container this way (file edits were made using vim/vi)

@genei09
Copy link
Author

genei09 commented Oct 8, 2016

after installing 1.12.1 (12133) with the same container, I'm not detecting the modify events with the script or webpack just as I saw with 1.12.2

@genei09
Copy link
Author

genei09 commented Oct 8, 2016

after completely rebooting my mac I'm able to get inotify modify events from edits made outside the container to be detected with 1.12.1 (12133). No amount of restarting docker / killing the processes worked. Shell script only, webpack still isn't picking up the changes without it running

@samoht
Copy link
Contributor

samoht commented Oct 14, 2016

@genei09 could you please upload your diagnostic logs to our server by running:

/Applications/Docker.app/Contents/Resources/bin/docker-diagnose -u

So that we can investigate your issue. Thanks!

@genei09
Copy link
Author

genei09 commented Oct 14, 2016

/Applications/Docker.app/Contents/Resources/bin/docker-diagnose -u
OS X: version 10.11.6 (build: 15G1004)
Docker.app: version: 1.12.1 (2d5b4d9)
Local time: Fri Oct 14 10:19:45 EDT 2016
UTC:        Fri Oct 14 14:19:45 UTC 2016
Timestamp:  20161014-101945
Running diagnostic tests:
[OK]      docker-cli
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      disk
[OK]      menubar
[ERROR]   environment      the variable DOCKER_TLS_HOSTNAME should not be set
[OK]      Docker
[OK]      VT-x
[OK]      kern.hv_support
Most specific failure is: the variable DOCKER_TLS_HOSTNAME should not be set
Docker logs are being collected into /tmp/3B9ABF07-3BDF-41B5-A7C2-18BBED6DC348/20161014-101945.tar.gz
Your unique id is: 3B9ABF07-3BDF-41B5-A7C2-18BBED6DC348
Please quote this in all correspondence.

DOCKER_TLS_HOSTNAME is set to localhost for use with Ansible

@genei09
Copy link
Author

genei09 commented Oct 16, 2016

the previous diagnostic was run while modify events were being passed through to the container. the following was after seeing the symptom return.

OS X: version 10.11.6 (build: 15G1004)
Docker.app: version: 1.12.1 (2d5b4d9)
Local time: Sun Oct 16 08:09:31 EDT 2016
UTC:        Sun Oct 16 12:09:31 UTC 2016
Timestamp:  20161016-080931
Running diagnostic tests:
[OK]      docker-cli
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      disk
[OK]      menubar
[ERROR]   environment      the variable DOCKER_TLS_HOSTNAME should not be set
[OK]      Docker
[OK]      VT-x
[OK]      kern.hv_support
Most specific failure is: the variable DOCKER_TLS_HOSTNAME should not be set
Docker logs are being collected into /tmp/3B9ABF07-3BDF-41B5-A7C2-18BBED6DC348/20161016-080931.tar.gz
Your unique id is: 3B9ABF07-3BDF-41B5-A7C2-18BBED6DC348
Please quote this in all correspondence.

@genei09
Copy link
Author

genei09 commented Oct 16, 2016

after quitting docker and restarting, and recreating the container the problem persisted.
after quitting docker the process com.docker.vmnetd was still running.
quitting docker a second time, killing the vmnetd process and restarting docker the modify events are still being blocked, even from within the container there is inconsistent behavior. Inside the container I used vi to open a file. When modified only the .swp had modifications detected. The actual file was only detected as modified when close/write was used. This was across the mount or within the containers fs

@genei09
Copy link
Author

genei09 commented Oct 16, 2016

after restarting the machine the containers were damaged and unusable. When attempting to exec into the containers to see what was going on I receive the message:

unable to find user root: no matching entries in passwd fileunable to find user root: no matching entries in passwd file

@genei09
Copy link
Author

genei09 commented Oct 16, 2016

after rebuilding the containers the same symptom is present. no longer able to detect modify events from outside the container, and vi only triggers modify events when close/write is used.

possibly a kernel issue?

@genei09
Copy link
Author

genei09 commented Oct 16, 2016

It looks like the containers pick up modify events fine until you issue a docker restart on the container. This is a fairly common command for us to issue so I didn't think anything of it while trying to narrow this down.

I've repeated this 3 times and each time it reacts the same way.
docker run: modify events are working
docker restart: modify events are not working

@frodopwns
Copy link

Has this issue been addressed at all? Major blocker.

@iameli
Copy link

iameli commented Mar 2, 2017

Same symptoms here. Using inotifywait -m on various files confirms that it sees changes from inside the container but not from outside. (And just for clarity, this is distinct from the vim issue where certain OSX events don't have a Linux analog.) Are y'all aware of a root cause?

Error exec: plutil -extract appVersionHistory xml1 "/Users/eli//Library/Group Containers/group.com.docker/Library/Preferences/group.com.docker.plist" -o -: exit 1
macOS: version 10.11.3 (build: 15D21)
Docker.app: version: 1.13.1 (94675c5a7)
Local time: Wed Mar  1 19:19:44 PST 2017
UTC:        Thu Mar  2 03:19:44 UTC 2017
Timestamp:  20170301-191944
Running diagnostic tests:
[OK]      docker-cli
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      disk
[OK]      menubar
[OK]      environment
[OK]      Docker
[OK]      VT-x
[OK]      kern.hv_support
Error exec: which /usr/bin/log: exit 1
Docker logs are being collected into /tmp/8CD0C43D-C8E1-48F3-8C3D-28E285C7936B/20170301-191944.tar.gz
Your unique id is: 8CD0C43D-C8E1-48F3-8C3D-28E285C7936B
Please quote this in all correspondence.

@iameli
Copy link

iameli commented Mar 2, 2017

I appear to be able to work around the issue by running another container that bind-mounts the same directory as the broken container and running inotifywait -m on files in the second container. This seems to embarrass the first container, which then proceeds to register inotify events successfully.

That's worked twice, anyway. I'll check back here if I find a more consistent repro than that.

EDIT: Yep, totally confirmed and consistent. Running an additional container that bind-mounts the same directory fixes the problem in the first container. You don't have to run inotifywait or anything. Downside: it stops working in the first container again after you close the second container.

This feels like a refcount-getting-decremented-too-many-times kinda thing.

@brianbolt
Copy link

I have a coworker who reported that if he had 2 volume's in a container, then only 1 of the volume's would respond to file changes.

@iJebus
Copy link

iJebus commented Apr 19, 2017

Seeing some weird and possibly related stuff; basically containers 'sometimes' picking up file modification events but not always, and it apparently dropping out after a period.

@mike-es
Copy link

mike-es commented Oct 18, 2017

I was able to reproduce this quite easily by running 4 instances of a modified image from the original description and then changing git branches in the bind mounted repos.

Details in EugenMayer/docker-sync#410 (comment)

Has any progress been made on this? It is currently blocking my team from using Docker for Mac.

@caseywebdev
Copy link

I've created a workaround that I figured I'd share here for anyone using Docker Compose.

version: '3.5'

services:
  my-app: &my-app
    image: my-image
    depends_on:
      - my-app-inotify-fix
    volumes:
      - .:/code
    command: ["my-command"]

  my-app-inotify-fix:
    <<: *my-app
    command: ["tail", "-f", "/dev/null"]
    depends_on: []

After a ton of tinkering around I was seeing the same results as @iameli. This hack will keep another container running with the same image and volume mounts so inotify events should continue to work even after docker-compose restart my-app. Obviously this is just a band-aid but I hope it helps!

@twose
Copy link

twose commented Mar 20, 2018

After docker rm -f ${container} and recreate, it works well, but it's too troublesome to use.
It is currently blocking my team from using Docker for Mac too.

@shnhrrsn
Copy link

It'd be really great to see this issue prioritized, it's a huge timesuck when developing having destroy my containers and/or restart Docker itself if that doesn't work. Not to mention the time I spend refreshing pages before realizing Docker's stopped syncing fs changes 😅

@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@shelane
Copy link

shelane commented Jul 30, 2018

/remove-lifecycle stale

@docker-robott
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@shelane
Copy link

shelane commented Oct 28, 2018

/remove-lifecycle stale

@shelane
Copy link

shelane commented Oct 28, 2018

/lifecycle frozen

@sergeigannochenkozenjob

Any update on that?

I faced the same problem while running two projects with really huge node_modules folders mapped through volumes. When I comment out one of them in my compose.yml, the other project starts receiving the file events. This observation makes me think that maybe docker daemon hits some limits set on the host machine.

@jgonggrijp
Copy link

I'm running into this issue, too. Docker Desktop 4.5.0 (74594) with Engine 20.10.12 and Compose 2.2.3 on macOS 10.15.6. It does not matter whether I use gRPC FUSE or legacy osxfs.

I run into the problem even after a fresh startup of the docker vm and recreation of all the containers (so not only after a restart).

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

No branches or pull requests