Small Python CLI for discovering Traefik hostnames from a live Docker + Traefik setup and exporting a reviewable list for later DNS selection.
It does:
- inspect running Docker containers for Traefik router rules
- optionally read active routers from the Traefik API
- optionally read Traefik file-provider config
- optionally mark discovered hosts as seen in access logs
- derive a likely DNS zone for each host
- optionally apply manual DNS provider overrides by zone
- export reviewable YAML and JSON
It does not:
- update DNS
- call DNS provider APIs
- decide automatically which hosts should become public DNS targets
git clone https://github.com/worryboy/traefik-domain-discovery.git
cd traefik-domain-discovery
./traefik-domain-discover --docker --traefik-api http://127.0.0.1:8080/api/rawdataNo fixed install path is required. Copy or clone the repo anywhere and run it directly with python3.
Optional, for fuller YAML support if your host does not already have PyYAML:
python3 -m pip install --user PyYAMLPrimary command:
./traefik-domain-discover --docker --traefik-api http://127.0.0.1:8080/api/rawdataWith file-provider config and access-log enrichment:
./traefik-domain-discover \
--docker \
--traefik-api http://127.0.0.1:8080/api/rawdata \
--file-provider-dir /path/to/traefik/dynamic \
--access-log /var/log/traefik/access.log \
--output /tmp/traefik-domain-discovery/discovered-hosts.yaml \
--json-output /tmp/traefik-domain-discovery/discovered-hosts.json \
--selection-template /tmp/traefik-domain-discovery/selected-targets.yamlQuick local example with the included sample config:
./traefik-domain-discover \
--file-provider-dir examples \
--output /tmp/discovered-hosts.yaml \
--json-output /tmp/discovered-hosts.jsonOptional manual zone overrides:
./traefik-domain-discover \
--docker \
--zone-overrides examples/zone-overrides.example.yaml \
--output /tmp/discovered-hosts.yamlThe main output is a compact, deduplicated review file. Each host is listed alphabetically with a short sources list showing where it came from:
hosts:
- host: app.example.com
zone: example.com
dns_provider: manual
seen_in_access_log: true
sources:
- type: docker_label
container: web
service: app
project: homelab
- type: file_provider
service: app-service
file: dynamic.yamlHostRegexp(...) rules are kept and include a short review note, but router names, rule text, label keys, and selection flags are not included in the default discovery output.
Zone detection is a lightweight heuristic. It uses the registrable domain shape for common cases, including common multi-part suffixes such as co.uk; it does not ship a full public suffix database. Provider values are manual review data from an optional override file:
zone_overrides:
candystreet.net:
dns_provider: internetx-xml
elternforum-lachen.ch:
dns_provider: manualWhen the Traefik API is available, --docker plus --traefik-api is the preferred practical path. File-provider parsing stays optional.
If you do not pass --output, the default file is written to /tmp/traefik-domain-discovery/discovered-hosts.yaml on a typical Linux host.
MIT