How to connect to a Redis container using Docker Compose?

The issue is that redis is “variable” that will be interpolated in the Dockerfile.

ENV REDIS_URL redis:6379

But the Redis URL should start with the literal redis.

So, the fix is updating the docker compose:

redis_db:
  image: redis:3.2.8

The desired config is:

REDIS_URL=redis://redis_db:6379

Thanks to BMitch and Andy Shinn for helping me figure this out.

Leave a Comment