Hello,
I’m stuck with an error trying to set up celery instance with rabbitmq using docker-compose.
My compose file:
version: '3.7'
services:
rabbit:
hostname: rabbit
image: rabbitmq:3.8
expose:
- 5672
celery:
image: celery
volumes:
- ./:/code
environment:
- PYTHONPATH=/code
command: celery -A task worker
depends_on:
- rabbit
links:
- "rabbit:rabbit"
My celery code:
from celery import Celery
app = Celery('tasks', broker='amqp://rabbit:5672/')
@app.task
def add(x, y):
return x + y
The sad outcome:
celery_1 | [2020-03-24 15:29:58,318: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@rabbit:5672//: [Errno 113] No route to host.
Do you guys have any idea what might be the issue?
I’ve tried creating a custom user, but it didn’t work (also, looks like problem is with domain resolution, not authentication)
When I docker exec to celery container I can totally ping rabbit container:
$ docker exec -ti celery-check_celery_1 ping rabbit
PING rabbit (172.23.0.2): 56 data bytes
64 bytes from 172.23.0.2: icmp_seq=0 ttl=64 time=0.077 ms
64 bytes from 172.23.0.2: icmp_seq=1 ttl=64 time=0.066 ms
64 bytes from 172.23.0.2: icmp_seq=2 ttl=64 time=0.069 ms