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

vincent15000's avatar

Laravel with docker - Supervisor - Unlinking stale socket /var/run/supervisor.sock

Hello,

I have followed the docker series on Laracast, very interesting.

I need to add a supervisor with docker.

I'm writing the docker-compose.yml file, but I get this error.

Unlinking stale socket /var/run/supervisor.sock exited with code 0

I have tried to add these lines in the dockerfile, but it doesn't work better.

RUN rm -f /var/run/supervisor.sock

CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

And I rebuild the container.

docker-compose up --build

And I get the same error.

Can you help me to understand why ?

Thanks a lot.

V

0 likes
2 replies
vincent15000's avatar

When I start the supervisor instead of using CMD, I don't have the error anymore, but the supervisor exit with code 0.

RUN service supervisor start

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

And I don't have any other information logged to help understand how to solve this.

I have read on the web that it can have something to do with the user, but I have set user=root in the supervisor configuration file, so it should work no ?

vincent15000's avatar
vincent15000
OP
Best Answer
Level 63

I have solved the problem with these files : docker-compose.yml and supervisor and rabbitmq configuration files.

FROM php:8.3-cli

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

RUN docker-php-ext-install pdo pdo_mysql

RUN mkdir -p /var/log/supervisor

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

CMD ["/usr/bin/supervisord"]
; 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]
nodaemon=true
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
[program:rabbitmq-consume]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan rabbitmq:consume
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/rabbitmq-consumer.log
stopwaitsecs=3600

Please or to participate in this conversation.