I'm running an ubuntu image in docker and i installed redis as a service
Here's how i start redis in the Dockerfile:
CMD redis-server --daemonize yes && /bin/bash
now whenever i make changes to the database and runredis-cli SAVE or redis-cli BGSAVE i expect to find a dump.rdbfile generated in /var/lib/redis but that doesn't happen
these two lines are from my redis.conf in docker:
dbfilename dump.rdb
dir /var/lib/redis
I don't want to mount my local dump.rdb file to the docker container.
How do i get redis to generate dump.rdb in docker?
Comment From: itamarhaber
Hello @AlyaGomaa
Please note that in order start the Redis server with a configuration file, the file's path must be provided as a command-line argument to redis-server. Given your CMD, it looks like you're not doing that, so the server starts with the default settings (except daemonize that is switched).
Comment From: AlyaGomaa
@itamarhaber
i changed the command to CMD redis-server /etc/redis/redis.conf --daemonize yes && /bin/bash
changed the save in /etc/redis/redis.conf to save 1 1
and then
SET foo 1
SAVE
and there's still no dump.rdb in /var/lib/redis/
Comment From: itamarhaber
What is the output of CONFIG GET dir?
Comment From: sundb
I'm curious about one thing, why do you use --daemonize yes in docker.
Comment From: AlyaGomaa
@itamarhaber 2) "/var/lib/redis"
Comment From: AlyaGomaa
@sundb no use i'm just used to starting it this way, starting it without --daemonize yes doesn't make any difference
Comment From: itamarhaber
I can try to reproduce - @AlyaGomaa can you share your Dockerfile?
Comment From: AlyaGomaa
@itamarhaber here it is Dockerfile.zip
Comment From: itamarhaber
I'm not able to reproduce the behavior with the provided Dockerfile:
/tmp/issue-8894 16:11:30
❯ docker run -it --rm --name foo foo
root@12bef475b3f5:/StratosphereLinuxIPS# redis-cli CONFIG GET dir
1) "dir"
2) "/var/lib/redis"
root@12bef475b3f5:/StratosphereLinuxIPS# cd /var/lib/redis
root@12bef475b3f5:/var/lib/redis# ls -al
total 12
drwxr-x--- 2 redis redis 4096 Apr 27 12:36 .
drwxr-xr-x 1 root root 4096 Apr 27 12:36 ..
root@12bef475b3f5:/var/lib/redis# redis-cli SAVE
OK
root@12bef475b3f5:/var/lib/redis# ls -al
total 16
drwxr-x--- 1 redis redis 4096 Apr 27 13:12 .
drwxr-xr-x 1 root root 4096 Apr 27 12:36 ..
-rw-r--r-- 1 root root 92 Apr 27 13:12 dump.rdb
root@12bef475b3f5:/var/lib/redis#
Comment From: AlyaGomaa
@itamarhaber
oh that's cool
when i run it without --network=host dump.rdb is there
```
docker run -it --rm slips
root@d80d418e8214:/StratosphereLinuxIPS# redis-cli CONFIG GET dir
1) "dir"
2) "/var/lib/redis"
root@d80d418e8214:/StratosphereLinuxIPS# cd /var/lib/redis
root@d80d418e8214:/var/lib/redis# ls -al
total 8
drwxr-x--- 2 redis redis 4096 Apr 27 11:13 .
drwxr-xr-x 1 root root 4096 Apr 27 11:13 ..
root@d80d418e8214:/var/lib/redis# redis-cli SAVE
OK
root@d80d418e8214:/var/lib/redis# ls -al
total 16
drwxr-x--- 1 redis redis 4096 Apr 27 13:29 .
drwxr-xr-x 1 root root 4096 Apr 27 11:13 ..
-rw-r--r-- 1 root root 92 Apr 27 13:29 dump.rdb
root@d80d418e8214:/var/lib/redis#
but when i run it with ```--network=host```
docker run -it --rm --net=host slips root@alya:/StratosphereLinuxIPS# redis-cli CONFIG GET dir 1) "dir" 2) "/var/lib/redis" root@alya:/StratosphereLinuxIPS# cd /var/lib/redis root@alya:/var/lib/redis# ls -al total 8 drwxr-x--- 2 redis redis 4096 Apr 27 11:13 . drwxr-xr-x 1 root root 4096 Apr 27 11:13 .. root@alya:/var/lib/redis# redis-cli SAVE OK root@alya:/var/lib/redis# ls -al total 8 drwxr-x--- 2 redis redis 4096 Apr 27 11:13 . drwxr-xr-x 1 root root 4096 Apr 27 11:13 ..
it saves dump.rdb to my local ``` /var/lib/redis ``` !
**Comment From: AlyaGomaa**
@itamarhaber now any changes in redis config file in docker are affecting the host!
in docker
redis-cli config set dir "/"
on the host
root@alya:/# redis-cli config get dir 1) "dir" 2) "/" ```
Comment From: itamarhaber
Regrettably, the with/without --network=host does not reproduce (on macOS) the new strange behavior that you're reporting. That said, this doesn't sound like a Redis issue, and perhaps more of a Docker thing, which I'm afraid there's very little we can help with in this repo.
Comment From: AlyaGomaa
ok thank you @itamarhaber
Comment From: itamarhaber
Sure, no problem. I'm closing this issue for now, but feel free to reopen/create a new one if needed.