简体   繁体   中英

(mac) dockers , how to connect to a redis server in the hosting machine from a containter

i am running a docker container on my mac machine using boot2docker :

I want to connect to redis-server i am running my hosting machine from inside the container.

  1. I have managed to connect from the container to a service i am running on the host machine using curl http://192.168.3.124:5000 (getting results)
  2. I have managed to connect to it , but I am not pulling data from it according to it's state. redisServer = redis.StrictRedis(host='192.168.3.124', port= "6379"); redisServer.get("2") (gets no results, from the hosting machine that key is set)

details : running the redis server :

[58781] 13 May 13:53:16.120 # Server started, Redis version 2.8.19
[58781] 13 May 13:53:16.120 * DB loaded from disk: 0.000 seconds
[58781] 13 May 13:53:16.120 * The server is now ready to accept connections on port 6379

ps aux |grep redis

partuck         58781   0.0  0.0  2469924   1652 s002  S+    1:53PM   0:00.03 redis-server *:6379
partuck         58728   0.0  0.7  2583104 115260   ??  S     1:53PM   0:00.47 /usr/local/opt/redis/bin/redis-server 127.0.0.1:6379

from the

Your host IP in the virtualbox that boot2docker setups is (typically) 10.0.2.2.

So you should try connecting to 10.0.2.2:6379

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM