主pipe没有启动到我的docker集装箱(Laravel项目)
主pipe没有启动到我的容器,我无法运行我的php artisan queue:work
我的laravel项目的php artisan queue:work
命令。
从我的Dockerfile中提取
# Add worker to supervisor config file COPY laravel-worker.conf /etc/supervisor/conf.d/ CMD ["/usr/bin/supervisord"]
这里是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
当我进入容器时,主pipe服务没有启动:
root@e7227ef40f63:/# service supervisor status supervisord is not running.
过程如下:
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
我编辑我的DockerFile并把这一行:
ENTRYPOINT service ssh restart && service apache2 restart && service cron start && /usr/bin/supervisord && bash
当容器启动时,服务现在已经开始:
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
但它接缝,主pipe不启动我的configuration文件,因为我没有看到应该运行的8个进程..
这是不好的部分:
&& bash /usr/bin/supervisord
supervisord
不是一个bash脚本。 按照原样执行: && /usr/bin/supervisord
。
但是 ,我build议您完全避免在容器中使用service
。 一般来说,运行多个进程到一个容器被认为是一个反模式 ,但是如果你真的需要它,最好只使用supervisor
。 为每个进程(cron,sshd等)创build一个.conf
文件,并且只运行你的CMD
supervosord。