Search code examples
dockerredisdocker-composeredis-cli

Read data of a redis container from the host machine


I set up with docker-compose a redis container and a node app which uses the redis DB.

All works but I didn't mount any volume so I can't access the data of the redis DB from the host. I also tried to deplou a container with another node app which tries to connect the redis DB but I can't connect to the redis client Error: Redis connection to redis:6379 failed

I don't want to docker-compose down the container because the redis data will be lost

Yes, I'm new to the Docker paradox


Solution

  • If you're using the redis image listed here, or one like it, you should be able to read the data by executing redis-cli in the same active container:

    docker exec -it vigilant_fermat redis-cli
    

    In my example, vigilant_fermat is the name of the container that Docker randomly assigned for me. Substitute the correct container name for your instance.