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:
- SSH into the container using
- Run the command provided by this page:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
sudo sysctl -pto 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.