cron

给debian的docker容器添加crontab定时任务

别来无恙 提交于 2020-11-09 01:00:21
现在大部分的docke镜像是基于debian # cat /etc/issue Debian GNU/Linux 9 \n \l Docker容器是不支持后台服务的,像systemctl service crontab这些后台运行的服务是不能通过 RUN systemctl start nginx 类似这种方案实现的,你必须写自己的entrypoint脚本来启动。本文记录了基于Debian的docker容器设置定时任务的方式。 案例背景 我部署一个前端项目,使用nginx镜像,由于官方镜像是基于debian,对比alpine也不觉得体积差多少,于是就使用debian作为容器系统。 Dockerfile看起来是这样的 FROM nginx:1.15.10 MAINTAINER Ryan Miao COPY sources.list /etc/apt/sources.list RUN apt-get update && apt-get install -y net-tools procps curl wget vim telnet cron 、 && apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* RUN mkdir -p /data/log/nginx && mkdir -p /data/web &