DoubleDecker
DoubleDecker

Reputation: 31

Celery not writing logs to file in Docker

Celery does not appear to be writing any log files when run in a Docker container. The same command works fine when run outside of Docker.

In my docker-compose.yml file:

  celery_main:
    build:
      context: .
      dockerfile: Dockerfile
      command: bash -c "sleep 20 && celery -A my_project worker -n 1 -Q celery -c 10 -l info -E --logfile=celery_main.log"
    links:
      - db
      - redis
      - web
    depends_on:
      - db
      - redis

I am running Celery as a regular user. When I log into the working directory inside the container with bash, I can create files, so I don't understand what is stopping Celery from creating log files? I get logging printed to STDOUT as usual.

Upvotes: 1

Views: 2116

Answers (1)

Ayush Pallav
Ayush Pallav

Reputation: 1057

The log file is being generated inside the container according to your compose file. You should consider mounting the volume to make it available on the host system.

Alternatively, all docker containers generate log files in /var/lib/docker/containers//-json.log

You can directly fetch your logs from there as well.

Upvotes: 3

Related Questions