title: How to connect to a Redis container using Docker Compose?
body: <p>This <code>docker-compose.yml</code> seems to work OK:</p>
  
  <pre><code>version: '3'
  services:
    web:
      image: web-app
      command: bundle exec rackup
      ports:
       - "9292:9292"
      links:
        - redis
    redis:
      image: redis
  </code></pre>
  
  <p>Command:</p>
  
  <pre><code>docker build -t web-app .; docker-compose up
  </code></pre>
  
  <p>The Web App is expecting a REDIS_URL config. Web App Dockerfile:</p>
  
  <pre><code>ENV REDIS_URL redis:6379
  </code></pre>
  
  <p>It seems that the Web App cannot connect to the Redis:</p>
  
  <pre><code>Redis::CannotConnectError - Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED):
  </code></pre>
  
  <p>So, what is the Redis URL for the Web App?</p>
  
  <p>Do I need to expose the Redis port (6379)?</p>
  
  <p>EDIT:</p>
  
  <p>Thanks to @Andy Shinn, I see the redis url should be <code>redis://6379</code>.<br>
  Now I get <code>Errno::EINVAL - Invalid argument - connect(2) for 0.0.24.235:6379</code>. This may have to do with Redis v 3.2.8. I'll try another version and see if it works.</p>
  
  <p>EDIT #2:  </p>
  
  <p>3.2.8 works fine with the app on my local machine, so that is not the issue.</p>