Disable redis persistence in docker

For me work

command: redis-server --save "" --appendonly no
image: redis:alpine

--renew-anon-volumes addresses the underlying problem of Redis retrieving a volume from the previous container after being stopped.

docker-compose up --renew-anon-volumes

Note that this affects other containers that keep their volumes around after being stopped, such as MySQL and Postgres.


For me this works:

image: redis:4.0-alpine
command: [sh, -c, "rm -f /data/dump.rdb && redis-server --save ''"]

Not very elegant, but works:

  redis:
    image: "redis:5.0.3-alpine"
    command: [sh, -c, "rm -f /data/dump.rdb && redis-server"]  # disable persistence

/data/dump.rdb is where Redis stores the database.