Redis Docker Official Image
docker run -d --name redis -p 6379:6379 redis:latest
Production-ready setup with persistence and password.
docker run -d \
--name redis \
--restart unless-stopped \
-p 6379:6379 \
-v redis-data:/data \
redis:latest redis-server --save 60 1 --loglevel warning --requirepass "YourStrongPassword"
docker exec -it redis redis-cli
docker logs -f --tail 100 redis
docker logs redis 2>&1 | grep -iE "error|err|warn|fail|panic"
docker logs --tail 200 redis 2>&1 | grep -iE "error|err|warn|fail|panic"
step 2. Setting vm.overcommit_memory = 1
docker logs redis 2>&1 | grep -iE "error|err|warn|fail|panic"
1:M 09 Nov 2026 21:32:18.095 # 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.
1:M 11 Nov 2026 18:52:41.176 # 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.
1:M 11 Nov 2026 18:55:09.958 # 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.
1:M 11 Nov 2026 18:57:32.535 # 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.
1:M 11 Nov 2026 19:00:02.648 # 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.
1:M 12 Nov 2026 04:29:00.568 # 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.
1:M 12 Nov 2026 04:29:00.568 # 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.
Why This Happens
How Redis saves data. When Redis creates an RDB backup or rewrites its AOF file, it forks a child process that duplicates its memory map using copy-on-write.
Redis 保存机制。 Redis 在进行 RDB 快照备份或重写 AOF 日志时,会 fork(克隆)一个子进程来共享主进程的内存。
Why 0 causes issues. With vm.overcommit_memory = 0, the Linux kernel checks if enough free physical RAM exists to hold a full duplicate of Redis before allowing the fork. Under low memory conditions, the kernel blocks the fork and background saves fail.
参数为 0 的风险。 当 vm.overcommit_memory = 0 时,Linux 内核会严格检查剩余物理内存是否足够复制一份完整的 Redis 内存。如果此时系统空闲内存不足,内核就会直接拒绝创建子进程,导致数据持久化失败甚至报错崩溃。
Why 1 fixes it. Setting vm.overcommit_memory = 1 tells the kernel to always allow memory allocations, letting Redis fork smoothly even when free RAM is tight.
参数为 1 的作用。 设为 1 表示允许内核始终接受内存分配请求,保证 Redis 在内存较紧时也能顺利完成后台保存。
Fix It (On the Docker Host)
echo "vm.overcommit_memory = 1" | sudo tee /etc/sysctl.d/99-redis-overcommit.conf
# Reload sysctl settings.
sudo sysctl --system
# Verify the value
sudo sysctl -a
sysctl vm.overcommit_memory
Redis Docker Official Image tags
https://hub.docker.com/_/redis
