This implementation is based on cron
docker-machine create --driver virtualbox default <1>
docker-machine start default <2>
eval `docker-machine env default` <3>
- Create a docker machine (once only)
- Start the docker machine
- Setup the docker client to use the docker-machine
docker build -t softwarecraftsmen/cron .
The cron base container only provides the scaffolding for cron jobs. In order to implement a cron job it must be extended and a job schedule has to be added.
The demo folder is containing a sample Dockerfile
and docker-compose
script to demonstrate the use of the base image.
FROM softwarecraftsmen/cron
MAINTAINER Software Craftsmen GmbH und CoKG <[email protected]>
ADD cron-setup.sh cron-setup.sh
RUN chmod +x cron-setup.sh
cron-setup.sh
#!/usr/bin/env bash
echo "* * * * * root echo hello >> $CRON_LOG 2>&1" >> /etc/cron.d/docker-cron
chmod 0644 /etc/cron.d/docker-cron
To fire up the cron scheduler run the docker-compose
script.
docker-compose --project-name=docker-cron-demo up