A lightweight Docker image based on Alpine Linux for running cron jobs using Supercronic.
766
A lightweight Docker image based on Alpine Linux for running cron jobs using Supercronic v0.2.33. This image is optimized for running scheduled tasks in containerized environments with proper timezone support and logging capabilities.
alpine:latestdocker run -d \
-v /path/to/crontab:/etc/cron.d/crontab:ro \
-v /path/to/logs:/var/log \
-e TZ=Asia/Jakarta \
herliansyah/supercronic:3.0
TZ: Timezone (default: Asia/Jakarta)SUPERCRONIC: Binary name (default: supercronic-linux-amd64)SUPERCRONIC_URL: Binary download URLSUPERCRONIC_SHA1SUM: SHA1 checksum for security verification/etc/cron.d/crontab: Mount your crontab file (read-only recommended)/var/log: Directory for logs outputversion: '3'
services:
cron:
image: herliansyah/supercronic:1.0
environment:
- TZ=Asia/Jakarta
volumes:
- ./crontab:/etc/cron.d/crontab:ro
- ./logs:/var/log
- /var/run/docker.sock:/var/run/docker.sock
# Format: minute hour day month weekday command
# Main cron log
*/5 * * * * echo "Task running" >> /var/log/cron.log 2>&1
# Task with curl example
0 * * * * curl -X POST http://api-endpoint >> /var/log/api-call.log 2>&1
# crontab with execute php in other docker container
*/1 * * * * docker exec php8.3-apache2.4 php /var/www/html/testauth.php >> /var/log/cron.log 2>&1
/
├── usr/local/bin/
│ ├── supercronic -> supercronic-linux-amd64
│ └── supercronic-linux-amd64
├── etc/
│ ├── cron.d/
│ │ └── crontab
│ ├── timezone
│ └── localtime
└── var/
└── log/
FROM alpine:latest
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.33/supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=71b0d58cc53f6bd72cf2f293e09e294b79c666d8 \
SUPERCRONIC=supercronic-linux-amd64 \
TZ=Asia/Jakarta
RUN apk add --no-cache curl
RUN apk add --no-cache docker-cli
RUN curl -fsSLO "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
RUN apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone
RUN mkdir -p /etc/cron.d
CMD ["/usr/local/bin/supercronic", "/etc/cron.d/crontab"]
3.0: Current stable versionlatest: Latest buildMIT
Content type
Image
Digest
sha256:a178725fa…
Size
22.3 MB
Last updated
almost 2 years ago
docker pull herliansyah/supercronic:3.0