-
-
Couldn't load subscription status.
- Fork 68
ManagingDNSZones.md
Chris edited this page Jun 22, 2025
·
3 revisions
To create the necessary DNS records for your services, DockFlare needs to know which Cloudflare Zone (i.e., your domain name like example.com) a given hostname belongs to.
DockFlare uses a two-level approach to determine the correct zone.
This is the primary method and covers most use cases.
- You provide the Zone ID of your main domain in the
CF_ZONE_IDenvironment variable. -
How it's used: If a container's labels define a
hostnamebut do not include azonenamelabel, DockFlare assumes the hostname belongs to this default zone. -
Requirement: This environment variable is required unless you plan to specify a
zonenamelabel for every single rule across all your containers.
You can override the default for any specific rule by adding the zonename label.
-
How it's used: Add the
{prefix}.zonenamelabel (or{prefix}.<index>.zonenamefor indexed rules) to a container. The value should be the domain name itself (e.g.,"other-domain.org"). - When this label is present, DockFlare ignores the default
CF_ZONE_IDfor that rule and looks up the Zone ID for the specified domain name. - Requirement: The domain name you provide must be an active zone within your Cloudflare account.
If you manage multiple domains in Cloudflare, the recommended strategy is:
- Set
CF_ZONE_IDto the Zone ID of your most frequently used domain. - For services on your primary domain, you only need the
hostnamelabel. - For services on any other domain, add both the
hostnameand the correspondingzonenamelabel.
This example shows how to manage hostnames across two different domains from a single container.
services:
my-service:
image: nginx:latest
container_name: my-app-service
networks:
- cloudflare-net
labels:
- "dockflare.enable=true"
# --- Rule 0: Uses the default zone from CF_ZONE_ID ---
- "dockflare.0.hostname=app.primary-domain.com"
- "dockflare.0.service=http://my-service:80"
# --- Rule 1: Uses a different, specified zone ---
- "dockflare.1.hostname=api.secondary-domain.net"
- "dockflare.1.service=http://my-service:80"
- "dockflare.1.zonename=secondary-domain.net" # Tells DockFlare which zone to use for this ruleIn this scenario, DockFlare will:
- Create a CNAME record for
app.primary-domain.comin the zone specified by yourCF_ZONE_ID. - Look up the Zone ID for
secondary-domain.netvia the Cloudflare API. - Create a CNAME record for
api.secondary-domain.netwithin thesecondary-domain.netzone.