Public | Automated Build

Last pushed: 2 years ago
Short Description
Run cron jobs in container
Full Description

The Concept

Stitch together a Docker job scheduler, distributed locking, task runner, and alerting system

Project: []

Docker image: []


  • Job Scheduler: Cron
  • Distributed Locking: Consul
  • Task Runners: Docker, Kubernetes
  • Job Alerting: Sensu

Run Methods

  • Cron
    • If ran with no command argument it will start in cron mode and run on the cron schedule.
    • Cron functionality can be disabled for an entire jobs yaml file by adding SCHEDULED under the configuration for a job yaml
  • Single Job
    • If a job name is specified it will run the job, tail the logs, and exit when the job is finished.
    • Lockers and Alerters are disabled in this mode

Deployment Methods

  • Docker

    • docker run sstarcher/job-runner:latest
  • Kubernetes

    • Example pod for running under Kubernetes
apiVersion: v1
kind: ReplicationController
  name: job-runner
  replicas: 1
    name: job-runner
        name: job-runner
      - name: job-runner
        image: sstarcher/job-runner:latest
        - name: RUNNER
          value: kubernetes
        - name: KUBERNETES_MASTER
          value: http://kubernetes:8080


  • Docker
    • Mount either the docker socket or set DOCKER_HOST
  • Kubernetes
    • Set KUBERNETES_MASTER to your Kubernetes cluster url example
    • compose2kube binary has been built from -
    • IGNORE_OVERRUN - if this variable is false if a job is running and a new job is launched of the same name this will alert to the alerter


  • Consul
    • CONSUL_HOST to an address without your cluster - default localhost
    • CONSUL_PORT to the port your cluster is listening on - default 8500


  • Sensu
    • SENSU_HOST to an address for Sensu - default
    • SENSU_PORT to the port Sensu is listening on for the client - default 3030
    • KIBANA_HOST optional URL. If set a Kibana link will be sent to the sensu data


  • Kubernetes
    • Will delete any pods containing a "jobrunner" label
    • Processes any alerting logic needed


  • Alerters, Lockers are disabled by default
  • Docker is the default runner
  • Example job formats are in the example-jobs folder
  • Job names must be unique
  • example-jobs
  • This project utilizes docker ONBUILD so any yaml files added under a jobs directory will be added and processed
  1. Create a Dockerfile
    FROM sstarcher/job-runner:latest
  2. Create a folder called jobs
  3. Create a job
    image: debian:jessie #This value is overriding what is set in the DEFAULTS.yaml
     - Test:
         time: '* * * * *'
         command: echo $job
  4. docker build --pull -t jobs .
  5. docker run jobs
Docker Pull Command
Source Repository