GithubHelp home page GithubHelp logo

ecliptik / docker-cron-container-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jordancrawfordnz/docker-cron-container-starter

0.0 2.0 0.0 6 KB

Starts local Docker containers based on a cron schedule.

Dockerfile 4.88% Shell 95.12%

docker-cron-container-starter's Introduction

View on Docker Hub

View on GitHub

A version for the Raspberry Pi


Cron Container Starter

This is a simple Docker image that starts local Docker containers based on a cron schedule.

This is based off sillelien/tutum-cron which does the same job but inside Tutum.

Why would I want this?

This is quite useful to run backups or other scheduled jobs. Rather than having each of these jobs in a container with their own cron schedules, you can use this image to keep all schedule job configuration in one place.

How does it work?

The Docker socket must be provided to the container as a volume at /var/run/docker.sock. Through this, the container can issue a start command.

fcron is used to schedule this API call.

Building

Pull the repository and run: docker build -t jordancrawford/cron-container-starter ..

Running

To run you must:

  • provide /var/run/docker.sock as a volume
  • provide your cron schedules as environment variables. These must be of the format: CONTAINER_<container name to start>=<cron schedule>

Cron Schedules

See the fcron documentation or crontab-generator for help.

Docker Compose

The easiest way to run the image is within Docker Compose. Below an example Docker Compose file that runs a test container every minute.

cron-container-starter:
   container_name: cron-container-starter
   image: jordancrawford/cron-container-starter
   restart: always
   # Don't take a large portion of memory or CPU shares.
   cpu_shares: 128
   mem_limit: 64m
   # Setup container start rules.
   environment:
    CONTAINER_test: '* * * * *'
   # Setup the Docker socket as a volume so the container can control Docker.
   volumes:
    - /var/run/docker.sock:/var/run/docker.sock
test:
   image: alpine
   container_name: test
   command: 'echo On Schedule'

docker-cron-container-starter's People

Contributors

jordancrawfordnz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.