Aside - DNS
So, I clearly missed a post. Means you get two today. Possibly three, if I'm feeling ambitious. Right now, it's time to talk about something I probably should have mentioned earlier: You will need a DNS domain with the ability to add an arbitrary number of records to it to follow this guide. I'd suggest picking one that allows dynamic DNS updates, in case you are trying to run this on a dynamic IP address; I personally use GoDaddy as registrar, and run my own DNS server to host my domains, but such a setup is beyond the scope of this blog - well, for now. My suggested setup would be, for simplicity, to have your domain's primary A record - the record pointing to "your.domain" - configured with your dynamic IP address and updated via ddclient. All the subdomains your containers are published under are CNAMEs pointing to "your.domain". That way, updating the IP address in one place allows all your containers to remain reachable.
For ddclient, we'll (of course) use a docker container. The relevant compose file snippet is
ddclient:
configs:
- source: ddclient-config
target: /config/ddclient.conf
deploy:
replicas: 1
environment:
PUID: 10020
PGID: 10020
TZ: Etc/UTC
image: "linuxserver/ddclient"
logging:
driver: journald
networ ks:
- homelab
restart: on-failure
We will need to set up the configuration, so edit configs/ddclient.conf with the following information
daemon=300 # check every 300 seconds
syslog=yes # log update msgs to syslog
mail=your@email.address # mail all msgs to root
mail-failure=your@email.address # mail failed update msgs to root
pid=/var/run/ddclient.pid # record PID in file.
ssl=yes # use ssl-support. Works with
usev4q=webv4, \ # find IP address via web
webv4=ipify-ipv4 # Use IPify's IPv4 address. These two work analog for IPv6
protocol=godaddy, \
login=<godaddy API token>, \
password=<godaddy API secret>, \
zone=your.domain, \
your.domain
If you would prefer a different registrar,
$ docker run --rm linuxserver/ddclient ddclient --help
outputs the master help. The various --list options output supported supported protocols, services and devices you can use, if your DNS situation requires it. I would recommend against using any web service for IP address determination that does not offer https access, however.
And insert in the compose file's root-level configs section:
ddclient-config:
file: /home/<your user>/configs/ddclient.conf
Now restart the stack.
$ docker stack deploy -c <compose file> --prune homelab
Files and snippets are, as usual, on my Gitea.