2018-08-04 00:45:53 +00:00
# Dockron
2018-08-01 15:54:55 +00:00
2018-11-17 21:21:24 +00:00
Simple scheduling for short-running Docker containers
2018-08-03 01:56:02 +00:00
2018-08-03 23:56:22 +00:00
## Usage
2018-08-03 01:56:02 +00:00
2018-08-04 00:45:53 +00:00
Dockron requires access to the Docker, so it may need to be run as root, or, if in a Docker container, need the socket mapped as a volume.
2018-08-03 23:56:22 +00:00
2018-08-04 00:45:53 +00:00
### Running Dockron
2018-08-03 23:56:22 +00:00
As simple as:
2018-08-04 00:45:53 +00:00
dockron
2018-08-03 23:56:22 +00:00
It will then run in the foreground, periodically checking Docker for containers with labels containing a cron schedule.
2018-08-04 00:45:53 +00:00
By default, Dockron will periodically poll Docker for new containers or schedule changes every minute. You can specify an interval by using the `-watch` flag.
2018-08-03 23:56:22 +00:00
2019-06-08 00:14:01 +00:00
### Running with Docker
Dockron is also available as a Docker image. The multi-arch repo can be found at [IamTheFij/dockron ](https://hub.docker.com/r/iamthefij/dockron )
From either an `amd64` , `arm` , or `arm64` machine, you can run Dockron using:
docker run -v /var/run/docker.sock:/var/run/docker.sock:ro iamthefij/dockron -watch
2018-08-03 23:56:22 +00:00
### Scheduling a container
First, be sure your container is something that is not long running and will actually exit when complete. This is for batch runs and not keeping a service running. Docker should be able to do that on it's own with a restart policy.
2018-08-04 00:45:53 +00:00
Create your container and add a label in the form `dockron.schedule="* * * * *"` , where the value is a valid cron expression (See the section [Cron Expression Formatting ](#cron-expression-formatting )).
2018-08-03 23:56:22 +00:00
2018-08-04 00:45:53 +00:00
Dockron will now start that container peridically on the schedule.
2018-08-03 23:56:22 +00:00
### Cron Expression Formatting
For more information on the cron expression parsing, see the docs for [robfig/cron ](https://godoc.org/github.com/robfig/cron ).
## Caveats
2018-08-04 00:45:53 +00:00
Dockron is quite simple right now. It does not yet:
2018-08-03 23:56:22 +00:00
* Issue any retries
* Cancel hanging jobs
I intend to keep it simple as well. It will likely never:
* Provide any kind of alerting (check out [Minitor ](https://git.iamthefij.com/IamTheFij/minitor ))
* Handle job dependencies
2018-08-04 00:45:53 +00:00
Either use a separate tool in conjunction with Dockron, or use a more robust scheduler like Tron, or Chronos.