Is it possible to set vm.overcommit_memory =1 only for specific containers?

So, I'm running a container that is showing this in the log:

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

Spending most of my life in Windows I'm about 80% Linux ignorant, and as far as I can tell, when setting this setting it does it system wide, which will also affect all the other containers. Do I want to do this?

Is there some way to set this for only the container that is recommending it? I should add in case it helps, that I'm running docker desktop in WSL2 mode.

Update: As requested in his comment, I'm adding the container this question is about; it's called Papermerge.


Is there some way to set this for only the container that is recommending it?

No. vm.overcommit_memory is a Linux kernel tunable, at the host level, not the container level. Value of 0 is a more cautious overcommit than 1.

Redis's reasoning for recommending 1 is their background save mechanism. Big in memory database processes forks itself to save a copy, suddenly Linux guesses it might need up to double the memory, and doesn't allow the fork. Not desirable for Redis, which doesn't change that memory, only wants a copy on write snapshot.

Success would be containers performing well by memory metrics, and processes not dying or failing to fork due to lack of memory. Probably unlikely even if you set it to 1, but capacity planning is your task as system administrator.