redis, docker,

Disable Redis persistence in Docker

Apr 12, 2022 · 1 min read · Post a comment
Disable Redis persistence in Docker

Disabling Redis persistance in Docker could be a good thing tho, if you are hosting a development environment, running low on disks space and possibly can’t afford to scale. By default I believe Redis uses the RDB persistence which basically saves a snapshot in a binary file named dump.rdb. Now, let’s see how to start a Redis Docker container with no persistence.

Prerequisites

  • Docker

Solution

Solution 1. As a part of a docker-compose stack example:

image: redis:alpine3.15
command: rm -f /data/dump.rdb && redis-server --save "" --appendonly no

As a part of a docker run command example:

docker run --name redis_container -d redis:alpine3.15 redis-server --save '' --appendonly no

Solution 2. Since Redis creates an anonymous volume, just before taking down the stack, add the --volumes flag. For instance:

docker-compose down --volumes

or use the --renew-anon-volumes flag when recreating the docker-compose stack.

docker-compose up --renew-anon-volumes

Note: This will affect the rest of the stack services volumes!!!

Solution 3. As a last resort, always make sure to name your persistence volumes, manually find the anonymous Redis docker volume and remove it by using the `docker volume rm command.

Conclusion

If you can think of any other alternative solution, please do let me know in the comment section below. On a side note, follow our official channel on Telegram.