Sign inSign up

wyzenrepo/docker-cron

By wyzenrepo

•Updated over 2 years ago

Crontab for containers

Image
0

1.2K

wyzenrepo/docker-cron repository overview

⁠Cron Containers

Run action from a container.

⁠Pré-config

mount your crondir into /crondir.

/crondir must have directories :

  • 1min
  • 15min
  • hourly
  • daily
  • weekly
  • monthly

and/or 1 file custom.cron like:

# min   hour    day     month   weekday command
*       *       *       *       *       my-command
*       *       *       *       *       docker exec mycontainer /usr/local/bin/backupDatabase.sh

In each directory put your script for cron.

## Default config

# min   hour    day     month   weekday command
*       *       *       *       *       run-parts /etc/periodic/1min
*/15    *       *       *       *       run-parts /etc/periodic/15min
0       *       *       *       *       run-parts /etc/periodic/hourly
0       2       *       *       *       run-parts /etc/periodic/daily
0       3       *       *       6       run-parts /etc/periodic/weekly
0       5       1       *       *       run-parts /etc/periodic/monthly

⁠docker-compose

version: "3.5"

services:
  cron:
    image: docker-cron:latest
    environment:
      - TZ=Europe/Paris
    volumes:
      # Map containers from host
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./crondirtest:/crondir:ro
      - ./crondirtest/log:/var/log/cron

Tag summary

Content type

Image

Digest

sha256:e6a7270d7…

Size

121 MB

Last updated

over 2 years ago

docker pull wyzenrepo/docker-cron