I’m running a MongoDB container using Docker Compose and encountering startup warnings related to tcmalloc and vm.max_map_count. I’ve set these values correctly on my host machine, but the container doesn’t seem to inherit them.
Setup:
My Docker Compose file:
mongo:
build: image
container_name: mongo
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: TO_CHANGE
ports:
- 0.0.0.0:27017:27017
volumes:
- mongo_data:/data/db
- mongo_ssl_data:/etc/letsencrypt
- keys:/keys
command: >
mongod --tlsMode allowTLS
--tlsCertificateKeyFile /etc/letsencrypt/live/db0.starknet.id/cert.pem
--tlsCAFile /etc/letsencrypt/live/db0.starknet.id/fullchain.pem
--tlsAllowConnectionsWithoutCertificates
--replSet rs0
--keyFile /keys/mongo_keyfile
depends_on:
certbot:
condition: service_healthy
My Dockerfile:
FROM mongo:8.0.0
ENV GLIBC_TUNABLES=glibc.pthread.rseq=0
I’ve set the following on my host machine (ubuntu 24):
root@ashur ~ # sysctl vm.max_map_count
vm.max_map_count = 262144
root@ashur ~ # cat /sys/kernel/mm/transparent_hugepage/enabled
always [madvise] never
root@ashur ~ # cat /proc/sys/vm/swappiness
0
Warnings
The server generated these startup warnings when booting
2024-09-21T09:22:31.052+00:00: For customers running the tcmalloc-google memory allocator, we suggest setting the contents of sysfsFile to 'always'
2024-09-21T09:22:31.052+00:00: For customers running the updated tcmalloc-google memory allocator, we suggest setting the contents of sysfsFile to 'defer+madvise'
2024-09-21T09:22:31.052+00:00: We suggest setting the contents of sysfsFile to 0.
2024-09-21T09:22:31.052+00:00: vm.max_map_count is too low
Why aren’t these settings being inherited by the container, and how can I resolve these warnings? I tried setting them in the Dockerfile but this doesn’t seem to work of to be the reasonable solution.