Dockerized alpine with busybox crond and useful tools. 🐳
10K+
Dockerized alpine with busybox crond and useful tools.
Packages included for all images: curl, wget
| Tag | Dockerfile Build Context |
|---|---|
:3.20, :latest | View |
:3.20-mysqlclient | View |
:3.20-openssl | View |
:3.20-mysqlclient-openssl | View |
:3.17, :latest | View |
:3.17-mysqlclient | View |
:3.17-openssl | View |
:3.17-mysqlclient-openssl | View |
:3.15, :latest | View |
:3.15-mysqlclient | View |
:3.15-openssl | View |
:3.15-mysqlclient-openssl | View |
:3.12, :latest | View |
:3.12-mysqlclient | View |
:3.12-openssl | View |
:3.12-mysqlclient-openssl | View |
Example 1: Create one cron that runs as root
docker run -it \
-e CRON='* * * * * /bin/echo "hello"' \
theohbrothers/docker-alpine-cron:3.20
Example 2: Create two crons that run as root
docker run -it \
-e CRON='* * * * * /bin/echo "hello"\n* * * * * /bin/echo "world"' \
theohbrothers/docker-alpine-cron:3.20
Example 3: Create two crons that run as UID 3000 and GID 4000
docker run -it \
-e CRON='* * * * * /bin/echo "hello"\n* * * * * /bin/echo "world"' \
-e CRON_UID=3000 \
-e CRON_GID=4000 \
theohbrothers/docker-alpine-cron:3.20
| Name | Default value | Description |
|---|---|---|
CRON | '' | Required: The cron expression. For multiple cron expressions, use \n. Use crontab.guru to customize crons. This will be set as the content of the crontab at /etc/crontabs/$CRON_USER |
CRON_UID | 0 | Optional: The UID of the user that the cron should run under. Default is 0 which is root |
CRON_GID | 0 | Optional: The GID of the user that the cron should run under. Default is 0 which is root |
docker-entrypoint.sh/etc/environment file is created at the beginning of the entrypoint script, which makes environment variables available to everyone, including crond.CRON_UID is created if it does not exist.CRON_GID is created if it does not exist.CRON_UID is added to the group of CRON_GID if membership does not exist./etc/crontabs/<CRON_USER>Since a /etc/environment file is created automatically to make environment variables available to every cron, any sensitive environment variables will get written to the disk. To avoid that:
ENV_SECRETS_DIR. By default, its value is /run/secretsMY_ENV_VAR=DOCKER-SECRET:my_docker_secret_name, where my_docker_secret_name is the secret mounted on $ENV_SECRETS_DIR/my_docker_secret_nameMY_ENV_VAR gets populated with the contents of the secret file $ENV_SECRETS_DIR/my_docker_secret_nameThis image is only needed if there is no container orchestrator (E.g. Docker in standalone mode), or if there is a container orchestrator but without a cron scheduler (E.g. Docker in Swarm mode).
If your orchestrator already provides an external scheduler (E.g. Kubernetes via CronJob), there's no need to use this image.
CRON environment variable? Just use crontab -Right. If the cron command is complex, and there is no need for customizing CRON_UID and CRON_GID, it is better to skip this image altogether and simply write everything in the entrypoint of the container manifest. For example, in Compose:
version: '2.2'
services:
some-cron:
image: alpine
tty: true
entrypoint:
- /bin/sh
command:
- -c
- |
set -eu
crontab - <<'EOF'
* * * * * /bin/echo "My super 'complex' cron command with quotes is better written in shell"
EOF
exec crond -f
docker logs to check whether crond has spit out any messages about the syntax of your cron/etc/crontabs, ensure:
root:root with 0600 permissions. See hereRequires Windows powershell or pwsh.
# Install Generate-DockerImageVariants module: https://github.com/theohbrothers/Generate-DockerImageVariants
Install-Module -Name Generate-DockerImageVariants -Repository PSGallery -Scope CurrentUser -Force -Verbose
# Edit ./generate templates
# Generate the variants
Generate-DockerImageVariants .
Content type
Image
Digest
sha256:f9e9ab7cf…
Size
6.4 MB
Last updated
over 1 year ago
docker pull theohbrothers/docker-alpine-cron