Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Docker - Supervisor for queue worker

Hello,

I have an application running with docker, but I have a lot of things to learn about docker, I'm new with docker and I never used any supervisor.

I need to execute a supervisor for a custom queue worker.

The supervisor doesn't run the queue worker.

If I run the queue worker manually, it works fine.

docker-compose run --rm artisan rabbitmq:consume

If I just use the supervisor, it doesn't work.

Here is the configuration file of the supervisor.

; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

# [supervisorctl]
# serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/*.conf

And here the configuration file for the queue worker.

[program:rabbitmq-consume]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan rabbitmq:consume # sqs --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
numprocs=8
redirect_stderr=true
# stdout_logfile=/var/www/html/rabbitmq-consumer.log
stopwaitsecs=3600

I have installed the supervisor via docker-compose and a dockerfile.

  supervisor:
    build:
      context: .
      dockerfile: supervisor.dockerfile
    container_name: supervisor
    volumes:
      - ./src:/var/www/html
    depends_on:
      - php
      - rabbitmq
      - mariadb
FROM ubuntu:22.04

RUN apt-get update && apt-get install -y supervisor

RUN mkdir -p /var/log/supervisor

COPY supervisor/supervisord.conf /etc/supervisor/supervisord.conf
COPY supervisor/conf.d/rabbitmq-consume.conf /etc/supervisor/conf.d/rabbitmq-consume.conf

RUN service supervisor start

# RUN rm -f /var/run/supervisor.sock
# CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

Thanks for your help.

V

0 likes
1 reply
vincent15000's avatar

What do you think about this article ?

https://stackoverflow.com/questions/57563313/how-to-configure-supervisor-in-docker-correctly

Not sure about all the explanation, but what I have understood is that it's not a good idea to use a supervisor with docker and that it would be better to use docker-compose.

Does this mean that it's better to create a container just for executing the queue worker via simple command and tell docker to restart it unless it's stopped ?

Please or to participate in this conversation.