Cron in a Docker Container
1.6K
Cron in a Docker Container.
docker-cron is an Alpine-based Docker container running Cron. It allows you to define a custom crontab that is executed by the Cron daemon.
# docker-compose.yml
services:
cron:
container_name: cron
environment:
CRONTAB: |
0 0 * * * echo "Already Midnight again!" >> /var/log/cron/cron.log 2>&1
0 8 * * * echo "Good Morning!" >> /var/log/cron/cron.log 2>&1
TZ: Europe/Berlin
image: krautsalad/cron
restart: unless-stopped
CRONTAB: A complete crontab definition (default: empty).TZ: Timezone setting (default: UTC).The container runs Cron as a daemon, executing the cron jobs defined in your CRONTAB environment variable. To ensure that the output of your cron jobs is visible in the container logs, append >> /var/log/cron/cron.log 2>&1 to your job commands. This log file is symlinked to the container's standard output.
You can find the full source code on GitHub.
Content type
Image
Digest
sha256:bcbb05c36…
Size
6.3 MB
Last updated
7 months ago
docker pull krautsalad/cron