Running celery worker + beat in the same container Running celery worker + beat in the same container docker docker

Running celery worker + beat in the same container


docker run only one CMD, so only the first CMD get executed, the work around is to create a bash script that execute both worker and beat and use the docker CMD to execute this script


You can use celery beatX for beat. It is allowed (and recommended) to have multiple beatX instances. They use locks to synchronize.

Cannot say if it is production-ready, but it works for me like a charm (with -B key)


I got by putting in the entrypoint as explained above, plus I added the &> to have the output in a log file.

my entrypoint.sh

#!/bin/bashpython3 manage.py migratepython3 manage.py migrate catalog --database=catalogpython manage.py collectstatic --clear --noinput --verbosity 0# Start Celery Workerscelery worker --workdir /app --app dri -l info &> /log/celery.log  &# Start Celery Beatcelery worker --workdir /app --app dri -l info --beat &> /log/celery_beat.log  &python3 manage.py runserver 0.0.0.0:8000