Docker Centos7 Container 容器中运行 crontab 定时任务 Dockerfile

 

# Pull base image  

FROM centos:latest

  

MAINTAINER crabdave "calorie.david@gmail.com"  

 

# Usage: USER [UID]

USER root

# modify timezone

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 

#install cronie

RUN yum -y install cronie

#install crontabs

RUN yum -y install crontabs

 

RUN sed -i '/session    required   pam_loginuid.so/c\#session    required   pam_loginuid.so' /etc/pam.d/crond

 

RUN echo "*/1 * * * * /bin/echo 'it works!' >> /root/test.log" >> /var/spool/cron/root

 

#start  

ENTRYPOINT ["/usr/sbin/init"]

 

参考:

http://stackoverflow.com/questions/21926465/issues-running-cron-in-docker-on-different-hosts

http://www.linuxadmin.lt/centos-7-no-package-vixie-cron-available/

http://welcomeweb.blog.51cto.com/10487763/1735251

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐