-
Notifications
You must be signed in to change notification settings - Fork 122
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
Unable to get inotify events inside container using kubernetes #2375
Comments
Came here to report exactly the same thing. Thanks @christopherL91 for the info that events are passed if it's mounted in two places - for anyone else, I've confirmed that that does work, although for me, I had to specify both the local and remote directory verbosely:
Once I ran that command, containers inside Kubernetes that mounted the same directory started receiving notifications. That workaround aside, the inability for |
Came across this issue when trying to solve my container running Webpack devserver not detecting changes and re-compiling. I'm not using Kubernetes, but a stack deployed with a compose file where my local directory is mounted as a volume for the Webpack service. Randomly I tried the suggestion of @majelbstoat. While the Webpack service was running, I just mounted the same directory into an alpine container (copied @majelbstoat's example just replacing the source path). Just letting that container run, any changes to my source files was picked up inside the Webpack container too… I don't know anything about Kubernetes, but it seems these issues might be related then. Is there any changes in how the directory is mounted in the compose file that could solve it for now? Otherwise, having a "ghost" container with the directory mounted will be the solution for now. Running Docker 18.05.0-ce-rc1-mac63 (24246) on the edge channel, on macOS 10.13.4 with APFS and Docker raw format (default). |
Thanks for the report. I think what's happening is:
I've got a prototype fix for this if you'd like to try it: https://download-stage.docker.com/mac/bysha1/98d31563898720b294dd40349228266a0dc2f969/Docker.dmg Note that
If you get a chance to try it, let me know what happens! |
I’m at Korean bbq rn but when I’m not drank I will test this. |
Hi @djs55, I'm not sure how relevant this is since I'm not using Kubernetes (but Today in a slight lapse of reasoned thought I upgraded to the latest edge version of Docker on my work computer too, and started seeing inotify events stopping after a few minutes. So, I did a test run with your development build and it sadly had no effect for me. In the first few minutes changes were picked up, but then they stopped after about 5 minutes. Booting up a separate container with Anything that would help you in further debugging and fixing this issue? |
Hi @fdanielsen -- that does sound like a very similar scenario. I'll investigate locally, but meanwhile if you could try starting a stack and then running:
It should display the active event registrations. Hopefully there's an entry for the host path mentioned in the compose file. When the events stop I suspect the entry will have been deleted. |
@fdanielsen I created a very simple image:
and a very simple
If I launch this with |
I don't know if this is relevant, but when i ran |
@djs55 That's interesting. Indeed that's how we deploy our stack and when I check the state as you suggest after deploying it this is all I see:
If I then start a separate container as mentioned earlier, this gets added in the second section:
So there's some issue with Docker not being aware of container-mounted directories for volumes in a deployed stack? |
@fdanielsen thanks for your comment -- you're correct, I've dug into it and can confirm the current code only handles the @majelbstoat thanks for your comment also -- I've seen a similar phenomenon which seemed to be triggered by the use of a symlink in the path I was sharing with the container. Could this explain what you saw? If so, I have a candidate fix for this also. If symlinks aren't involved then I can't explain it :/ |
@djs55, yes there were symlinks involved! |
In response to this issue I'm going to provide you a possible explanation from djs55. "I think what's happening is: 1) Kubernetes creates a container with a bind mount 2) A controller sees the event and tells com.docker.osxfs to start sending events 3) A periodic timer (with a 5 minute interval) fires, and 4) A GC collects unused event registrations, where "unused" means "does not correspond to a running Docker container". Since the Kubernetes container names are not the same as the docker container names, the garbage collector deletes the Kubernetes event registration. The reason docker run -v ... makes it work is that the GC sees the event registration is still in use and doesn't delete it". Djs55 offers a prototype fix for this if you would like to try it at: https://download-stage.docker.com/mac/byshal/98d31563898720b294dd40349228266a0dc2f969/Docker.dmg. He warns that the build is only for developmental purposes; suited for testing only, and not for production. Several other developers have offered their own personal experiences, so there might be a little something in this one for everyone. If you decide to try the prototype djs55 wants feedback. I too am interested in whether it works for you. Happy notifying events inside your container ✌️ |
There's an even newer development build available: https://download-stage.docker.com/mac/bysha1/7fc56519ef8858a58fd0eb61d10c958688ff8767/Docker.dmg -- this one should have event fixes for
Let me know if you get a chance to try it! |
Hi @djs55, I've tested this for an hour or so now on my stack setup. It looked very promising at first, but the events suddenly stopped. The I don't know if there's any other debug info I can get you to figure out why the events stopped? All the container mounts show |
An update to my previous comment. After it stopped working I recreated the stack (
Also got Diagnostic ID 270A2A95-162B-4B1E-A0A0-3D468FD6E41D/20180513-210107. I've never seen anything like this happen before, so wonder if something in the patched version crashed hard? |
Issues go stale after 90d of inactivity. Prevent issues from auto-closing with an 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. |
@fdanielsen sorry for the delay getting back to you. Unfortunately I couldn't find the uploaded diagnostic -- perhaps the upload failed. Are you still experiencing the same problem? The latest edge and stable has the fixes incorporated -- could you try again with one of those builds and upload a fresh diagnostic? Thanks! |
@djs55 I am seeing this exact same issue.
The filesystem is mounted: It works as expected, however no filesystem events are being sent to the container. When I run When I run the image with If I can provide anymore information, please let me know. |
FWIW I think I'm seeing this, or something similar, on Catalina (10.15.1) with Docker 19.03.5. Starting docker from
Running:
Shows the mount ok:
But it doesn't register any changes to the file ( Running this (modifying from within the container) works fine:
Has something changed here, or do I need to specify something extra when mounting the volume? |
Hmmm, interesting. I restarted Docker and now the above scenario is working. Not sure if I can reproduce now 🤔 |
@mhart I actually had a very very similar experience, and was already typing my comment here describing how I could reproduce the problem and how I tried restarting docker and even uninstalling and installing different versions of docker to see if it was a recent regression. I was trying different things with the shared directories in the configuration and trying to mount things in different directories in my file system, mounting a directory directly, then mounting it's parent and pointing inotifywait to the subdir, then mounting a file and modifying, just to be sure I could describe everything and maybe discover something related to the root of the apparent bug. Then as a last thing to try, I tried copy and pasting your example, and it magically worked. Then my attempts also worked, everything just started working magically. I'm not quite sure if there's a bug involved, if it is related to the original issue that the OP had, how to reproduce, if it's related to the latest version of macOS nor if this comment will help in any way since at the end of the day I couldn't really have a reproducible example made, but yeah, something weird with the inotify events definitely happened here. In my case restarting Docker did NOT work. I have no idea what actually did, but I'd bet that rebooting does the trick (though I'll have to test that specifially the next time I encounter this problem). |
I'm having the exact same issue on a windows machine, so it's not limited to mac. |
Why is this closed? It's not solved. |
@infostreams see this comment where the bot explained what it planned to do. There's normally a 90 day delay between the comment and the close (if no-one tells it to stop) but due to a bug in the bot it was almost 2 years! I'll reopen this issue for now. |
It’s still not solved /lifecycle frozen |
+1 would like to understand how to better debug filesystem events over the osxfs bridge. for a case I'm working with:
To workaround this, I wrote a script that binds to fsevents on the host machine, and delegates changes manually using As I understand it, this is still considered the only known workaround to the issue in question here. |
Closed issues are locked after 30 days of inactivity. If you have found a problem that seems similar to this, please open a new issue. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
Expected behavior
Should be able to get inotify events inside a container in kubernetes mounted with a host directory.
Actual behavior
Not able to get inotify events if there isn't another container outside kubernetes that mounts the same directory directly using docker run -v ...
Information
Docker for Mac: version: 17.12.0-ce-mac45 (a61e84b8bca06b1ae6ce058cdd7beab1520ad622)
macOS: version 10.13.2 (build: 17C88)
logs: /tmp/E73BC492-DDF5-4CBB-B43D-7F7874CF3802/20180109-011402.tar.gz
[OK] db.git
[OK] vmnetd
[OK] dns
[OK] driver.amd64-linux
[OK] virtualization VT-X
[OK] app
[OK] moby
[OK] system
[OK] moby-syslog
[OK] kubernetes
[OK] env
[OK] virtualization kern.hv_support
[OK] slirp
[OK] osxfs
[OK] moby-console
[OK] logs
[OK] docker-cli
[OK] menubar
[OK] disk
Steps to reproduce the behavior
docker run -it -v "some directory" alpine
and install inotifyapk --no-cache add inotify-tools
and then runinotifywait -r -m --format "%e %f" 'some directory'
in order to watch for inotify eventscreate the following service and deployment using
kubectl create -f ./alpine.yaml
and exec into the container. There you run the same command as with the other container "apk --no-cache ..."Write and modify the directory that is now mounted inside the two containers, and see that both containers receive inotify events.
Now remove the container that is running outside kubernetes and watch what happens inside the container that is running inside kubernetes. The container no longer receives any inotify events
The text was updated successfully, but these errors were encountered: