redis / docker-library-redis

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

Redis is persisting AOF files and snapshot files in the wrong directory #383

Closed Xmaxer closed 11 months ago

Xmaxer commented 11 months ago

I have a docker-compose definition that looks like this:

  redis:
    image: redis/redis-stack-server:7.2.0-v5
    restart: always
    ports:
      - '7100-7103:6379'
    command: 'redis-server /redis/redis.conf --appendonly yes --save 30 1'
    volumes:
      - ./path/to/redis.conf:/redis/redis.conf
      - ./path/to/users.acl:/redis/users.acl
      - redis_objects_db_data:/data

Where the redis_objects_db_data is actually a NFS volume, so it's not on the local machine.

Everything seems fine on the Redis side, no errors. The logs look like this:


2023-11-04T17:44:23.926+00:00 | 1:M 04 Nov 2023 17:44:23.926 * Server initialized
-- | --
  | 2023-11-04T17:44:23.929+00:00 | 1:M 04 Nov 2023 17:44:23.929 * Creating AOF base file appendonly.aof.1.base.rdb on server start
  | 2023-11-04T17:44:23.931+00:00 | 1:M 04 Nov 2023 17:44:23.931 * Creating AOF incr file appendonly.aof.1.incr.aof on server start
  | 2023-11-04T17:44:23.931+00:00 | 1:M 04 Nov 2023 17:44:23.931 * Ready to accept connections tcp
  | 2023-11-04T17:44:54.034+00:00 | 1:M 04 Nov 2023 17:44:54.034 * 100 changes in 30 seconds. Saving...
  | 2023-11-04T17:44:54.034+00:00 | 1:M 04 Nov 2023 17:44:54.034 * Background saving started by pid 14
  | 2023-11-04T17:44:54.102+00:00 | 14:C 04 Nov 2023 17:44:54.102 * DB saved on disk
  | 2023-11-04T17:44:54.103+00:00 | 14:C 04 Nov 2023 17:44:54.102 * Fork CoW for RDB: current 0 MB, peak 0 MB, average 0 MB
  | 2023-11-04T17:44:54.135+00:00 | 1:M 04 Nov 2023 17:44:54.134 * Background saving terminated with success

Problem is, when I enter my docker container to inspect where the files are going, here is the result:

root@831a10da14ca:/# ls -la
total 7356
drwxr-xr-x.   1 root root      56 Nov  4 17:45 .
drwxr-xr-x.   1 root root      56 Nov  4 17:45 ..
-rwxr-xr-x.   1 root root       0 Nov  4 17:44 .dockerenv
drwxr-xr-x.   2 root root     103 Nov  4 17:44 appendonlydir
lrwxrwxrwx.   1 root root       7 Oct  4 02:08 bin -> usr/bin
drwxr-xr-x.   2 root root       6 Apr 18  2022 boot
drwxrwxrwx.   4  999  999    6144 Nov  2 19:03 data
drwxr-xr-x.   5 root root     340 Nov  4 17:44 dev
-rw-r--r--.   1 root root 7521662 Nov  4 17:45 dump.rdb
-rwxr-xr-x.   1 root root    1269 Oct 29 08:41 entrypoint.sh
drwxr-xr-x.   1 root root      66 Nov  4 17:44 etc
drwxr-xr-x.   1 root root      20 Oct 29 08:42 home
lrwxrwxrwx.   1 root root       7 Oct  4 02:08 lib -> usr/lib
lrwxrwxrwx.   1 root root       9 Oct  4 02:08 lib32 -> usr/lib32
lrwxrwxrwx.   1 root root       9 Oct  4 02:08 lib64 -> usr/lib64
lrwxrwxrwx.   1 root root      10 Oct  4 02:08 libx32 -> usr/libx32
drwxr-xr-x.   2 root root       6 Oct  4 02:08 media
drwxr-xr-x.   2 root root       6 Oct  4 02:08 mnt
drwxr-xr-x.   1 root root      25 Oct 29 08:42 opt
dr-xr-xr-x. 270 root root       0 Nov  4 17:44 proc
drwxr-xr-x.   2 root root      41 Nov  4 17:44 redis
drwx------.   2 root root      37 Oct  4 02:12 root
drwxr-xr-x.   5 root root      46 Oct  4 02:12 run
lrwxrwxrwx.   1 root root       8 Oct  4 02:08 sbin -> usr/sbin
drwxr-xr-x.   2 root root       6 Oct  4 02:08 srv
dr-xr-xr-x.  13 root root       0 Nov  4 16:22 sys
drwxrwxrwt.   2 root root       6 Oct  4 02:12 tmp
drwxr-xr-x.   1 root root      56 Oct  4 02:08 usr
drwxr-xr-x.   1 root root      19 Oct  4 02:12 var

root@831a10da14ca:/# ls -la data
total 12
drwxrwxrwx. 4  999  999 6144 Nov  2 19:03 .
drwxr-xr-x. 1 root root   56 Nov  4 17:45 ..
drwxrwxrwx. 2  999  999 6144 Oct 29 08:43 redis
drwxrwxrwx. 2  999  999 6144 Oct 29 08:43 redisinsight

root@831a10da14ca:/# ls -la data/redis
total 8
drwxrwxrwx. 2 999 999 6144 Oct 29 08:43 .
drwxrwxrwx. 4 999 999 6144 Nov  2 19:03 ..

As you can see, the dump.rdb and appendonlydir files/directorties are in the root folder. And the data folder is completely empty.

Is there any ideas as to what's going on? I have other systems/databases running that use a similar NFS setup and they work and persist their data just fine.

yosifkit commented 11 months ago

This repo is for the redis image. We do not maintain the redis/redis-stack-server images. It looks like that is over in https://github.com/redis-stack/redis-stack.

Their entypoint seems to set a dir for the data. But I'd point out that your command: is overriding their entrypoint script, since they set it as CMD not ENTRYPOINT, so unless you set dir in your config, it would not be set and default to the working directory (/ since they don't set anything in their Dockerfile).