Setting up DuckDNS in a Docker Container
DuckDNS is a free dynamic DNS service that will point a subdomain of duckdns.org to an IP of your choice. This IP can then be updated using a scripted process on a client machine. The most common application for this is to provide an easy to remember name to use for accessing a home lab/server as often a user’s ISP will regularly change their external IP address.
Setting up DuckDNS using Docker only takes a couple minutes. We will need to start by going to the DuckDNS website and logging in using one of the available OAuth providers, Google, GitHub, etc. Once you are logged in you wil be presented with a very basic screen listing your account information at the top and a section to add subdomains at the bottom. You will want to go ahead and choose an available subdomain here and add it to your list. A quick Google search for “my IP” will let you verify that your external IP is correct. Make a note of your domain and your token as we will need both when we go to create our container that will keep our external IP up to date.
We will be using the LinuxServer container image for our purposes here. It is a regularly updated image and is available on the Docker Hub here. You will want to start off by determining your Docker user UID and GID by running id YOUR_DOCKER_USERNAME_HERE
on your host machine. You can then plug all of your information into the Docker command below to spin up your DuckDNS container. Be sure to update your timezone as appropriate.
docker create \
--name=duckdns \
--restart=always \
-e PUID=YOUR_UID_HERE \
-e PGID=YOUR_GID_HERE \
-e TZ=America/Chicago \
-e SUBDOMAINS=YOUR_DOMAIN_HERE \
-e TOKEN=YOUR_TOKEN_HERE \
linuxserver/duckdns
After you have created your container you can start it using docker start duckdns
and then use a docker ps
to verify it is running. You can run a ping from a terminal to your FQDN to verify that it is returning your proper external IP and then test again once your know your external IP has changed.
Leave a comment