title: How to configure docker to use redis with celery
body: <h3>docker-compose.yml</h3>
  <pre><code>version: '3.1'
  services:
  
    redis:
      image: redis:latest
      container_name: rd01
      ports:
       - '6379:6379'
  
    webapp:
      image: webapp
      container_name: wa01
      ports: 
        - &quot;8000:8000&quot;
      links:
        - redis
      depends_on:
        - redis
  
  
    celery:
      build: .
      container_name: cl01
      command: celery -A server worker -l info
      depends_on:
        - redis
  </code></pre>
  <p>I also don't feel I understand links and depends_on, I tried different combinations.</p>
  <p>Celery cannot connect to redis. I get the following error -</p>
  <pre><code>[2018-08-01 13:59:42,249: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused.
  </code></pre>
  <p>I believe I have set broker URLs correctly in settings.py in my django application (webapp image)</p>
  <pre><code>CELERY_BROKER_URL = 'redis://redis:6379/0' 
  CELERY_RESULT_BACKEND = 'redis://redis:6379/0'
  </code></pre>
  <p>What is the right way to dockerize a django project with celery and redis? TIA.</p>
  <h2>EDITS</h2>
  <h3>celery.py</h3>
  <pre><code>from __future__ import absolute_import, unicode_literals
  import os
  from celery import Celery
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
  
  app = Celery('server')
  app.config_from_object('django.conf:settings', namespace='CELERY')
  app.autodiscover_tasks()
  
  
  @app.task(bind=True)
  def debug_task(self):
      print('Request: {0!r}'.format(self.request))
  </code></pre>
  <p><a href="https://nofile.io/f/JKWyGqg2pvY/server.zip" rel="noreferrer">This is my django  project</a> to it's simplest form to reproduce the error.</p>