whatisgithub

What is docker-gen?

nginx-proxy/docker-gen — explained in plain English

Analysis updated 2026-06-26

4,625GoAudience · ops devopsComplexity · 3/5Setup · moderate

In one sentence

A Go program that watches your running Docker containers and regenerates config files from templates whenever containers start, stop, or change, most commonly used to auto-update an nginx reverse proxy without any manual editing.

Mindmap

mindmap
  root((docker-gen))
    What it does
      Watches Docker containers
      Regenerates config files
      Signals services to reload
    Common uses
      nginx reverse proxy
      Log rotation
      Service discovery
    Template system
      Go template syntax
      Container metadata
      Env vars and ports
    Run modes
      On host directly
      Inside app container
      Separate container
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Auto-generate and reload an nginx reverse proxy config whenever a new container starts with a VIRTUAL_HOST environment variable

USE CASE 2

Keep log rotation config up to date as containers are added or removed without manual edits

USE CASE 3

Register containers with etcd or another service discovery system automatically on startup

What is it built with?

GoDockernginx

How does it compare?

nginx-proxy/docker-genantoniomika/sishgoogle/go-cmp
Stars4,6254,6264,630
LanguageGoGoGo
Setup difficultymoderatemoderateeasy
Complexity3/53/52/5
Audienceops devopsops devopsdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires access to the Docker socket, run docker-gen as a separate container to avoid exposing the socket to public-facing services.

License not described in the explanation.

So what is it?

docker-gen is a Go program that watches your Docker containers and automatically generates text files whenever containers start, stop, or change. You provide a template file written with Go's template syntax, and docker-gen fills it in with live data about your running containers: their names, IP addresses, exposed ports, environment variables, and more. The most common use is generating a reverse proxy configuration. For example, when you start a new web application in a Docker container with an environment variable like VIRTUAL_HOST=example.com, docker-gen can detect that container, rebuild an nginx configuration file that includes that host name, and signal nginx to reload, all without any manual editing. This is how the popular nginx-proxy project works under the hood. Other built-in templates cover centralized logging (sending container log output to fluentd or logstash), log rotation (automatically rotating the JSON log files Docker creates for each container), and service discovery (registering containers with external systems like etcd so other services can find them). There are three ways to run docker-gen: directly on the server, bundled inside the same container as the application it configures, or as a separate standalone container that shares a volume with another container. The separate-container approach is common when you want to keep the Docker socket (which grants broad system access) away from a publicly exposed service. The command accepts a template file and an optional output destination. A -watch flag keeps it running and regenerates files whenever container state changes. The -notify option lets you specify a command or signal to send to a container after each regeneration, which is how nginx gets told to reload its configuration.

Copy-paste prompts

Prompt 1
Using docker-gen, write a Go template that generates an nginx server block for each running container that has a VIRTUAL_HOST environment variable set, then signals nginx to reload.
Prompt 2
I want docker-gen to run as a separate container alongside nginx. Show me the docker-compose.yml that mounts the Docker socket, shares a volume for the generated config, and signals nginx after each regeneration.
Prompt 3
Write a docker-gen template that generates a Fluentd log forwarding config for all running containers, using each container's name as the log tag.
Prompt 4
I have docker-gen watching containers and regenerating a config file with -watch. How do I use the -notify flag to send a HUP signal to nginx inside a different container after each config update?

Frequently asked questions

What is docker-gen?

A Go program that watches your running Docker containers and regenerates config files from templates whenever containers start, stop, or change, most commonly used to auto-update an nginx reverse proxy without any manual editing.

What language is docker-gen written in?

Mainly Go. The stack also includes Go, Docker, nginx.

What license does docker-gen use?

License not described in the explanation.

How hard is docker-gen to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is docker-gen for?

Mainly ops devops.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.