title: Docker, Celery, method failing on compose
body: <p>I'm trying a FastAPI based API with celery, redis, and rabitMQ as the background tasks.
  when doing <code>docker-compose up</code>, the redis, rabbit, and flower parts work, I'm able to access the flower dashboard.</p>
  <p>but it then gets stuck in the celery part.</p>
  <p>the error:</p>
  <pre><code> rabbitmq_1       | 2020-09-08 06:32:38.552 [info] &lt;0.716.0&gt; connection &lt;0.716.0&gt; (172.22.0.6:49290 -&gt; 172.22.0.2:5672): user 'user' authenticated and granted access to vhost '/'
  celery-flower_1  | [W 200908 06:32:41 control:44] 'stats' inspect method failed
  celery-flower_1  | [W 200908 06:32:41 control:44] 'active_queues' inspect method failed
  celery-flower_1  | [W 200908 06:32:41 control:44] 'registered' inspect method failed
  celery-flower_1  | [W 200908 06:32:41 control:44] 'scheduled' inspect method failed
  celery-flower_1  | [W 200908 06:32:41 control:44] 'active' inspect method failed
  celery-flower_1  | [W 200908 06:32:41 control:44] 'reserved' inspect method failed
  celery-flower_1  | [W 200908 06:32:41 control:44] 'revoked' inspect method failed
  celery-flower_1  | [W 200908 06:32:41 control:44] 'conf' inspect method failed
  </code></pre>
  <p>My docker-compose file:</p>
  <pre><code>version: &quot;3.7&quot;
  
  services:
    rabbitmq:
      image: &quot;bitnami/rabbitmq:3.7&quot;
      ports:
        - &quot;4000:4000&quot;
        - &quot;5672:5672&quot;
      volumes:
        - &quot;rabbitmq_data:/bitnami&quot;
  
    redis:
      image: &quot;bitnami/redis:5.0.4&quot;
      environment:
        - REDIS_PASSWORD=password123
      ports:
        - &quot;5000:5000&quot;
      volumes:
        - &quot;redis_data:/bitnami/redis/data&quot;
  
    celery-flower:
      image: gregsi/latest-celery-flower-docker:latest
      environment:
        - AMQP_USERNAME=user
        - AMQP_PASSWORD=bitnami
        - AMQP_ADMIN_USERNAME=user
        - AMQP_ADMIN_PASSWORD=bitnami
        - AMQP_HOST=rabbitmq
        - AMQP_PORT=5672
        - AMQP_ADMIN_HOST=rabbitmq
        - AMQP_ADMIN_PORT=15672
        - FLOWER_BASIC_AUTH=user:test
      ports:
        - &quot;5555:5555&quot;
      depends_on:
        - rabbitmq
        - redis
  
    fastapi:
      build: .
      ports:
        - &quot;8000:8000&quot;
      depends_on:
        - rabbitmq
        - redis
      volumes:
        - &quot;./:/app&quot;
      command: &quot;poetry run uvicorn app/app/main:app --bind 0.0.0.0:8000&quot;
  
    worker:
      build: .
      depends_on:
        - rabbitmq
        - redis
      volumes:
        - &quot;./:/app&quot;
      command: &quot;poetry run celery worker -A app.app.worker.celery_worker -l info -Q test-queue -c 1&quot;
  
  volumes:
    rabbitmq_data:
      driver: local
    redis_data:
      driver: local
  </code></pre>
  <p>My celery app:</p>
  <pre class="lang-py prettyprint-override"><code>celery_app = Celery(
      &quot;worker&quot;,
      backend=&quot;redis://:password123@redis:6379/0&quot;,
      broker=&quot;amqp://user:bitnami@rabbitmq:5672//&quot;
  )
  
  celery_app.conf.task_routes = {
      &quot;app.app.worker.celery_worker.compute_stock_indicators&quot;: &quot;stocks-queue&quot;
  }
  
  celery_app.conf.update(task_track_started=True)
  </code></pre>
  <p>celery worker:</p>
  <pre class="lang-py prettyprint-override"><code>@celery_app.task(acks_late=True)
  def compute_stock_indicators(stocks: list, background_task):
      stocks_with_indicators = {}
      for stock in stocks:
          current_task.update_state(state=Actions.STARTED,
                                    meta={f&quot;starting to fetch {stock}'s indicators&quot;})
  
          stock_indicators = fetch_stock_indicators(stock)  # Fetch the stock most recent indicators
          current_task.update_state(state=Actions.FINISHED,
                                    meta={f&quot;{stock}'s indicators fetched&quot;})
  
          stocks_with_indicators.update({stock: stock_indicators})
  
          current_task.update_state(state=Actions.PROGRESS,
                                    meta={f&quot;predicting {stocks}s...&quot;})
  </code></pre>
  <p>The Fast API function:</p>
  <pre class="lang-py prettyprint-override"><code>log = logging.getLogger(__name__)
  rabbit = RabbitMQHandler(host='localhost', port=5672, level=&quot;DEBUG&quot;)
  log.addHandler(rabbit)
  
  
  def celery_on_message(body):
      &quot;&quot;&quot;
      Logs the initiation of the function
      &quot;&quot;&quot;
      log.warning(body)
  
  
  def background_on_message(task):
      &quot;&quot;&quot;
      logs the function when it is added to queue
      &quot;&quot;&quot;
      log.warning(task.get(on_message=celery_on_message, propagate=False))
  
  
  app = FastAPI(debug=True)
  
  
  @app.post(&quot;/&quot;)
  async def initiator(stocks: FrozenSet, background_task: BackgroundTasks, ):
      &quot;&quot;&quot;
      :param stocks: stocks to be analyzed
      :type stocks: set
      :param background_task: initiate the tasks queue
      :type background_task: starlette.background.BackgroundTasks
      &quot;&quot;&quot;
      log.warning(msg=f'beginning analysis on: {stocks}')
      task_name = &quot;app.app.worker.celery_worker.compute_stock_indicators&quot;
  
      task = celery_app.send_task(task_name, args=[stocks, background_task])
      background_task.add_task(background_on_message, task)
      return {&quot;message&quot;: &quot;Stocks indicators successfully calculated,stocks sent to prediction&quot;}
  </code></pre>