Docker Cloudflare DDNS image will allow us to use the free CloudFlare DNS Service as a Dynamic DNS Provider (DDNS). So, In this article, we’ll dig a bit deeper into the details.
As part of our Docker Hosting Support, Bobcares provides solutions to all queries, large and small.
Let’s take a closer look at Docker cloud-flare DDNS.
Docker Cloudflare DDNS
Cloudflare DDNS is a Docker image that automatically updates DNS records on Cloudflare. However, this small Alpine Linux-based Docker image allows us to use CloudFlare’s free DNS service as a dynamic DNS provider (DDNS).
Most importantly, this is a multi-arch image that will run on devices like the Raspberry Pi that are amd64, aarch64, and armhf.
Image Variants
Usage
The setup is simple.
docker run \ -e API_KEY=xxxxxxx \ -e ZONE=example.com \ -e SUBDOMAIN=subdomain \ oznu/cloudflare-ddns
Parameters
--restart=always
– After the host reboots, this makes sure the container restarts automatically.-e API_KEY
– Our Cloudflare API token with a specific scope. See the section below on how to create a Cloudflare API token. RequiredAPI_KEY_FILE
– From where we’ll get our Cloudflare scoped API token.API_KEY_FILE
takes precedence if bothAPI_KEY_FILE
andAPI_KEY
are there.-e ZONE
– The DNS zone should receive DDNS updates. RequiredZONE_FILE – From where we want to load our Cloudflare DNS Zone. If we specify both ZONE FILE and ZONE, ZONE FILE takes precedence.
-e SUBDOMAIN
– A subdomain of the zone where DNS changes can be made. If this is not there, the root zone will be used.SUBDOMAIN_FILE
– The path from which our Cloudflare DNS Subdomain is loaded.SUBDOMAIN_FILE
takes precedence if bothSUBDOMAIN_FILE
andSUBDOMAIN
are there.
Optional Parameters
-e PROXIED
– Iftrue
, traffic will be routed through the Cloudflare CDN.false
is the default value.-e RRTYPE=A
– To use IPv6 records instead of IPv4 records, setAAAA
. For IPv4 records, it defaults toA
.-e DELETE_ON_STOP
– Iftrue
, the dns record will be deleted when the container is stopped.false
is the default value.-e INTERFACE=tun0
– Set totun0
to get the IP address from atun0
network interface. If this field is left blank, the public IP address will be used instead. The--network host
run argument is required.-e CUSTOM_LOOKUP_CMD="echo '1.1.1.1'"
– Set to any shell command to execute them, with the IP retrieved from the standard output. To use the default IP address detection methods, leave it unchecked.-e DNS_SERVER=10.0.0.2
– Set the IP address of the DNS server we’d like to use to this value. Otherwise, it falls back to 1.1.1.1.-e CRON="@daily"
– Before the exec portion, set our own custom CRON value. Defaults value is set to every 5 minutes –*/5 * * * *
.
Depreciated Parameters
-e EMAIL
– When using an Account-level token, our CloudFlare email address is used. When using a scoped API token, this variable MUST NOT be set.
Creating a Cloudflare API token
Go to Dashboard > profile > api-tokens and follow these steps to create a CloudFlare API token for the DNS zone:
- Firstly, To create a token, click the Create Token button.
- Secondly, Give the token a name. For example,
cloudflare-ddns
- Permissions should be granted to the token as follows:
Read permissions for Zone-Zone Settings
Read permissions for Zone-Zone
Edit permissions forZone – DNS - After that, set the resources for the zone to:
Include – All zones - Further, Complete the wizard and paste the generated token into the container’s
API_KEY
variable.
Multiple Domains
Create CNAME records in CloudFlare if we need multiple records pointing to the public IP address.
IPv6
Set the environment variable RRTYPE=AAAA
if we want to set IPv6 records.
Moreover, we’ll also need docker with IPv6 support or a container with host networking enabled.
Docker Compose
On the other hand, if we use Docker Compose, follow these steps:
version: '2' services: cloudflare-ddns: image: oznu/cloudflare-ddns:latest restart: always environment: - API_KEY=xxxxxxx - ZONE=domainname.com - SUBDOMAIN=subdomain.domainname.com - PROXIED=false
[Looking for a solution to another query? We are just a click away.]
Conclusion
In conclusion, Docker Cloudflare DDNS is a simple Docker image that wraps an example script to dynamically update a Cloudflare DNS record.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
var google_conversion_label = "owonCMyG5nEQ0aD71QM";
Hi,
can i use diffrent Domains set in one Compose File?
can i set IPV4 and IPV6 for Domain in one Compose File?
Yes you can have both IPv4 and IPv6 addresses associated with the same dns name.
can i use a wildcard for the subdomain to capture all subdomains? e.g. *.example.com ?
Yes, you can use a wildcard for the subdomain to capture all subdomains using a pattern like “*.example.com” in Docker Cloudflare DDNS.