docker-cron is a tool for scheduling containers execution using labels
You can run the docker-cron container with the following:
docker run \ --privileged \ --restart="unless-stopped" \ --mount=type=bind,source="/var/run/docker.sock",destination="/var/run/docker.sock" \ "ghcr.io/dmipeck/docker-cron:latest"The docker-cron container will check each minute for any containers that should be run based of of a cron expression added to the container labels
You can run an example scheduled container with the following:
docker container create \ --label="github.com/dmipeck/docker-cron.enabled=true" \ --label="github.com/dmipeck/docker-cron.schedule=* * * * *" \ "hello_world:latest"This will run the hello-world container every minute
Scheduled containers require the following labels to be started by docker-cron:
| Label | Value |
|---|---|
github.com/dmipeck/docker-cron.enabled | "true" |
github.com/dmipeck/docker-cron.schedule | any valid cron expression, e.g "* * * * *" |
docker-cron will only try to start the container once, regardless of if it succeeds. Use the --restart=on-failed, or --restart=on-failed:<max_retries> flags to restart the container if there is an error.