DEV Community

Henrik Klarup
Henrik Klarup

Posted on

Putting the duck in docker.

Lets say you are setting up a home automation system, and that you want to access it when you are away from your home.
Having to remember your IP is hard, and your ISP might change in anytime they want to. You need something smarter. You need DuckDNS.

DuckDNS allows you to connect your IP with a DuckDNS domain of your choosing, something like Now that's cool!

But how does DuckDNS know what IP it should direct you to? It doesn't, at least not by pure magic. You need to tell it. You could either do this manually, but again you ISP might change your IP unless you've payed for it.
You need a service to report it.

But running a service is hard, you need to have the correct dependencies installed for that specific service to run and you need to make sure that you restart it if it goes down.

Luckily someone out on the wild internet has you covered, as long as you have docker on your server.

If you don't know about docker, go check it out here.

So lets get started.

First go to DuckDNS and sign in.
Here you can select what you want your domain to be. Here you will also find your token.

Lets create a docker container.

docker create \
  --name=duckdns \
  -e TZ=Europe/Copenhagen \
  -e SUBDOMAINS=myawesomehomeautomation \
  -e TOKEN=<your_token_here> \
  --restart unless-stopped \

Now we have a docker container ready for use. When started this will start sending a request to DuckDNS with our public IP. It also uses docker to keep restarting it it falls over for some reason other than us stopping it ourselves.

So let's run it.

docker run duckdns

There we go.

We can now navigate to and we should hit our own server. We can also see that the reported IP in the DuckDNS interface matches the one from a site like WhatsMyIp.

Top comments (0)