How to run a cron job inside a docker container?

前端 未结 20 1288
無奈伤痛
無奈伤痛 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:02

    From above examples I created this combination:

    Alpine Image & Edit Using Crontab in Nano (I hate vi)

    FROM alpine
    
    RUN apk update
    RUN apk add curl nano
    
    ENV EDITOR=/usr/bin/nano 
    
    # start crond with log level 8 in foreground, output to stderr
    CMD ["crond", "-f", "-d", "8"]
    
    # Shell Access
    # docker exec -it  /bin/sh
    
    # Example Cron Entry
    # crontab -e
    # * * * * * echo hello > /proc/1/fd/1 2>/proc/1/fd/2
    # DATE/TIME WILL BE IN UTC
    

提交回复
热议问题