A lightweight Docker image with Cron based on Alpine Linux.
Download size of this image is only:
Docker hub image: funnyzak/alpine-cron
Docker Pull Command: docker pull funnyzak/alpine-cron:latest
-
CRON_STRINGS: Strings with cron jobs. Use "\n" for newline (Default: undefined)
-
CRON_TAIL: - If defined cron log file will read to stdout by tail (Default: undefined)
By default cron running in foreground.
The following packages are installed by default:
- certificates
- bash
- curl
- wget
- rsync
- git
- gcc
- openssh
- make
- cmake
- zip
- unzip
- gzip
- certbot
- bzip2
- tar
- tzdata
- nodejs
- yarn
- npm
- pushoo-cli
- mysql-client
- mariadb-connector-c
- ossutil64
- /etc/cron.d Place to mount custom crontab files
When image will run, files in /etc/cron.d will copied to /var/spool/cron/crontab.
If CRON_STRINGS defined script creates file /var/spool/cron/crontab/CRON_STRINGS
Log file by default placed in /var/log/cron/cron.log
The image already installed pushoo-cli, you can use it to send notification. You can send notification to DingTalk, iFttt, Discord, Feishu, atri, bark, etc.
More information about pushoo-cli, please refer to pushoo-cli and pushoo.
docker run --name="alpine-cron-sample" -d \
-v /path/to/app/conf/crontabs:/etc/cron.d \
-v /path/to/app/scripts:/scripts \
funnyzak/alpine-cron
docker run --name="alpine-cron-sample" -d \
-e 'CRON_STRINGS=* * * * * /scripts/myapp-script.sh'
-v /path/to/app/scripts:/scripts \
funnyzak/alpine-cron
docker run --name="alpine-cron-sample" -d \
-e 'CRON_STRINGS=* * * * * wget --spider https://sample.dockerhost/cron-jobs'
funnyzak/alpine-cron
version: '3'
services:
acron:
image: funnyzak/alpine-cron
privileged: true
container_name: cron
logging:
driver: 'json-file'
options:
max-size: '1g'
tty: true
environment:
- TZ=Asia/Shanghai
- LANG=C.UTF-8
- CRON_TAIL=1 # tail cron log
- CRON_STRINGS=* * * * * /scripts/echo.sh
restart: on-failure
volumes:
- ./scripts:/scripts # execute script
- ./cron:/etc/cron.d # crontab
- ./db:/db # log
For more details, please refer to the docker-compose.yml file.
If you have any questions or suggestions, please feel free to submit an issue or pull request.
MIT License © 2022 funnyzak