How to run a cron job inside a docker container?

前端 未结 20 1610
無奈伤痛
無奈伤痛 2020-11-22 05:36

I am trying to run a cronjob inside a docker container that invokes a shell script.

Yesterday I have been searching all over the web and stack overflow, but I could

20条回答
  •  梦如初夏
    2020-11-22 06:15

    this line was the one that helped me run my pre-scheduled task.

    ADD mycron/root /etc/cron.d/root
    
    RUN chmod 0644 /etc/cron.d/root
    
    RUN crontab /etc/cron.d/root
    
    RUN touch /var/log/cron.log
    
    CMD ( cron -f -l 8 & ) && apache2-foreground # <-- run cron
    

    --> My project run inside: FROM php:7.2-apache

提交回复
热议问题