1

I'm running celery-worker and celery-beat inside docker.

When I do celery logs -f celery-worker I can see the celery is up and running

Now I want to send some tasks (for test purposes) to the worker..

There seems to be two ways to do that (How can I run a celery periodic task from the shell manually?) using django shell and using celery command itself I don't have manage.py in the docker, so I'm using the celery command

However, all celery commands including celery inspect registered hangs and gives me nothing.

How can I send tasks to celery running inside docker?

customcommander
  • 17,580
  • 5
  • 58
  • 84
eugene
  • 39,839
  • 68
  • 255
  • 489

1 Answers1

0

I believe it hangs because you cannot connect to the broker.

You need the CELERY_BROKER_URL environment variable to be set to the correct url before running celery commands.

If you are using docker compose you should have a broker service more or less similar to this:

  broker:
    container_name: broker
    image: redis:6.0
    ports:
      - 6379:6379
    volumes:
      - ./volumes/redis_data:/data

Basically we can connect to our broker from our host machine using localhost:6379 .

Therefore in the terminal you can set the following env var

$ export CELERY_BROKER_URL=redis://localhost:6379/0

and celery commands should return a result now.

NBWL
  • 141
  • 6