虽然searching这个问题,我发现:cron -f
应该启动服务。为什么Dockerfile中的cron服务没有运行?
所以我必须:
RUN apt-get install -qq -y git cron
下一页我:
CMD cron -f && crontab -l > pullCron && echo "* * * * * git -C ${HOMEDIR} pull" >> pullCron && crontab pullCron && rm pullCron
我dockerfile部署没有错误,但这个cron不会运行。我可以通过添加一行来启动cron服务?
PS:
我知道,在我的cron git的功能实际上应该是一个挂钩,但对我来说(也可能是替他人),这是学习如何与泊坞窗设置crons :-)
PPS :
完整Dockerfile(修订版):
RUN apt-get update && apt-get upgrade -y
RUN mkdir -p /var/log/supervisor
RUN apt-get install -qq -y nginx git supervisor cron wget
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN wget -O ./supervisord.conf https://raw.githubusercontent.com/..../supervisord.conf
RUN mv ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN apt-get install software-properties-common -y && apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449 && add-apt-repository 'deb http://dl.hhvm.com/ubuntu utopic main' && apt-get update && apt-get install hhvm -y
RUN cd ${HOMEDIR} && git clone ${GITDIR} && mv ./tybalt/* ./ && rm -r ./tybalt && git init
RUN echo "* * * * * 'cd ${HOMEDIR} && /usr/bin/git pull origin master'" >> pullCron && crontab pullCron && rm pullCron
EXPOSE 80
CMD ["/usr/bin/supervisord"]
PPPS:
Supervisord.conf:
[supervisord]
autostart=true
autorestart=true
nodaemon=true
[program:nginx]
command=/usr/sbin/nginx -c /etc/nginx/nginx.conf
[program:cron]
command = cron -f -L 15
autostart=true
autorestart=true
重复:http://stackoverflow.com/questions/20545554/how-do-i-start-cron-on-docker-ubuntu-base – Armand
嗨@Armand,我找到了这个答案,但我不'了解它是如何重复的?这实际上是使我添加'cron -f'添加'CMD'的末尾的问题,但这似乎没有运行 –
Docker使用单个进程启动实例。你能详细说明你开始使用哪个命令吗?我所学到的是,如果你需要更多的进程在运行,你应该考虑从命令行运行管理程序,并让它负责启用你想要的系统进程。 – Armand