简体   繁体   中英

Supervisor is not started into my docker container (Laravel project)

Supervisor is not started into my container and i am not able to run my php artisan queue:work command for my laravel project.

Extract from my Dockerfile

# Add worker to supervisor config file
COPY laravel-worker.conf /etc/supervisor/conf.d/

CMD ["/usr/bin/supervisord"]

Here is the laravel-worker.conf:

[program:laravel-worker]
command=php /var/www/test/current/artisan queue:work --tries=3
user=myuser
process_name=%(program_name)s_%(process_num)d
directory=/var/www/test/current
stdout_logfile=/tmp/supervisord.log
redirect_stderr=true
numprocs=1
autostart=true
autorestart=true

When i go into the container, the supervisor service is not started:

root@e7227ef40f63:/# service supervisor status
supervisord is  not running.

And process are following:

root@e7227ef40f63:/# ps -aux | grep supervisor
root         1  0.0  0.0   4328   652 ?        Ss   18:21   0:00 /bin/sh -c service ssh restart && service apache2 restart && service cron start && bash /usr/bin/supervisord
root       365  0.0  0.0  55808 10632 ?        Ss   18:25   0:00 /usr/bin/python /usr/bin/supervisord
root       380  0.0  0.0  11120   712 ?        S+   18:27   0:00 grep supervisor

UPDATE

I edited my DockerFile and put this line:

ENTRYPOINT service ssh restart && service apache2 restart && service cron start && /usr/bin/supervisord && bash 

The service is now well started when the container starts :

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.1  0.0   4328   652 ?        Ss   05:20   0:00 /bin/sh -c service ssh restart && service apache2 restart && service cron start && /usr/bin/supervisord && bash
root        25  0.0  0.0  55176  1140 ?        Ss   05:20   0:00 /usr/sbin/sshd
root        43  0.1  0.0 406408 25504 ?        Ss   05:20   0:00 /usr/sbin/apache2 -k start
www-data    46  0.0  0.0 406440  8416 ?        S    05:20   0:00 /usr/sbin/apache2 -k start
www-data    47  0.0  0.0 406440  8416 ?        S    05:20   0:00 /usr/sbin/apache2 -k start
www-data    48  0.0  0.0 406440  8416 ?        S    05:20   0:00 /usr/sbin/apache2 -k start
www-data    49  0.0  0.0 406440  8416 ?        S    05:20   0:00 /usr/sbin/apache2 -k start
www-data    50  0.0  0.0 406440  8416 ?        S    05:20   0:00 /usr/sbin/apache2 -k start
root        59  0.0  0.0  17484   636 ?        Ss   05:20   0:00 /usr/sbin/cron
root        63  0.2  0.0  56012 10788 ?        Ss   05:20   0:00 /usr/bin/python /usr/bin/supervisord
root        64  0.0  0.0  20032  1280 ?        S    05:20   0:00 bash
root        89  0.1  0.0  20240  1996 ?        Ss   05:20   0:00 bash
root       112  0.0  0.0  17492  1168 ?        R+   05:21   0:00 ps -aux

But it seams that supervisor doesn't start my config file because i don't see the 8 processes that should be run..

This is the bad part:

&& bash /usr/bin/supervisord

supervisord is not a bash script. Execute it as is: && /usr/bin/supervisord .

However , I recommend you to completely avoid using service in a container. In general, running more than one process into a container is considered an antipattern , but if you really need it, better only use supervisor . Create a .conf file for each process (cron, sshd, etc) and only run supervosord as is in your CMD .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM