This install assumes that Docker has been installed previously, and extends the Docker stack created for the Traefik Reverse Proxy.
Docker Cloudflare DDNS is a simple docker image that allows any changes to a DHCP allocated WAN IP address to be updated to the DNS provider Cloudflare. It passes the current WAN IP address via the Cloudflare API every five minutes (default) where it is compared with the IP address set in Cloudflare, and updated if different.
Install Cloudflare DDNS
Add the following service definition to docker-compose.yml in docker root folder. The Proxied parameter is True as we used Cloudflare in proxy mode. Refer to section below for the CLOUDFLARE_API_TOKEN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
version: "3.9"
# SERVICES ####################################################
services:
cf-ddns:
container_name: cf-ddns
image: oznu/cloudflare-ddns:latest
#
restart: always
#
environment:
- PUID=<span style="color:red;">$PUID</span>
- PGID=<span style="color:red;">$PGID</span>
- API_KEY=<span style="color:red;">$CLOUDFLARE_API_TOKEN</span>
- ZONE=<span style="color:red;">$DOMAINNAME_CLOUD_SERVER</span>
- PROXIED=true
From the Docker root folder, run this command to build the container:
1
sudo docker compose -f dc-cfddns.yml up -d
Check the logs in Portainer to confirm communication with the Cloudflare API
Cloudflare API Token
To create a Cloudflare Api Token, go to Cloudflare and do the following:
- Click Create Token
- In the Create Custom Token section at the bottom, click Get started
- Set Token name: cf-ddns
- Grant the Permissions (click +Add more twice):
- Account = Zone, Select item = Zone Settings, select = Read
- Zone – Zone : Read
- Zone – DNS : Edit
- Set the Zone Resources to:
- Include – All zones
- Click Continue to summary, copy the generated token and add to the .env file in Docker root
Resources
- Cloudflare DDNS documentation on Docker Hub
- Update Cloudflare with your Dynamic IP address (YouTube)