如何在php-fpm-alpine docker容器中运行cron作业? [英] How to run cron jobs inside php-fpm-alpine docker container?

查看:297
本文介绍了如何在php-fpm-alpine docker容器中运行cron作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何在容器.

我发现了这一点:如何运行docker容器中的cron作业

但这覆盖了CMD,我不知道保持php-fpm正常运行

But that overrides the CMD, I don't know hot to keep php-fpm working

推荐答案

当您需要在docker容器中运行多个进程时,一种解决方案是使用 supervisord 作为主要说明.Docker将启动并监视 supervisord ,这反过来将启动您的其他进程.

When you need to run multiple processes in your docker container a solution is to use supervisord as the main instruction. Docker will start and monitor supervisord which in turn will start your other processes.

Docker文件示例:

Docker File Example:

FROM debian:9
...
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/my.conf"]

Supervisord配置示例(/etc/supervisor/my.conf):

Supervisord config example (/etc/supervisor/my.conf):

[supervisord]
nodaemon=true

[program:cron]
command=/usr/sbin/crond -f -l 8
stdout_logfile=/dev/stdout
stderr_logfile=/dev/stderr
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0
autorestart=true

[program:php-fpm]
command=docker-php-entrypoint php-fpm

请注意,最好配置超级用户以将日志输出到/dev/stdout /dev/stderr ,以允许Docker处理这些日志.否则,随着文件写入量的增加,您会冒着容器随着时间的流逝而变慢的风险.

Note that it is desirable to configure supervisord to output the logs to /dev/stdout and /dev/stderr to allow docker to handle these logs. Otherwise you risk your container to slow down over time as the amount of file writes increases.

这篇关于如何在php-fpm-alpine docker容器中运行cron作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆