Pi-hole on docker crashing because of shared memory shortage

I run Pi-hole in docker and I just realized that it creashed, probably many times but I did not notice because of docker restarting it (EDIT: now I see it is crashing every 15 minutes!). The question is similar to PiHole Crash - Reason shared memory tmpfs /dev/shm 100% (now closed), but in a docker context.

My version:

Docker Tag 2025.06.2Core v6.1.2FTL v6.2.3Web interface v6.2.1

The logs:

pihole-1  | 2025-07-14 20:00:35.737 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 93% is used (63.0MB used, 67.1MB total, FTL uses 63.0MB)
pihole-1  | 2025-07-14 20:00:41.908 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 94% is used (63.3MB used, 67.1MB total, FTL uses 63.3MB)
pihole-1  | 2025-07-14 20:00:48.581 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 94% is used (63.6MB used, 67.1MB total, FTL uses 63.6MB)
pihole-1  | 2025-07-14 20:00:54.771 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 95% is used (63.9MB used, 67.1MB total, FTL uses 63.9MB)
pihole-1  | 2025-07-14 20:01:02.709 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 95% is used (64.2MB used, 67.1MB total, FTL uses 64.2MB)
pihole-1  | 2025-07-14 20:01:08.915 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 96% is used (64.5MB used, 67.1MB total, FTL uses 64.5MB)
pihole-1  | 2025-07-14 20:01:15.746 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 96% is used (64.8MB used, 67.1MB total, FTL uses 64.8MB)
pihole-1  | 2025-07-14 20:01:22.502 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 96% is used (65.1MB used, 67.1MB total, FTL uses 65.1MB)
pihole-1  | 2025-07-14 20:01:28.977 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 97% is used (65.4MB used, 67.1MB total, FTL uses 65.3MB)
pihole-1  | 2025-07-14 20:01:35.810 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 97% is used (65.7MB used, 67.1MB total, FTL uses 65.6MB)
pihole-1  | 2025-07-14 20:01:42.584 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 98% is used (65.9MB used, 67.1MB total, FTL uses 65.9MB)
pihole-1  | 2025-07-14 20:01:49.361 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 98% is used (66.2MB used, 67.1MB total, FTL uses 66.2MB)
pihole-1  | 2025-07-14 20:01:55.784 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 99% is used (66.5MB used, 67.1MB total, FTL uses 66.5MB)
pihole-1  | 2025-07-14 20:02:04.550 UTC [50M] WARNING: Shared memory shortage (/dev/shm) ahead: 99% is used (66.8MB used, 67.1MB total, FTL uses 66.8MB)
pihole-1  | 2025-07-14 20:02:04.555 UTC [50M] WARNING: Could not fallocate() in realloc_shm() (/app/src/shmem.c:838): No space left on device
pihole-1  | 2025-07-14 20:02:04.555 UTC [50M] CRIT: realloc_shm(): Failed to resize "/FTL-50-queries" (10) to 65175552: No space left on device (28)
pihole-1  | 
pihole-1  |   [i] pihole-FTL exited with status 1
pihole-1  | 
pihole-1  |   [i] Container will now stop or restart depending on your restart policy

I have ample RAM on my server - how can I increase the shared memory for the docker contrainer?

Debug Token:

https://tricorder.pi-hole.net/IMw6VaBL/

I increased the size with the docker compose entry shm_size: 900m, I will monitor how it goes

The default SHM allocation for Docker can be too small. We used to have a note somewhere about SHM size and changing it but I can't find it quickly.

A short time after the change I was at

root@srv ~# docker exec -it pihole-pihole-1 df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
shm             900M   65M  836M   8% /dev/shm

and now (about 20 hours later) at

root@srv ~# docker exec -it pihole-pihole-1 df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
shm             900M   60M  841M   7% /dev/shm

It looks like there is a stabilization at ~60-65 Mb, I will wait a few more days and set 100 Mb to be on the safe side.

We try to be light when using system resources and not take everything available and then warn when things are getting to the limit.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.