DEV Community

Stop Copy-Pasting dns: Blocks: Introducing Transparent DNS Injection in Gubernator

If youโ€™ve ever built a containerized home lab, a multi-host cluster, or an internal development environment using Docker Compose with custom local DNS (like CoreDNS), you know this exact pain point:

services:
  web:
    image: nginx:alpine
    dns:
      - 192.168.1.100   # Hardcoded CoreDNS IP
  api:
    image: my-api:latest
    dns:
      - 192.168.1.100   # Copied again...
  db:
    image: postgres:alpine
    dns:
      - 192.168.1.100   # And again!

It is repetitive, it litters your configuration files, and if you forget to paste that block or the DNS IP changes, your container is born blind-unable to resolve internal services or talk to the internet. With Gubernator, we decided to eliminate this boilerplate entirely.

The Solution: Transparent DNS Injection ๐Ÿช„

Starting with version v2.4.13, Gubernator implements Transparent DNS Injection. Now, you can deploy your standard, clean, unedited docker-compose.yml file. No custom network configurations, no hardcoded IPs.

# Standard, clean Compose file. No "dns:" blocks required!
services:
  web:
    image: nginx:alpine
  api:
    image: my-api:latest
  db:
    image: postgres:alpine

Behind the scenes, Gubernator's deployment executor intercepts container creation and dynamically injects the cluster's CoreDNS host IP directly into the container's runtime configuration.

How It Works Under the Hood

  • Host IP Auto-Detection: Gubernator automatically detects the Manager Node IP at startup (either via GBNT_HOST_IP or by testing outbound gateway paths).
  • Dynamic Templating: CoreDNS templates are updated on the fly to handle custom local routing domains (like *.gbnt and *.gbnt.test).
  • Runtime Interception: During scheduling and task execution, Gubernator intercepts the container host configuration and populates the DNS servers parameter with the dynamically resolved CoreDNS address.

The Result: 0% Boilerplate, 100% Magic

Your containers are deployed instantly and gain immediate out-of-the-box support to:

  • Resolve internal service domains seamlessly.
  • Communicate with the outer internet through your configured upstream forwarders.
  • Adapt automatically even if the physical IP of your manager host changes.

Get Started

Gubernator is designed to combine the simplicity of Docker Compose with the scheduling power of Nomad. You can inspect the code, read the documentation, and launch your first cluster today on GitHub:

๐Ÿ‘‰ Gubernator GitHub Repository

If you find this feature useful, don't forget to drop a โญ๏ธ on GitHub! What are your thoughts on container DNS management? Let me know in the comments!

Comments

No comments yet. Start the discussion.