π³ A minimal config domain resolver for Docker.
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.
There are three parts to setting up a local domain with Docker:
- Create a resolver on the Host machine.
- Direct traffic from the Host machine to other Docker services.
- 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.
The domain-resolver
docker image is available from both GitHub Container Registry (GHCR) and Docker Hub.
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.
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.
β₯ π³