Cron---Alpine

Cron---Alpine

Docker app from grtgbln's Repository

Overview

Alpine-based images with cron support

Docker

A lightweight docker image for cronjobs

Manual example with docker

Pull it with:

docker pull ghcr.io/2franix/cron-docker:latest

Create a ./crontab file:

# Create this file in the current directory and name it crontab
* * * * * echo "It works!"

Run it!

docker run --rm --mount="type=bind,src=./crontab,dst=/crontab" ghcr.io/2franix/cron-docker:latest

On the next minute, you should see in the output that it is working:

crond: crond (busybox 1.36.1) started, log level 8
crond: USER worker pid  15 cmd echo "It works!"
It works!

With compose

services:
  cron:
    image: ghcr.io/2franix/cron-docker:latest
    restart: unless-stopped
    volumes:
      - ./crontab:/crontab

See the sample compose.yaml file in the examples folder for a more detailed example.

Features

The image runs the cron daemon as root but uses the worker user to run the cron job. At runtime, it installs the crontab file specified by the CRON_SPEC_FILE environment variable as worker's crontab.

If you need additional scripts to run the job, two approaches are available:

  • mount them in worker's home directory (defaults to /worker, configurable via the CRON_USER_HOME environment variable). At startup, the container recursively changes ownership of the home directory, which guarantees that those files are owned by the worker user at runtime. The drawback is that the files ownership is changed on the host as well, which may not be suitable to all use cases
  • create a derived image and copy the files in worker's home directory at build time. Unlike the other approach above, the files on the host are not modified, since this is a copy.

If you need to perform additional actions as root before starting the cron daemon, mount shell scripts in the /entrypoint.pre.d directory. Those files are executed in alphabetical order.

Note that the mounted crontab is installed at startup, so modifying it while the container is running does not have any effect on cron.

SMTP with msmtp

It is possible to configure msmtp in the container so that any output produced by the cronjobs is automatically sent by email. See the SMTP_* and CRON_MAILTO variables below. This feature is disabled by default and is only enabled when SMTP_HOST is set.

Environment variables in the image

Instead of storing the value directly in some of the variables, it is possible to write it to a file in the container and store the path to this file in the XXX_FILE variable. For example, rather than storing the SMTP password in SMTP_PASSWORD, one can store it in the /etc/smtp_password file in the container and set SMTP_PASSWORD_FILE=/etc/smtp_password. This is mainly useful to leverage docker secrets to pass sensitive data.

Not all variables support this feature. Refer to the "Has _FILE variant" column in the table below.

Variable Default value Modifiable Has _FILE variant Notes
CRON_USER "worker" no Set at build time, cannot be changed.
CRON_USER_UID 1000 yes
CRON_USER_GID 1000 yes
CRON_USER_HOME /worker yes See CRON_SPEC_FILE if you change this variable.
CRON_ENTRYPOINT_PRE_DIR /entrypoint.pre.d yes Optional folder containing scripts to execute as root before starting cron.
CRON_SPEC_FILE /crontab yes Contains the crontab definition, as expected by cron.
CRON_VERBOSITY 8 yes A value between 0 (max) and 8 (min) to control cron's verbosity.
CRON_MAILTO "" yes X Cron emails recipient.
SMTP_HOST "" yes X SMTP host server to use to send emails. Leave it empty to disable msmtp entirely.
SMTP_PORT "" yes X Port of the SMTP server to use to send emails.
SMTP_TLS "on" yes Value of msmtp's TLS option.
SMTP_FROM "" yes X Address to appear as sender of emails sent by cron.
SMTP_USER "" yes X Username when authenticating against the SMTP server.
SMTP_PASSWORD "" yes X Password when authenticating against the SMTP server.

Install Cron---Alpine on Unraid in a few clicks.

Find Cron---Alpine in Community Apps on your Unraid server, review the template, and click Install. Unraid handles the Docker app or plugin setup from the published template.

Open the Apps tab on your Unraid server Search Community Apps for Cron---Alpine Review the template variables and paths Click Install

Requirements


        Expects a crontab file mounted to Cron File BEFORE starting the container.
    

Related apps

Details

Repository
ghcr.io/2franix/cron-docker:latest
Last Updated2026-07-17
First Seen2025-05-13

Runtime arguments

Network
bridge
Privileged
false

Template configuration

Cron FilePath

Crontab file

Target
/crontab
Default
/mnt/user/appdata/cron_alpine/crontab
Value
/mnt/user/appdata/cron_alpine/crontab
Pre-Run Script DirectoryPath

Directory for pre-run scripts

Target
/entrypoint.pre.d
Default
/mnt/user/appdata/cron_alpine/pre-run.d
Value
/mnt/user/appdata/cron_alpine/pre-run.d
Cron - Mail ToVariable

Cron emails recipient

Target
CRON_MAILTO
SMTP - HostVariable

SMTP server hostname

Target
SMTP_HOST
SMTP - PortVariable

SMTP server port

Target
SMTP_PORT
SMTP - TLSVariable

Use TLS for SMTP connection

Target
SMTP_TLS
Default
on|off
SMTP - From AddressVariable

Sender email address

Target
SMTP_FROM
SMTP - UsernameVariable

SMTP username

Target
SMTP_USER
SMTP - PasswordVariable

SMTP password

Target
SMTP_PASSWORD
Cron User IDVariable

User ID to run the cron jobs as.

Target
CRON_USER_UID
Default
099
Value
099
Cron Group IDVariable

Group ID to run the cron jobs as.

Target
CRON_USER_GID
Default
099
Value
099
Cron WorkerVariable

User to run the cron jobs as. Not modifiable

Target
CRON_USER
Default
worker
Value
worker
Internal Cron Worker HomeVariable

Home directory of the cron user.

Target
CRON_USER_HOME
Default
/worker
Value
/worker
Internal Pre-Run Script DirectoryVariable

Internal directory for pre-run scripts.

Target
CRON_ENTRYPOINT_PRE_DIR
Default
/entrypoint.pre.d
Value
/entrypoint.pre.d
Internal Cron FileVariable

Internal crontab file.

Target
CRON_SPEC_FILE
Default
/crontab
Value
/crontab
Cron VerbosityVariable

Cron verbosity level. 0 - max, 8 - min

Target
CRON_VERBOSITY
Default
8|7|6|5|4|3|2|1|0