Docker Community Forums

Share and learn in the Docker community.

Redis db is created in my local computer instead of inside the container!

I’m running docker for linux and using an ubuntu image. I installed redis as a service

here’s my dockerfile: https://github.com/redis/redis/files/6384165/Dockerfile.zip

here’s how i start the docker image:

docker run -it --rm --net=host imagename

Here’s how i start redis in the Dockerfile:
CMD redis-server /etc/redis/redis.conf && /bin/bash

now whenever i make changes to the database and runredis-cli SAVE or redis-cli BGSAVE i expect to find a dump.rdb file generated in /var/lib/redis but instead i get nothing and dump.rdb is saved to my local /var/lib/redis !!
these two lines are from my redis.conf in docker:

dbfilename dump.rdb
dir /var/lib/redis 

when i run without --network==host i find dump.rdb inside the container!!

also 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) "/"

How do i get redis to generate dump.rdb inside the docker container and what is causing this behavior?