Mongodb docker vm.max_map_count is too low even if set to 524288

mongodb run as docker container always gives the warning ‘vm.max_map_count is too low’ if I enter mongosh.

vm.max_map_count is set to 524288 in the host system permanently. If I run ‘docker exec mongodb sysctl vm.max_map_count’ (mongodb is the container name) the result is vm.max_map_count = 524288. So I assume the setting is replicated inside the container correctly.

Tried different values, different hosts (all ubuntu 22.04), always the same on every mongodb running in docker container. Restarting or recreating didn’t help. If I run the mongod directly on the host, the warning is gone.

Any ideas? Am I missing something?

Actually docker sets the soft limit to the hard limit of the host, which is too high. The soft limit seems to trigger the warning.

Since I’m running the container without docker-compose and portainer can’t add all run options, I edited my daemon.json and added

“default-ulimits”: {
“nofile”: {
“Hard”: 1048576,
“Name”: “nofile”,
“Soft”: 65536 } }

which sets the limits for all containers.

Problem solved! :grinning: