redis / docker-library-redis

Docker Official Image packaging for Redis
http://redis.io
BSD 3-Clause "New" or "Revised" License
1.12k stars 563 forks source link

The documentation makes it sound like persistence is disabled by default #262

Open x-yuri opened 3 years ago

x-yuri commented 3 years ago

start with persistent storage

$ docker run --name some-redis -d redis redis-server --appendonly yes

If persistence is enabled, data is stored in the VOLUME /data, which can be used with --volumes-from some-volume-container or -v /docker/host/dir:/data (see docs.docker volumes).

For more about Redis Persistence, see http://redis.io/topics/persistence.

https://hub.docker.com/_/redis

tianon commented 3 years ago

Is there a question, suggestion, or request in here?

(This sounds like a statement to me, and I'm not understanding what you're hoping we'll do with it.)

x-yuri commented 3 years ago

An issue :) Suggestion to improve the documentation. Not a question.

The documentation is misleading about this. I'm not sure if this part is needed at all. Although maybe in older version of redis it really ran without persistence by default.

I'm not sure where that part of the documentation comes from. If it covers only the latest builds, then one option is to remove the section. Or suggest to run redis with a named volume. Or document how to run it with AOF. Although I'm not sure what effect would specifying the --appendonly yes option have:

https://github.com/docker-library/redis/blob/f634377/6.0/alpine/Dockerfile#L40-L48 https://github.com/docker-library/redis/issues/263

x-yuri commented 3 years ago

I just confirmed that redis apparently at least saves its state before shutdown. (What are its settings exactly is not clear since #263.) But if you're running Docker Swarm, you should name your mounts.

x-yuri commented 3 years ago

It seems that if you specify any argument to redis-server, they assume you are going to specify everything.

@yosifkit It totally looks that way, but on closer inspection it appears that redis only resets the save parameters (when argc >= 2). It's there since day one. Probably because there's no way to reset them via command line.

It can be cured by explicitly specifying the save params:

#!/bin/sh -eu
run() {
    cid=`docker run --rm -itd redis:alpine "$@"`
    docker exec "$cid" redis-cli config get save
    docker stop "$cid"
}
run
run --bind 0.0.0.0
run --save 3600 1 --save 300 100 --save 60 10000

Output:

save
3600 1 300 100 60 10000
fcdf7763cb52de51f4c99f3fea9d13a2aa99f4d56bd23f0da378e4a80f3e732e
save

554503ffeed5dfe3fc7232e3a646989d9e6745dc4d069aebd3124f756229f6fe
save
3600 1 300 100 60 10000
e7544eec533b3d657bb2f47e92121125a0326a8702b074714a5a0f4395a44f94
MattJustMatt commented 1 year ago

This is confusing. I want to run with no persistence, so I've appendonly and save in the config file, but a volume is still being created. Not the end of the world but it's not clear from the docs how to disable this.

jamesbraza commented 10 months ago

+1 to this, there's room for clarification. https://hub.docker.com/r/redis/redis-stack is where I am coming from

In its persistence section, it documents what happens when passing -v. However, what happens when one doesn't pass -v isn't described, like if the Docker container is stopped without -v, will one lose all data?