I'm trying to connect from inside a Docker container to a local Redis server on my machine. What I did so far:
redis-cli -h 172.17.0.3 -p 6379
ifconfig
inside the container)What's the trick I'm not thinking of in order to get a working connection?
I already tried to set "bind 0.0.0.0" in my redis.conf
but that had no effect. I also tried to forward the port 6379 to 6379 when running the container but I get an error saying the address is already in use.
Thanks in advance!
You should not connect to IP address of the container, but IP of the host (one you see on host for Docker bridge). Looking at your question it should be 172.17.0.1
You can do this:
$host_ip
docker run -it --add-host redis_server:$host_ip ubuntu bash
Now from inside container you will be able to reach Redis server via hostname redis_server
running on your host machine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With