Dynamic DNS with Cloudflare and Docker
Setting up Dynamic DNS (DDNS) on Cloudflare with the help of Docker is quick and easy thanks to oznu!
How to set up Dynamic DNS with Cloudflare and Docker?
I usually deploy via Docker Compose so that’s what I’ll outline first. Both of the below will do the same thing, however. I’ve pre-filled the environment fields here as an example so both of these assume that my API Key is 1234 and I want to update the
ddns A record on the bret.dk domain.
For your setup, you’ll need to update the API Key to the one generated via your Cloudflare Dashboard (giving it Edit DNS permissions on your chosen domain) and if you wanted to set up home.yourdomain.com you’d set your ZONE to yourdomain.com and SUBDOMAIN to home. The PROXIED field defines whether or not you want to proxy requests to your subdomain over CloudFlare’s CDN. Change this to “true” if you want to do that. (This can sometimes cause issues with certain pieces of software so you can always leave this unfiltered and if a specific piece of software needs the proxy, you can set up a CNAME record and filter that!)
version: '2' services: cloudflare-ddns: image: oznu/cloudflare-ddns:latest restart: always environment: - API_KEY=1234 - ZONE=bret.dk - SUBDOMAIN=ddns - PROXIED=false
docker run \ -e API_KEY=1234 \ -e ZONE=bret.dk \ -e SUBDOMAIN=ddns \ -e PROXIED=false \ oznu/cloudflare-ddns
This Cloudflare Dynamic DNS Docker image will run on most ARM-based SBC (Raspberry, Pi, Orange Pi, ASUS Tinkerboard, RockPi etc) and any x86/x64 system but if you have any issues, let me know in the comments and I’ll see if I can help!
In total, setting up Cloudflare DDNS took me 5 minutes to get up and running and now I can have a constantly updated Dynamic DNS entry for my home network. You could use this to point CNAME records for self-hosted projects, or even ensure your NGINX Proxy Manager is always up-to-date on the correct IP.