title: Running Redis rq worker on Docker
body: <p>I am trying to make a queue of tasks using redis rq. I was trying to follow a tutorial but I am using docker. Below is my code-</p>
  <p>app.py</p>
  <pre><code>from flask import Flask, request
  import redis
  from rq import Queue
  
  import time
  app = Flask(__name__)
  
  r = redis.Redis()
  q = Queue(connection=r)
  
  def background_task(n):
  
      &quot;&quot;&quot; Function that returns len(n) and simulates a delay &quot;&quot;&quot;
  
      delay = 2
  
      print(&quot;Task running&quot;)
      print(f&quot;Simulating a {delay} second delay&quot;)
  
      time.sleep(delay)
  
      print(len(n))
      print(&quot;Task complete&quot;)
  
      return len(n)
  
  def index():
  
      if request.args.get(&quot;n&quot;):
  
          job = q.enqueue(background_task, request.args.get(&quot;n&quot;))
  
          return f&quot;Task ({job.id}) added to queue at {job.enqueued_at}&quot;
  
      return &quot;No value for count provided&quot;
  
  
  if __name__ == &quot;__main__&quot;:
      app.run()
  </code></pre>
  <p>Docker compose file-</p>
  <pre><code>version: &quot;3.8&quot;
  services:
    web:
      build: .
      ports:
        - &quot;5000:5000&quot;
      volumes:
        - .:/code
      environment:
        FLASK_ENV: development
       
        
    redis:
      image: &quot;redis:alpine&quot;
  
  </code></pre>
  <p>Dockerfile</p>
  <pre><code>FROM python:3.7-alpine
  WORKDIR /code
  ENV FLASK_APP=app.py
  ENV FLASK_RUN_HOST=0.0.0.0
  RUN apk add --no-cache gcc musl-dev linux-headers
  COPY requirements.txt requirements.txt
  RUN pip install -r requirements.txt
  EXPOSE 5000
  COPY . .
  CMD [&quot;flask&quot;, &quot;run&quot;]
  </code></pre>
  <p>Whenever I run '''docker-compose up --build''' and open http://localhost:5000/ I get Url not found
  Where am I going wrong?
  How is one supposed to use rq worker command in docker containers.</p>