How to set the vm.overcommit_memory parameter when running docker desktop on win11?

1:M 27 Oct 2022 05:26:18.873 # 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.

But my host is win11

If you use the WSL2 backend You can change it temporarily by simply starting a WSL distribution, and running

sudo sysctl -w vm.overcommit_memory=1

It will not be persistent and I don’t know if you could make it persistent.
One idea is that you could try to run a privileged container but that should start before everything else.

docker run --restart always -d --privileged --init --name sysctl-updater bash -c "while true; do sysctl -w vm.overcommit_memory=1; sleep 10; done"

This way it will change the setting when it starts and do the same change in case something changes it back in every 10 seconds.