The original image was changed to run php code by cron. So following changes were added to the original Dokerfile:
phpBelow updated the original readme.
Docker image to run cron inside the Docker container
Suppose you have folder cron.d with your cron scripts. The only thing you have to do is copying this folder into the Docker image:
# Dockerfile
FROM renskiy/cron
COPY cron.d /etc/cron.d
Then build and create container:
docker build --pull --rm --tag dmitriy/mercury-metrics .
docker run -d --rm --name cron dmitriy/mercury-metrics
To view logs use Docker logs command:
docker logs --follow cron
All you cron scripts should write logs to /var/log/cron.log. Otherwise you won't be able to view any log using this way.
In addition to cron.d you can pass any cron job as argument(s) to the start-cron command at the moment of container creation (providing optional user with -u/--user option):
docker run -d --rm --name cron dmitriy/mercury-metrics --user www-data \
"0 1 \* \* \* echo '01:00 AM' >> /var/log/cron.log 2>&1" \
"0 0 1 1 \* echo 'Happy New Year!!' >> /var/log/cron.log 2>&1"
Almost any environ variable you passed to the Docker will be visible to your cron scripts. With the exception of $SHELL, $PATH, $PWD, $USER, etc.
docker run -it --rm --interactive -e MY_VAR=foo dmitriy/mercury-metrics start-cron \
"\* \* \* \* \* env >> /var/log/cron.log 2>&1"
CRON_PATHThis Environ variable let you provide custom directory for your cron.d scripts which will be placed instead of default /etc/cron.d:
docker run -d --name cron -e CRON_PATH=/etc/my_app/cron.d dmitriy/mercury-metrics
This is very useful when you planning to create more then one Docker container from a single image.
Content type
Image
Digest
Size
135.8 MB
Last updated
over 8 years ago
docker pull dmitriy/mercury-metrics