title: Docker compose - Name or service not known when calling service from another container
body: <p>I have a Django app in one container, trying to compose it with Redis and Mysql containers. However, calling</p>
  
  <pre><code>redis://redis:6379
  </code></pre>
  
  <p>from Django app, gives me</p>
  
  <pre><code>ConnectionError: Error -2 connecting redis://redis:6379. Name or service not known.
  </code></pre>
  
  <p>I do not see any difference in my setup, compare to other working solutions. Do I miss something?
  My docker-compose.yml</p>
  
  <pre><code>version: '3'
  
  services:
    web:
      build: .
      environment:
        - REDIS_HOST=redis
      restart: always
      command: bash -c "python manage.py runserver --settings=settings.production_cs 0.0.0.0:8000"
      container_name: eprofi
      volumes:
        - .:/eprofi
      ports:
        - "8000:8000"
      depends_on:
        - db
        - redis
      links:
        - db:postgres
        - redis:redis
    db:
      image: mysql:latest
      command: mysqld --default-authentication-plugin=mysql_native_password
      volumes:
        - "./mysql:/var/lib/mysql"
      ports:
        - "3306:3306"
      restart: always
      environment:
        - MYSQL_ROOT_PASSWORD=secret123
        - MYSQL_DATABASE=django_app
        - MYSQL_USER=django_app
        - MYSQL_PASSWORD=django_app123
    redis:
      restart: always
      image: redis:latest
      ports:
        - "6379:6379"
  </code></pre>
  
  <p>My Dockerfile</p>
  
  <pre><code># We Use an official Python runtime as a parent image
  FROM python:2.7.13
  ENV DEBIAN_FRONTEND noninteractive
  
  ENV PYTHONDONTWRITEBYTECODE 1
  # The enviroment variable ensures that the python output is set straight
  # to the terminal with out buffering it first
  ENV PYTHONUNBUFFERED 1
  
  # create root directory for our project in the container
  RUN mkdir /www
  
  # Set the working directory to /www
  WORKDIR /www
  
  #Upgrade pip
  RUN pip install pip -U
  
  #Install dependencies
  ADD requirements.txt /www/
  RUN pip install -r requirements.txt --src /usr/local/src
  
  # Copy the current directory contents into the container at /www
  ADD . /www/
  </code></pre>
  
  <p>Then I do</p>
  
  <pre><code>docker-compose build
  docker-compose up
  </code></pre>
  
  <p>Everything starts as expected, but calling Redis with "redis://redis:6379" gives the above "Name or service not known." error.</p>
  
  <p>My tools</p>
  
  <pre><code>docker-compose version 1.17.1, build unknown
  docker-py version: 2.5.1
  Client: Docker Engine - Community
   Version:           19.03.4
  </code></pre>
  
  <p><strong>UPDATE 1</strong>
  How I call Redis from python app (old Django).</p>
  
  <p>Settings of Django app:</p>
  
  <pre><code>CACHES = {
      'my_cache': {
          'BACKEND': 'redis_cache.RedisCache',
          'LOCATION': 'redis://{}:{}'.format(REDIS_HOST, REDIS_PORT),
          'KEY_PREFIX': 'project/my_cache',
          'TIMEOUT': 60*60*24,  # expire in 24 hours
          'OPTIONS': {
              'DB': 1,
              'PARSER_CLASS': 'redis.connection.HiredisParser'
          }
      },
  }
  </code></pre>
  
  <p>Call:</p>
  
  <pre><code>cache = get_cache('my_cache')
  cache.get(cache_key)
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Command</p>
  
  <pre><code>ping redis
  </code></pre>
  
  <p>run in the container gives me an error </p>
  
  <pre><code>ping: unknown host
  </code></pre>