DNS Labels
Create Cloudflare DNS records from container labels.
One label is enough. This creates a proxied A record for app.example.com that points to this host's public IP:
services:
web:
image: nginx:alpine
labels:
labelgate.dns.web.hostname: "app.example.com"When the container is removed, the record is deleted 30 minutes later (sync.remove_delay).
Labels
Every label has the form labelgate.dns.<name>.<property>. The <name> is any name you choose; see The name part.
| Property | Required | Default | Example | Meaning |
|---|---|---|---|---|
hostname | yes | - | app.example.com | Record name. |
type | no | A | CNAME | A, AAAA, CNAME, TXT, MX, SRV or CAA. |
target | A/AAAA: no, others: yes | auto | 203.0.113.10 | Record value. See Targets. |
proxied | no | true | false | Orange cloud. Only A, AAAA and CNAME can be proxied. |
ttl | no | auto | 300 | TTL in seconds, up to 86400. 0 or 1 means auto. Proxied records always use auto. |
cleanup | no | true | false | Delete the record when the container is gone. false keeps it. |
credential | no | auto | company | Which API token to use. default is cloudflare.api_token. |
access | no | - | team | Put an Access policy in front of the hostname. |
comment | no | - | blog | Extra text for the record's comment in Cloudflare. |
priority | no | 0 | 10 | MX and SRV only. 0-65535. |
weight | no | 0 | 5 | SRV only. 0-65535. |
port | no | 0 | 5222 | SRV only. 0-65535. |
flags | no | 0 | 128 | CAA only. 0-255. |
tag | no | issue | issuewild | CAA only. issue, issuewild or iodef. |
Targets
For A and AAAA records:
target | Result |
|---|---|
auto (default) | The host's public IP: IPv4 for A, IPv6 for AAAA. For a container on an agent, the agent host's public IP. |
container | The container's own IP address. |
| An IP address | That address, e.g. 203.0.113.10 for A or 2001:db8::10 for AAAA. |
For other types, target is required:
CNAME,MX,SRV: a hostname, e.g.mail.example.com.TXT,CAA: the value, used as written.
If auto or container finds no address (for example, no public IPv6), the record shows an error and Labelgate retries on every sync.
Recipes
Fixed IP, DNS only (grey cloud)
labels:
labelgate.dns.web.hostname: "app.example.com"
labelgate.dns.web.target: "203.0.113.10"
labelgate.dns.web.proxied: "false"Several records from one container
labels:
labelgate.dns.root.hostname: "example.com"
labelgate.dns.www.hostname: "www.example.com"
labelgate.dns.www.type: "CNAME"
labelgate.dns.www.target: "example.com"Mail: MX and SPF
labels:
labelgate.dns.mx.hostname: "example.com"
labelgate.dns.mx.type: "MX"
labelgate.dns.mx.target: "mail.example.com"
labelgate.dns.mx.priority: "10"
labelgate.dns.spf.hostname: "example.com"
labelgate.dns.spf.type: "TXT"
labelgate.dns.spf.target: "v=spf1 mx ~all"priority defaults to 0. Set it when it matters.
SRV
labels:
labelgate.dns.xmpp.hostname: "_xmpp-client._tcp.example.com"
labelgate.dns.xmpp.type: "SRV"
labelgate.dns.xmpp.target: "xmpp.example.com"
labelgate.dns.xmpp.priority: "10"
labelgate.dns.xmpp.weight: "5"
labelgate.dns.xmpp.port: "5222"CAA
labels:
labelgate.dns.caa.hostname: "example.com"
labelgate.dns.caa.type: "CAA"
labelgate.dns.caa.target: "letsencrypt.org"Keep the record after the container is gone
labels:
labelgate.dns.web.hostname: "app.example.com"
labelgate.dns.web.cleanup: "false"Per-container defaults
labelgate.dns.default.<property> sets a default for every DNS name in the same container. Allowed properties: type, target, proxied, ttl, credential, cleanup.
labels:
labelgate.dns.default.proxied: "false"
labelgate.dns.a.hostname: "a.example.com"
labelgate.dns.b.hostname: "b.example.com"Good to know
- Labelgate only changes records it created. It marks them with
labelgate:<id>at the start of the record comment; yourcommenttext goes after it. - An existing record with the same name and type is never taken over. You get
conflict: existing record not owned by labelgate. See Ownership & Conflicts. - Do not add a DNS label for a hostname that a tunnel label already uses. The tunnel creates its own record.