I have a dockerized setup running a Django app within which I use Celery tasks. Celery uses Redis as the broker.
Versioning:
When you use docker-compose, you aren't going to be using localhost
for inter-container communication, you would be using the compose-assigned hostname of the container. In this case, the hostname of your redis container is redis
. The top level elements under services:
are your default host names.
So for celery to connect to redis, you should try redis://redis:6379/0
. Since the protocol and the service name are the same, I'll elaborate a little more: if you named your redis service "butter-pecan-redis" in your docker-compose, you would instead use redis://butter-pecan-redis:6379/0
.
Also, docker-compose.dev.yml doesn't appear to have celery and redis on a common network, which might cause them not to be able to see each other. I believe they need to share at least one network in common to be able to resolve their respective host names.
Networking in docker-compose has an example in the first handful of paragraphs, with a docker-compose.yml to look at.