Configuring Duck DNS with Docker

18-08-2024 - 1 minute, 12 seconds -
documentation dns duckdns docker

Getting Started with Duck DNS Using Docker


Introduction

Duck DNS is a free dynamic DNS service that allows you to update your domain's IP address automatically. This solution is particularly useful for users with dynamic IP addresses, allowing consistent access to services running on their home network.

Prerequisites

Before proceeding, ensure you have the following:

Setting Up Duck DNS with Docker

1. Create a Docker Compose File

Start by creating a docker-compose.yml file that defines your Duck DNS service.

services:
  duckdns:
    image: lscr.io/linuxserver/duckdns:latest
    container_name: duckdns
    environment:
      - SUBDOMAINS=example,example2
      - TOKEN=xxxxxxxx-xxxxxx-xxxxx-xxxxx-xxxx
      - UPDATE_IP=ipv4 #optional
    volumes:
      - ./config:/config #optional
    restart: unless-stopped

Key Notes:

  • Replace SUBDOMAINS with your Duck DNS subdomains.
  • Replace TOKEN with your Duck DNS token.
  • Optionally, you can configure other environment variables such as PUID, PGID, and TZ to fit your setup.
2. Run Duck DNS

To start the Duck DNS service, use Docker Compose:

docker-compose up -d

This command will launch the Duck DNS container, automatically updating your IP address to keep your domains pointed correctly.

Example Caddy Configuration
pancakepuncher.com {
  handle_path /code* {
    reverse_proxy host.docker.internal:8080
  }
}

Resources and References

Conclusion

By following this guide, you have successfully set up Duck DNS using Docker, ensuring that your domain is always updated with the correct IP address.