https://github.com/f-koehler/simple-docker-dns-server
Easily run a lightweight DNS server via docker-compose (e.g. for your LAN/VPN)
https://github.com/f-koehler/simple-docker-dns-server
dns dns-server dnsmasq docker docker-compose podman podman-compose
Last synced: about 1 year ago
JSON representation
Easily run a lightweight DNS server via docker-compose (e.g. for your LAN/VPN)
- Host: GitHub
- URL: https://github.com/f-koehler/simple-docker-dns-server
- Owner: f-koehler
- License: mit
- Created: 2022-05-27T15:36:55.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-26T09:22:41.000Z (about 1 year ago)
- Last Synced: 2025-04-11T04:42:29.899Z (about 1 year ago)
- Topics: dns, dns-server, dnsmasq, docker, docker-compose, podman, podman-compose
- Language: Dockerfile
- Homepage:
- Size: 53.7 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Simple DNS server using docker-compose and dnsmasq
[](https://github.com/f-koehler/simple-docker-dns-server/actions/workflows/docker.yml)
This repository showcases how you can easily set up a simple DNS server using `dnsmasq` and `docker-compose`/`docker`.
DNS entries can be added directly via the `docker-compose.yml` file, which can be easily automated (e.g. via ansible).
Such a simple DNS server is ideal for internal use (e.g. at home or within a wireguard/tailscale VPN network).
## Option 1 - `docker-compose`
Change the DNS entries in the `extra_hosts` section in `docker-compose.yml`. The DNS server can be started by running
```bash
docker-compose up -d
```
from the project directory.
By default, the DNS server will listen all IP addresses/interfaces (equivalent to `0.0.0.0`). This can be changed in the `ports` section by changing `53:53/tcp` to `:53:53/tcp` etc.
The server can be stopped by running
```bash
docker-compose down
```
from the project directory.
`dnsmasq` can be configured by modifying the `dnsmasq.conf` file. After changing this file, it is necessary to first bring the server down and restart using the aforementioned commands.
## Option 2 - Plain `docker`
The server can be run with plain `docker` commands as well. First, the docker image is built using
```bash
docker build -t simple-docker-dns .
```
and then started with
```bash
docker run -d --name dns_service \
--restart unless-stopped \
-v /etc/localtime:/etc/localtime:ro \
-v $(pwd)/dnsmasq.conf:/etc/dnsmasq.conf:ro \
-p 53:53/tcp \
-p 53:53/udp \
--add-host foo.bar:192.168.0.1 \
simple-docker-dns
```
The DNS entries are specified using `--add-host `.
The server can subequently be stopped using
```bash
docker stop simple-docker-dns
```
`dnsmasq` can be configured by modifying the `dnsmasq.conf` file. After changing this file, it is necessary to first bring the server down, rebuild the docker image and finally start it again.