docker容器使用cron任务计划

当前有bash环境情况下exec到容器内部运行命令下载
root@0f76222d94c0:~# apt-get install cron
Reading package lists... Done
Building dependency tree       
Reading state information... Done
编写crontab
root@0f76222d94c0:~# crontab -e
*/1 * * * * echo 'test' > /root/test.txt
不生效解决方式
root@0f76222d94c0:~# service cron status
[FAIL] cron is not running ... failed!
root@0f76222d94c0:~# service cron start
[ ok ] Starting periodic command scheduler: cron.
Dockerfile
FROM harbor.od.com/public/python37:latest
RUN apt-get install cron  -y && service cron start


root@0f76222d94c0:~#  docker build -t harbor.od.com/public/python37-cron:latest .

你可能感兴趣的:(docker,docker)