Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

793
Views
How to connect to a Redis container using Docker Compose?

This docker-compose.yml seems to work OK:

version: '3'
services:
  web:
    image: web-app
    command: bundle exec rackup
    ports:
     - "9292:9292"
    links:
      - redis
  redis:
    image: redis

Command:

docker build -t web-app .; docker-compose up

The Web App is expecting a REDIS_URL config. Web App Dockerfile:

ENV REDIS_URL redis:6379

It seems that the Web App cannot connect to the Redis:

Redis::CannotConnectError - Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED):

So, what is the Redis URL for the Web App?

Do I need to expose the Redis port (6379)?

EDIT:

Thanks to @Andy Shinn, I see the redis url should be redis://6379.
Now I get Errno::EINVAL - Invalid argument - connect(2) for 0.0.24.235:6379. This may have to do with Redis v 3.2.8. I'll try another version and see if it works.

EDIT #2:

3.2.8 works fine with the app on my local machine, so that is not the issue.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!