Skip to main content

Fixing Permission Denied When Running sysctl -w fs.inotify.max_user_watches in Docker Container

The solution is simple - you need to modify the host machine's configuration:

Check Current Configuration

cat /proc/sys/fs/inotify/max_user_watches

Modify

sysctl -w fs.inotify.max_user_watches=524288

If the error disappears, we can permanently add it to a new file in /etc/sysctl.d/.

echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf

The above command creates a file in /etc/sysctl.d/ and adds the watcher count to it.

Finally, reload systemd settings to activate this new change. To reload systemd, restart the computer or just run the following command.

sudo sysctl -p /etc/sysctl.conf