A docker-in-docker based image, with Supercronic installed.
See Supercronic, a cron for containers for a complete description of supercronic.
Being based on docker, this allows the cron entries to use docker either inside the container, or more normally communicate with the host docker to execute commands.
Effectively, this means any docker image may be periodically launched through Supercronic, and then cleaned up later.
All the examples here assume that the docker host is also used to run the docker images, through mounting of /var/run/docker.sock
The CRONTAB environment variable is used to define the cron for Supercronic.
The complete crontab must be stored within the CRONTAB variable.
Try this out:
echo '# Say hello with cowsay every 5 seconds
*/5 * * * * * * docker run -e TZ --rm wernight/funbox cowsay "Hi, it is `date`"
# Tell a fortune at 7am
7 * * * * docker run -e TZ --rm wernight/funbox fortune' > sample-crontab
CRONTAB=`cat sample-crontab` docker run -e CRONTAB -e TZ="Australia/Melbourne" --privileged --rm -it -v /var/run/docker.sock:/var/run/docker.sock trammel/docker-with-supercronic
In order to run this container you'll need docker installed.
CRONTAB
The CRONTAB variable must contain a complete, well formatted crontab for Supercronic to run.
TZ
By default docker will run containers in UTC. You'll need to explicitly set the timezone (TZ) environment variable to match your expectations.
CRONTAB=`cat sample-crontab` docker run -e CRONTAB -e TZ="Australia/Melbourne" --detach --privileged -v /var/run/docker.sock:/var/run/docker.sock trammel/docker-with-supercronic
CRONTAB=`cat sample-crontab` docker run -e CRONTAB -e TZ="Australia/Melbourne" --privileged --rm -it -v /var/run/docker.sock:/var/run/docker.sock trammel/docker-with-supercronic
docker run --privileged --entrypoint= --rm -it -v /var/run/docker.sock:/var/run/docker.sock trammel/docker-with-supercronic /bin/sh
/var/run/docker.sock:/var/run/docker.sock
- Allows docker in the container to use host docker.
- Docker Inc - Docker - Docker
- Aptible - Supercronic - Supercronic
This project is licensed under the MIT License - see the LICENSE.txt file for details.