How to run a cron job inside a docker container?

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

    Here's my docker-compose based solution:

      cron:
        image: alpine:3.10
        command: crond -f -d 8
        depends_on:
          - servicename
        volumes:
          - './conf/cron:/etc/crontabs/root:z'
        restart: unless-stopped
    

    the lines with cron entries are on the ./conf/cron file.

    Note: this won't run commands that aren't on the alpine image.

提交回复
热议问题