需求
supervisor和php容器都是单独的,我要在supervisor容器中调用php容器中的 php artisan xx命令
环境来源
- 项目地址: dnmp
- 我需要的容器有,php,nginx,redis,supervisor
修改点
- 打开docker-compose.yml文件,找到supervisor,将注释去掉,增加挂载的文件,/var/run/docker.sock和/usr/bin/docker
volumes:
- ${SOURCE_DIR}:/www/:rw
- ${SUPERVISOR_LOG}:/var/log/supervisor/:rw
- ${SUPERVISOR_CONFIG}:/etc/supervisor/conf.d/:rw
- ${SUPERVISOR_CONF_FILE}:/etc/supervisor/supervisord.conf:ro
- /var/run/docker.sock:/var/run/docker.sock:rw
- /usr/bin/docker:/usr/bin/docker:rw
- 容器有,php,nginx,redis,supervisor
- 修改services/supervisor/Dockfile文件
FROM ubuntu
MAINTAINER phonecom<1053653379@qq.com>
RUN apt update
RUN apt install -y supervisor
USER root
WORKDIR /www
- 重新构建 supervisor
- 进入容器后 修改command
command=docker exec -i php sh -c "php /www/job/artisan queue:work --daemon"
;directory=/www/localhost/
priority=999 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; retstart at unexpected quit (default: true)
startsecs=10 ; number of secs prog must stay running (def. 10)
startretries=3 ; max # of serial start failures (default 3)
exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
stopsignal=QUIT ; signal used to kill process (default TERM)
stopwaitsecs=10 ; max num secs to wait before SIGKILL (default 10)
user=root ; setuid to this UNIX account to run the program
log_stdout=true
log_stderr=true ; if true, log program stderr (def false)
logfile=/var/log/supervisor/php.log
logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
logfile_backups=10 ; # of logfile backups (default 10)
stdout_logfile_maxbytes=20MB ; stdout 日志文件大小,默认 50MB
stdout_logfile_backups=20 ; stdout 日志文件备份数
stdout_logfile=/var/log/supervisor/php.stdout.log