How to run a cron job inside a docker container?

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

    Though this aims to run jobs beside a running process in a container via Docker's exec interface, this may be of interest for you.

    I've written a daemon that observes containers and schedules jobs, defined in their metadata, on them. Example:

    version: '2'
    
    services:
      wordpress:
        image: wordpress
      mysql:
        image: mariadb
        volumes:
          - ./database_dumps:/dumps
        labels:
          deck-chores.dump.command: sh -c "mysqldump --all-databases > /dumps/dump-$$(date -Idate)"
          deck-chores.dump.interval: daily
    

    'Classic', cron-like configuration is also possible.

    Here are the docs, here's the image repository.

提交回复
热议问题