Fixing Redis background-save issues on Docker
I've been running redis in Docker for a number of sites, to perform things such as storing session data, hubot settings, and more.
I recently ran into a problem on one of my systems where it was reporting:
Can't save in background: fork: Out of memory
A quick google search showed this is a common error, so much so that there is an
official FAQ about it.
The solution is to toggle the /proc/sys/vm/overcommit_memory
to 1.
The trick when using Docker is that this needs to happen on the host machine.
This still didn't solve my problem, though. So I ran a
docker ps
on the host machine to get an idea of what was happening. And discovered that, somehow, I had two identical redis containers running, using the exact same configuration - which meant they were doing backups to the same volume. Killing the one no longer being used by my swarm services caused everything to work once again.