mirror of
https://github.com/willfarrell/docker-crontab.git
synced 2025-10-28 12:17:17 +01:00
3.0 KiB
3.0 KiB
docker-crontab
A simple wrapper over docker to all complex cron job to be run in other containers.
Supported tags and Dockerfile links
Why?
Yes, I'm aware of mcuadros/ofelia (280MB), it was the main inspiration for this project. A great project, don't get me wrong. It was just missing certain key enterprise features I felt were required to support where docker is heading.
Features
- Easy to read schedule syntax allowed.
- Allows for comments, cause we all need friendly reminders of what
update_script.shactually does. - Start an image using
image. - Run command in a container using
container. - Run command on a instances of a scaled container using
project. - Ability to trigger scripts in other containers on completion cron job using
trigger.
Config.json
comment: Comments to be included with crontab entry. Optional.schedule: Crontab schedule syntax as described in https://godoc.org/github.com/robfig/cron. Ex@hourly,@every 1h30m,* * * * * *. Required.command: Command to be run on docker container/image. Required.image: Docker images name (exlibrary/alpine:3.5). Optional.project: Docker Compose/Swarm project name. Optional, only applies whencontainis included.container: Full container name or container alias ifprojectis set. Ignored ifimageis included. Optional.dockerargs: Command line dockerrun/execarguments for full control. Defaults to.trigger: Array of docker-crontab subset objects. Subset includes:image,project,container,command,dockerargsonstart: run the command oncrontabcontainer start. Defaultfalse.
See config.sample.json for examples.
Examples
Command Line
docer build -t crontab .
docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
-v /path/to/config/dir:/opt/crontab \
crontab
Dockerfile
FROM willfarrell/crontab
COPY config.json ${HOME_DIR}/
Logrotate Dockerfile
FROM willfarrell/crontab
RUN apk add --no-cache logrotate
RUN echo "*/5 * * * * /usr/sbin/logrotate /etc/logrotate.conf" >> /etc/crontabs/logrotate
ADD logrotate.conf /etc/logrotate.conf
CMD ["crond", "-f"]
TODO
- Make smaller by using busybox?
- Have ability to auto regenerate crontab on file change (signal HUP?)
- Run commands on host machine (w/ --privileged?)
- Write tests
- Setup TravisCI