How lucaslorentz/caddy-docker-proxy works
Caddy-Docker-Proxy watches Docker resources, turns Caddy-prefixed labels and other supported configuration sources into a Caddyfile, and distributes the resulting Caddy configuration to local or controlled Caddy servers. The README documents label conversion, templates and upstream discovery; sampled code also shows separate container and Swarm service target handling, event-triggered refreshes, and configuration pushes. Some implementation details—especially server selection and optional modes—are represented only at the documented or excerpted level, so uncertain links are omitted.
Main entry points: generator.go Config generator · loader.go Docker loader · cmd.go CLI startup · client.go Docker client
Components 18
Runtime control
- CLI startup
cmd.go - Runtime options
config/options.go - Docker loader
loader.go
Docker discovery
- Docker client
docker/client.go
Config generation
- Config generator
generator/generator.go - Container targets
generator/containers.go - Service targets
generator/services.go - Label templates
generator/labels.go - Label parsing
caddyfile/fromlabels.go - Caddyfile model
caddyfile/caddyfile.go - Config merging
caddyfile/merge.go - Caddyfile marshal
caddyfile/marshal.go - Caddyfile lexer
caddyfile/lexer.go - Caddyfile processing
caddyfile/processor.go
Caddy delivery
- Config push
push.go
Other components
- Operator
- Docker Engine
- Caddy
Connections 23
- Operator → CLI startup: starts
cmd.go - CLI startup → Runtime options: configures
cmd.go - CLI startup → Docker loader: starts loader
cmd.go - CLI startup → Caddy: starts
cmd.go - Docker loader → Docker client: creates clients
loader.go - Docker client → Docker Engine: queries and watches
docker/client.go - Docker loader → Config generator: creates generator
loader.go - Docker loader → Config generator: requests config
- Config generator → Docker client: lists resources
generator/generator.go - Config generator → Container targets: gets container IPs
generator/containers.go - Config generator → Service targets: gets service targets
generator/services.go - Config generator → Label templates: renders labels
generator/labels.go - Label templates → Label parsing: converts labels
generator/labels.go - Label parsing → Caddyfile model: creates blocks
- Config generator → Config merging: merges configs
- Config generator → Caddyfile marshal: serializes result
- Caddyfile marshal → Caddyfile lexer: tokenizes input
caddyfile/marshal.go - Caddyfile processing → Caddyfile model: processes config
- Docker loader → Config push: distributes config
- Config push → Caddy: loads configuration
- Config generator → Docker Engine: reads metadata
README.md - Config generator → Caddyfile marshal: generates Caddyfile
README.md - Docker loader → Caddy: triggers reload
README.md