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
– After the host reboots, this makes sure the container restarts automatically.--restart=always
– Our Cloudflare API token with a specific scope. See the section below on how to create a Cloudflare API token. Required-e API_KEY
– From where we’ll get our Cloudflare scoped API token.API_KEY_FILE
takes precedence if bothAPI_KEY_FILE
andAPI_KEY_FILE
are there.API_KEY
– The DNS zone should receive DDNS updates. Required-e ZONE
ZONE_FILE – From where we want to load our Cloudflare DNS Zone. If we specify both ZONE FILE and ZONE, ZONE FILE takes precedence.
– A subdomain of the zone where DNS changes can be made. If this is not there, the root zone will be used.-e SUBDOMAIN
– The path from which our Cloudflare DNS Subdomain is loaded.SUBDOMAIN_FILE
takes precedence if bothSUBDOMAIN_FILE
andSUBDOMAIN_FILE
are there.SUBDOMAIN
Optional Parameters
– If-e PROXIED
, traffic will be routed through the Cloudflare CDN.true
is the default value.false
– To use IPv6 records instead of IPv4 records, set-e RRTYPE=A
. For IPv4 records, it defaults toAAAA
.A
– If-e DELETE_ON_STOP
, the dns record will be deleted when the container is stopped.true
is the default value.false
– Set to-e INTERFACE=tun0
to get the IP address from atun0
network interface. If this field is left blank, the public IP address will be used instead. Thetun0
run argument is required.--network host
– 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 CUSTOM_LOOKUP_CMD="echo '1.1.1.1'"
– 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 DNS_SERVER=10.0.0.2
– Before the exec portion, set our own custom CRON value. Defaults value is set to every 5 minutes –-e CRON="@daily"
.*/5 * * * *
Depreciated Parameters
– When using an Account-level token, our CloudFlare email address is used. When using a scoped API token, this variable MUST NOT be set.-e EMAIL
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
variable.API_KEY
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.
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.