Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lorenzck/docker-crontaimer
Simple docker image that executes cron jobs. π³β²
https://github.com/lorenzck/docker-crontaimer
cron cronjobs docker docker-image dockerfile
Last synced: about 1 month ago
JSON representation
Simple docker image that executes cron jobs. π³β²
- Host: GitHub
- URL: https://github.com/lorenzck/docker-crontaimer
- Owner: LorenzCK
- License: mit
- Created: 2019-01-25T14:16:00.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-26T15:30:14.000Z (about 6 years ago)
- Last Synced: 2024-11-12T22:42:53.781Z (3 months ago)
- Topics: cron, cronjobs, docker, docker-image, dockerfile
- Language: Dockerfile
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Docker CronTaimer
![Docker Hub pulls](https://img.shields.io/docker/pulls/lorenzck/crontaimer.svg)
Basic Docker image that executes cron jobs for you.
Lightweight image based on **Alpine:3.8** that runs the cron daemon in foreground.
Crontab file can be built into your image or mounted as a volume.Docker, docker-compose, make and bash are included, allowing you to run scripts or interact with your containers in response to your cron jobs.
## Usage
The basic image includes a basic cron jobs file that prints out βHello world!β every minute.
For instance:```
~$ docker run --rm lorenzck/crontaimer
crond: crond (busybox 1.28.4) started, log level 8
Hello world!
crond: USER root pid 6 cmd echo "Hello world!"
```Copy your crontab specification onto `/etc/crontabs/root` to set the jobs you need.
The simplest `Dockerfile` can be as follows:```
FROM lorenzck/crontaimer:latest
COPY mycronjobs /etc/crontabs/root
```A suggested docker-compose configuration might look like this:
```yml
version: '3'services:
timer:
build: path-to-dockerfile
volumes:
- /var/run/docker.sock:/var/run/docker.sock:rw
restart: unless-stopped
```Mounting the Docker socket as a read/write volume allows you to operate on Docker containers from your cron jobs.
You may also choose to mount the directory containing your `docker-compose.yml` or `Makefile`, in order to use it from the `crontaimer` container to perform more complex tasks.
## Notes
* The image is configured to run jobs in UTC time.
Add `TZ=UTC` at the top of your crontab file (see [the default cronjobs file](https://github.com/LorenzCK/docker-crontaimer/blob/master/cronjobs)) in order to ensure that your jobs also work in the same timezone.
* Crontab files must end with a newline character.
* Add `2>&1` to your cron job command to ensure that `stderr` is also redirected to the logs of your container.