loading...

Fixing "unable to monitor directories for changes" on Docker for macOS

tjbarber profile image TJ Barber ・1 min read

Earlier today I ran across this error when trying to run my Docker-ized Ruby on Rails application:

FATAL: Listen error: unable to monitor directories for changes.

Obviously, I started Googling. I was confused, because I didn't know if this was my macOS host causing this issue or if it was the Docker container itself. Docker pointed me to this page which seemed like it should offer me the solution, and it kinda did but not really.

Through trial and error, I found that macOS doesn't have a sysctl.conf file by default. I wanted to avoid creating one if at all possible. But I found out that by using docker ssh I could get to my Docker container's terminal! Once I discovered that, here are the steps I took to resolve the issue:

  1. SSH into the container using docker ssh.
  2. Run the command provided by this page: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
  3. Run sudo sysctl -p to refresh your kernel parameters.

Re-run the command you were attempting to run and you should be good to go! From here I was able to start my Rails console and all worked as intended.

Posted on Jan 28 by:

tjbarber profile

TJ Barber

@tjbarber

Podcaster, software developer working in Ruby and Swift. Christian and new dad. Follow my adventures on my website!

Discussion

markdown guide