How to run a cron job inside a docker container?

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

    The most robust way I found so far is run an independent cron container - install the docker client and bind mount the docker sock so you can talk to the docker server on the host.

    Then just use env vars for each cron job and an entrypoint script to generate the /etc/crontab

    Here is an image that I created using this principle and using it in production for the last 3-4 years.

    https://www.vip-consult.solutions/post/better-docker-cron#content

提交回复
热议问题