Alpine-based image configured with crond, and containing mysql-client and other useful packages
721
This image allows you to run cron jobs in your Docker infrastructure. To keep things small, the image is built on Alpine, and therefore the crond is supplied by Busy Box. The default crond configuration is kept intact, though this can be overriden with a suitable Compose file configuration.
This image is based on discussion in a blog post: Scheduling background tasks using cron in a Docker container
The corresponding Github repository is: https://github.com/robogeek/docker-cron
Included in the image are the following packages
mysql-client -- primarily to have mysqldump so that MySQL backup scripts can be supportedless, gzip, rsync -- Generally useful tools to have available for writing cron jobsThe intended use is something like this:
version: '3.8'
services:
crond:
image: robogeek/crond
networks:
- wordpress-local_wpnet
volumes:
- ./hourly:/etc/periodic/hourly
# This must be the path to where the Wordpress files are located
- ../../wordpress-local/roots/html:/docroot
- ./backups:/backups
networks:
wordpress-local_wpnet:
external: true
First, attach the container to any required networks so cron jobs can access desired services.
Second, override the directories that can contain cron jobs. The directories supported by the default Alpine Linux crond configuration are:
/etc/periodic/15min - for jobs running every 15 minutes/etc/periodic/hourly - for jobs running every hour/etc/periodic/daily - for jobs running every day/etc/periodic/weekly - for jobs running every weekFor whichever job frequency you desire, mount a directory into the container at the corresponding location. Any executable program (or shell script) in the directory is executed at the named frequency. It is important that executable programs not have a file extension, like .sh, because the run-parts program silently ignores such files.
Third, you mount into the container any directories you require for backups. For example to tar/gzip the files for a Wordpress container, that directory must be mounted into this container. Additionally a directory for storing any files can be mounted, like the /backups directory shown in this example.
Content type
Image
Digest
Size
11.9 MB
Last updated
over 5 years ago
docker pull robogeek/crond