Docron is a scheduling tool designed to automate the start, stop and restart of Docker containers based on user-defined schedules. With a simple interface, it streamlines container management.
I created this application to provide an alternative for users who are not comfortable using crontab or those who prefer not to modify system files. Docron runs in its own container, with access only to its resources and other containers via the Docker API. I haven't found any existing solutions that offer this functionality, but I may have overlooked some.
If you prefer a one-off command to start a container, use the following code:
docker run -d \
--name docron \
-p 8080:8080 \
-e DOCKER_CONNECTION=unix:///var/run/docker.sock \
-e DB='Data Source=/data/docron.db;' \
-e KEY_PATH='/data/keys' \
-e EXCLUDED_CONTAINERS="container-name1,container-name2" \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /<yourDBFolder>/:/data \
ghcr.io/primez/docron:latestAlternatively, a Docker Compose file might look like this:
services:
docron:
image: ghcr.io/primez/docron:latest
container_name: docron
ports:
- 8080:8080
environment:
- DOCKER_CONNECTION=unix:///var/run/docker.sock
- DB=Data Source=/data/docron.db;
- KEY_PATH=/data/keys
- EXCLUDED_CONTAINERS=
- container-name1
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /<yourFolder>/:/dataDocron expects the following parameters to function properly:
- ENV:
DOCKER_CONNECTION- This is the address thatDocronwill use to connect and gather information about containers for start/stop operations. If this parameter is not provided, it will default to aDocker for Windowsenvironment. - ENV:
DB-DocronusesSQLiteto store schedules. To store the database in a mounted volume, provide this parameter. Otherwise, the database will be created inside the container. - ENV:
KEY_PATH-Docronstores anti-forgery keys here. Any path within a container will work, but it is better to provide a path to a mounted volume. - ENV:
EXCLUDED_CONTAINERS- an optional parameter to hide containers fromDocron - VOL:
<yourDBFolder>- If you want to persist the database between container updates, specify a host folder path to be mounted.


