Cloudflare Dynamic DNS updater
800
Dynamic DNS (DDNS) updater for Cloudflare, packaged as a multi-architecture Docker image, optimized for Raspberry Pi 3, 4, and 5 as well as Linux x86_64 systems.
This project is designed to automatically keep a Cloudflare DNS (A) record updated with your public IP address, making it ideal for game servers, homelabs, and connections without a static IP.
β
Uses the official Cloudflare API (PATCH /dns_records)
β Multi-arch Docker:
linux/amd64 (PC / VPS)linux/arm/v7 (Raspberry Pi 3)linux/arm64 (Raspberry Pi 4 and 5)β Automatic semantic versioning (Semantic Release)
β Automatic publishing to:
β Logs with date and time (Europe/Madrid)
β Non-root user (improved security)
β No calls to Cloudflare if the IP has not changed
β Very lightweight (Alpine Linux)
β Optional persistent state using Docker volumes (avoids false IP updates on restart)
By default, the container stores its internal state (last known IP address and DNS Record ID) inside /data.
To avoid false IP change detections after container restarts, it is strongly recommended to mount a persistent volume.
The following files are stored in /data:
last_ip β last public IP detecteddns_record_id β Cloudflare DNS Record ID (cached after first run)If no volume is mounted, the container will still work correctly, but this state will be lost when the container restarts.
docker pull negrii/cloudflare-ddns:latest
docker pull ghcr.io/negri234279/cloudflare-ddns:latest
Also available by version:
v1.0.0
v1.0.1
v1.1.0
.envCF_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxx
CF_ZONE_ID=yyyyyyyyyyyyyyyyyyyyyyyy
CF_DOMAIN=foo.bar.es
CF_RECORD_TYPE=A
CF_TTL=1
CF_PROXIED=false
CF_INTERVAL=300
TZ=Europe/Madrid
π‘
CF_TTL=1TTL automΓ‘tico en Cloudflare.
docker run -d \
--name cloudflare-ddns \
--env-file .env.dev.local \
--restart unless-stopped \
-v cloudflare-ddns-data:/data \
negrii/cloudflare-ddns:latest
πΎ The
cloudflare-ddns-datavolume ensures state persistence across container restarts.Without it, the container may detect a false IP change on startup.
docker-compose.ymlservices:
cloudflare-ddns:
image: negrii/cloudflare-ddns:latest
container_name: cloudflare-ddns
env_file:
- .env
restart: unless-stopped
volumes:
- cloudflare-ddns-data:/data
volumes:
cloudflare-ddns-data:
πΎ The
cloudflare-ddns-datavolume ensures state persistence across container restarts.Without it, the container may detect a false IP change on startup.
docker compose up -d
View logs:
docker logs -f cloudflare-ddns
docker rm -f cloudflare-ddns
docker volume rm cloudflare-ddns-data
β οΈ This will remove all persisted state.
2025-03-12 02:20:43 π Cloudflare DDNS running on armv7l (TZ=Europe/Madrid)
2025-03-12 02:20:43 β±οΈ Interval: 300s
2025-03-12 02:20:43 β
Persistence enabled: /data is a mounted volume
2025-03-12 02:25:43 βΉοΈ IP unchanged (203.0.113.45)
Create an API Token with permissions:
Cloudflare Dashboard β your domain bar.es β Overview β Zone ID
It is not necessary to manually obtain the DNS Record ID.
The container will automatically retrieve the DNS Record ID from Cloudflare using the domain and zone information provided on first run, and store it internally.
| Variable | Description |
|---|---|
CF_API_TOKEN | Cloudflare token |
CF_ZONE_ID | Zone ID |
CF_DOMAIN | Domain or subdomain |
CF_RECORD_TYPE | DNS record type (default A) |
CF_TTL | TTL (default 1 = automatic) |
CF_PROXIED | true / false (default false) |
CF_INTERVAL | Interval in seconds (default 300) |
TZ | Time zone (default Europe/Madrid) |
STATE_DIR | State directory (default /data) |
docker compose -f 'docker-compose.dev.yml' up -d --build
This project uses GitHub Actions for:
Each push to main generates a new version if the commits require it.
Negrii π https://github.com/Negri234279β
MIT License
Pull requests and suggestions are welcome π
If you find this project useful, leave a β on GitHub
Content type
Image
Digest
sha256:885ac9ffeβ¦
Size
7.3 MB
Last updated
7 months ago
docker pull negrii/cloudflare-ddns:v1.6.1