Skip to content

domjtalbot/docker-domain-resolver

Repository files navigation


Domain Resolver

🐳 A minimal config domain resolver for Docker.


Why?

Custom local domains are a great tool when developing software, but their set-up steps can be tedious and often forgotten.

This Docker image automates part of the process of setting up a local domain so that you can focus on your development.


How does it work?

There are three parts to setting up a local domain with Docker:

  1. Create a resolver on the Host machine.
  2. Direct traffic from the Host machine to other Docker services.
  3. Define a server service to use the domain.

The domain-resolver Docker image is responsible for step 2, directing traffic from the Host machine to other Docker services.


How to use

The domain-resolver docker image is available from both GitHub Container Registry (GHCR) and Docker Hub.

Docker Compose

Add the following service to your docker-compose.yml config:

services:
  domain-resolver:
    container_name: domain-resolver

    # GitHub Container Registry (GHCR)
    # image: ghcr.io/domjtalbot/domain-resolver

    # Docker Hub
    image: domjtalbot/domain-resolver

    environment:
      # The domain you want to resolve
      # (Defaults to `test`)
      - DOMAIN=example.dockerdomainresolver

      # Cutom DNS servers
      # (Defaults to Cloudflare)
      # - NS1=1.0.0.1
      # - NS2=1.1.1.1

      # Add additional config for dnsmasq
      # (Defaults to #)
      # - ADDITIONAL_CONFIG=#
    ports:
      - "127.0.0.1:53:53/udp"
    volumes:
      # Allow domain-resolver to check if the
      # domain has been configured on the host.
      - /etc/resolver:/etc/resolver:ro
    restart: always

You can then run Docker compose using:

docker-compose up -d

This presumes a resolver already exists on the Host machine. See the next step for automating the creation of a resolver on the Host machine.

Create a resolver on the Host machine

To help automate the creation of a resolver on the Host machine, you can use the create-host-resolver script.

./create-host-resolver.sh --domain example.dockerdomainresolver

Please note that the process of creating a resolver varies depending on the type of Host. The create-host-resolver script currently only supports macOS.



♥ 🐳