Configuration
Configuration

Configuration

Docker Cloudflare Tunnel Sync is configured with environment variables or Docker secrets for sensitive Cloudflare values.

Environment variables

VariableRequiredDefaultDescription
CF_API_TOKENyes-Cloudflare API token. Can also be provided as a Docker secret.
CF_ACCOUNT_IDyes-Cloudflare account identifier. Can also be provided as a Docker secret.
CF_TUNNEL_IDyes-Cloudflare Tunnel identifier. Can also be provided as a Docker secret.
CF_API_BASE_URLnohttps://api.cloudflare.com/client/v4Override Cloudflare API base URL.
DOCKER_HOSTno-Docker daemon host. Standard Docker environment variable.
DOCKER_API_VERSIONno-Docker API version override.
SYNC_POLL_INTERVALno30sController poll interval.
SYNC_RUN_ONCEnofalseRun a single reconciliation and exit.
SYNC_DRY_RUNnofalseLog planned changes without applying them.
SYNC_MANAGED_TUNNELnofalseAllow the controller to overwrite the tunnel ingress configuration.
SYNC_MANAGED_ACCESSnofalseAllow the controller to create or update Cloudflare Access apps and policies.
SYNC_MANAGED_DNSnofalseAllow the controller to create or update DNS CNAME records for tunnel hostnames.
SYNC_DNS_ZONESno-Comma-separated DNS zones kept in the orphan cleanup scan when SYNC_DELETE_DNS=true.
SYNC_DELETE_DNSnofalseDelete managed DNS records in selected zones when they are no longer declared by labels.
SYNC_MANAGED_BYnodocker-cf-tunnel-syncManaged-by marker used for DNS comments and Access tags.
LOG_LEVELnoinfoLog level: debug, info, warn, or error.

Managed modes

The controller is conservative by default. It only applies a category of changes when the matching managed flag is enabled.

FlagCloudflare resources managed
SYNC_MANAGED_TUNNEL=trueCloudflare Tunnel ingress rules
SYNC_MANAGED_DNS=trueDNS CNAME records for managed hostnames
SYNC_MANAGED_ACCESS=trueCloudflare Access applications and policies

Dry-run mode

Dry-run mode logs planned changes without applying them:

1
-e SYNC_DRY_RUN=true

Use dry-run mode for first deployments, label validation, audits, and cleanup checks.

Run once mode

Run once mode performs a single reconciliation and exits:

1
-e SYNC_RUN_ONCE=true

DNS cleanup scope

When SYNC_DELETE_DNS=true, the controller deletes managed DNS records that are no longer declared by Docker labels.

The cleanup scan is limited to zones selected from current labels plus any zones listed in SYNC_DNS_ZONES.

Logging

Set the log level with LOG_LEVEL:

1
-e LOG_LEVEL=debug