docker-compose: redis connection refused between containers

后端 未结 1 1756
温柔的废话
温柔的废话 2021-02-07 04:59

I am trying to setup a docker-compose file that is intended to replace a single Docker container solution that runs several processes (RQ worker, RQ dashboard and a Flask applic

1条回答
  •  悲&欢浪女
    2021-02-07 05:13

    In your code localhost from rq-worker1 is rq-worker1 itself, not redis and you can't reach redis:6379 by connect to localhost from rq-worker1. But by default redis and rq-worker1 are in the same network and you can use service name as a domain name in that network. It means, that you can connect to redis service from rq-worker1 using redis as a domain name, for instance: client.connect(("redis", 6379))

    You should replace localhost with redis in config of rq-worker1.

    0 讨论(0)
提交回复
热议问题