Question

I am a newbie of docker and running docker inside vagrant host.

I am running redis service on host interface which is working an I am able to connect with it on host interface like localhost:6379. But I am not able to connect with it inside a docker container.

I am running docker container as

docker run -t -i -p 80:80 apache-latest /bin/bash

I am able to ping host interface inside the docker container on docker0 IP 172.17.42.1 and lx*** ip 10.0.3.1.

I am getting Connection refused [tcp://172.17.42.1:6379] error. I tried connecting with redis on host interface by providing docker0 and lx* ip I am getting connection refused error.**

Please help how to connect with redis inside a docker container...

Était-ce utile?

La solution

You should check which port you bind redis to in your redis config file:

# config file directive to check:
bind 127.0.0.1

You should bind it to one of the addresses you can ping (f.e. 10.0.3.1).

Alternatively, you can pass a redis socket to container:

# uncomment this section in config file:
unixsocket /lnk/redis.sock
unixsocketperm 755

Then you can use -v /lnk:/lnk to pass the directory with the socket to container. You can communicate with redis using this socket instead of IP address.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top