Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Increase inotify watchers in Docker images during build

Increasing fs.inotify.max_user_watches for Docker images

TL;DR You can't set those for an image during build time becasue Docker takes the sysctl configuration from the Host. So, set the config on your host machine.

As in this link, to increase the maximum watchers, we need set fs.inotify.max_user_watches to a higher number in /etc/sysctl.conf.

$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p

So, I immediately tried to add it to Dockerfile and build the image only to see the following error:

sysctl: setting key "fs.inotify.max_user_watches": Read-only file system

After some research, I realised that Docker doesn't let the sysctl to be modified during build for images because it takes it from the host.

So, I had to set the sysctl on the host, not in the `Dockerfile.

@Bronco97421
Copy link

Bronco97421 commented May 18, 2021

Man you save my life !

@mrashad10
Copy link

mrashad10 commented Aug 10, 2021

I lost the half of my day search for this solution, thank you

@adityadubey057
Copy link

adityadubey057 commented Nov 26, 2021

What if I am using Fargate and i need to update the fs.inotify.max_user_watches values,how is that possible then , as it is read mode ?

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