Fixed config loading, added Dockerfile
This commit is contained in:
35
README.md
35
README.md
@@ -1,6 +1,6 @@
|
||||
# docker-nsupdate-ddns
|
||||
|
||||
This script pushes container/ip information from a Docker instance to a DNS server via the DNS update mechanism desribed in RFC 2136 (nsupdate). nsupdate is implemented by ISC Bind9.
|
||||
This script pushes container/ip information from local Docker instance to a DNS server via the DNS update mechanism desribed in RFC 2136 (nsupdate). nsupdate is implemented by ISC Bind9.
|
||||
|
||||
Every REFRESH_INTERVAL seconds, it queries all the Docker containers on the local host, finds their IP and pushes it with the name to the DNS server.
|
||||
|
||||
@@ -13,22 +13,25 @@ The names of the environment variables is the same as in the config file. Enviro
|
||||
### Environment variables
|
||||
```bash
|
||||
docker run -d \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-e DOCKER_SOCKET=/var/run/docker.sock \
|
||||
-e DOMAIN=int.mtak.nl \
|
||||
-e HOSTNAME_LABEL=nl.mtak.docker-bind-ddns.hostname \
|
||||
-e HOSTNAME_LABEL=nl.mtak.docker-nsupdate-ddns.hostname \
|
||||
-e DEFAULT_NETWORK=10.100.0.192/26 \
|
||||
-e REFRESH_INTERVAL=5 \
|
||||
-e ONE_SHOT=True \
|
||||
-e NAMESERVER=10.100.0.11 \
|
||||
-e TSIG_NAME=dck1 \
|
||||
-e TSIG_KEY=SyYXDCJ4kIs3qhvI= \
|
||||
merijntjetak/docker-bind/ddns:latest
|
||||
merijntjetak/docker-nsupdate-ddns:latest
|
||||
```
|
||||
|
||||
### Config file
|
||||
```bash
|
||||
cat <<EOF >configfile
|
||||
DOCKER_SOCKET=/var/run/docker.sock
|
||||
DOMAIN=int.mtak.nl
|
||||
HOSTNAME_LABEL=nl.mtak.docker-bind-ddns.hostname
|
||||
HOSTNAME_LABEL=nl.mtak.docker-nsupdate-ddns.hostname
|
||||
DEFAULT_NETWORK=10.100.0.192/26
|
||||
REFRESH_INTERVAL=5
|
||||
ONE_SHOT=True
|
||||
@@ -38,15 +41,17 @@ TSIG_KEY=SyYXDCJ4kIs3qhvI=
|
||||
EOF
|
||||
|
||||
docker run -d \
|
||||
-v `pwd`/configfile:/configfile
|
||||
merijntjetak/docker-bind-ddns:latest /configfile
|
||||
-v `pwd`/configfile:/configfile \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
merijntjetak/docker-nsupdate-ddns:latest /configfile
|
||||
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
- `DOCKER_SOCKET` - Sets the location of the Docker socket
|
||||
- `DOMAIN` - Sets the domain in which the records are created. Needs to match the Bind zone.
|
||||
- `HOSTNAME_LABEL` - Docker label to override the default record name with. Use with `docker --label=nl.mtak.docker-bind-ddns.hostname=nginx` to get `nginx.int.mtak.nl`
|
||||
- `HOSTNAME_LABEL` - Docker label to override the default record name with. Use with `docker --label=nl.mtak.docker-nsupdate-ddns.hostname=nginx` to get `nginx.int.mtak.nl`
|
||||
- `DEFAULT_NETWORK` - Preferred network to find IP for, in case there are multiple networks
|
||||
- `REFRESH_INTERVAL` - Interval between updates
|
||||
- `ONE_SHOT` - Set to True for the script to update once and immediately quit (nice for debugging)
|
||||
@@ -79,18 +84,17 @@ docker run -d \
|
||||
## Design
|
||||
### Requirements
|
||||
|
||||
- Eventual redunancy (Bind9 zone transfers to secondary)
|
||||
- Support for multiple individual Docker servers
|
||||
- IPv6 support
|
||||
- Detect hostname in decreasing order of priority:
|
||||
- [x] Eventual redundancy (Bind9 zone transfers to secondary)
|
||||
- [x] Support for multiple individual Docker servers
|
||||
- [ ]IPv6 support
|
||||
- [x]Detect hostname in decreasing order of priority:
|
||||
- label
|
||||
- Container name
|
||||
- Forward-only
|
||||
- Clean up DNS (DNS is stateful but the script isn't, so there might be a mismatch)
|
||||
- [x]Forward-only
|
||||
- [ ]Clean up DNS (DNS is stateful but the script isn't, so there might be a mismatch)
|
||||
|
||||
### Todo
|
||||
### Nice to have
|
||||
|
||||
- Make event-driven with [Ahab](https://github.com/instacart/ahab)
|
||||
- Add tests
|
||||
|
||||
### Alternatives
|
||||
@@ -98,3 +102,4 @@ docker run -d \
|
||||
CoreDNS didn't fit the requirements, because zone transfers out of a CoreDNS server do not
|
||||
include the records from the coredns-dockerdiscovery plugin.
|
||||
|
||||
K3s and k8s would probably do this, but incur significant complexity over a standalone Docker instance.
|
||||
|
||||
Reference in New Issue
Block a user