Giter Site home page Giter Site logo

docker-gen's Introduction

docker-gen

docker-gen is a file generator that renders templates using docker container meta-data.

docker-gen can be used to generate various kinds of files for:

  • Centralized logging - fluentd, logstash or other centralized logging tools that tail the containers JSON log file or files within the container.
  • Log Roatation - logrotate files to rotate container JSON log files
  • Reverse Proxy Configs - nginx, haproxy, etc. reverse proxy configs to route requests from the host to containers
  • Service Discovery - Scripts (python, bash, etc..) to register containers within etcd, hipache, etc..

===

Installation

Linux binaries for release 0.1.1

Download the version you need, untar, and install to your PATH.

wget https://github.com/jwilder/docker-gen/releases/download/0.1.1/docker-gen-linux-amd64-0.1.0.tar.gz
tar xvzf tar xvzf docker-gen-linux-amd64-0.1.0.tar.gz
./docker-gen

Usage

docker-gen
Usage: docker-gen [-config file] [-watch=false] [-notify="restart xyz"] [-interval=0] <template> [<dest>]

Options:

  • -watch - runs continuously and monitors docker container events. When containers are started or stopped, the template is regenerated.
  • -notify - runs a command after the template is generated. Useful for restarting nginx, reloading haproxy, etc..
  • -config file - Use the specified config file instead of command-line options. Multiple templates can be defined and they will be executed in the order that they appear in the config file.
  • -interval <secs> - Run the notify command on a fixed interval. Useful for service registration use cases.

If no <dest> file is specified, the output is sent to stdout. Mainly useful for debugging.

Examples

NGINX Reverse Proxy Config

docker-gen -only-exposed -watch -notify "/etc/init.d/nginx reload" templates/nginx.tmpl /etc/nginx/sites-enabled/default

Automated Nginx Reverse Proxy for Docker

Fluentd Log Management

docker-gen -watch -notify "restart fluentd" templates/fluentd.tmpl /etc/fluent/fluent.conf

Docker Log Management With Fluentd

Register Containers in Etcd

docker-gen -notify "/bin/bash /tmp/etcd.sh" -interval 10 templates/etcd.tmpl /tmp/etcd.sh

Development

This project uses godep for managing 3rd party dependencies. You'll need to install godep into your workspace before hacking on docker-gen.

git clone <your fork>
godep restore
make

TODO

  • Add Dockerfile and trusted build
  • Add event status for handling start and stop events differently
  • Add a way to filter out containers in templates

docker-gen's People

Contributors

jwilder avatar cer 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.