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

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

 

# Pull base image  

FROM centos:latest

  

MAINTAINER crabdave "[email protected]"  

 

# 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

你可能感兴趣的:(Docker)