### Example DNS Record Definitions for CNAME Resolution Source: https://github.com/timk153/docker-external-dns/blob/main/README.md These examples illustrate how A and CNAME records are defined to create an aliasing chain, demonstrating how multiple CNAME records can point to each other, eventually resolving to an A record. The subsequent lookups show the final resolved IP address for each defined name. ```DNS Configuration type = A name = example.com server = 8.8.8.8 type = CNAME name = subdomain.example.com target = example.com type = CNAME name = lower.subdomain.example.com target = subdomain.example.com Lookup of example.com returns 8.8.8.8 Lookup of subdomain.example.com returns 8.8.8.8 Lookup of lower.subdomain.example.com returns 8.8.8.8 ``` -------------------------------- ### Configure DDNS A Record for Docker External DNS Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This example configures an A record for my-domain.com. The project will start the DDNS Service when this record is processed. The service will fetch your current public ipv4 address and use it for this record. The DDNS Service will check at regular intervals for a new ipv4 address. If one is detected then this record will be updated to the new value when the next DNS synchronisation interval is reached. ```yaml services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[{ "type": "A", "name": "my-domain.com", "address": "DDNS", "proxy": false }]' ``` -------------------------------- ### Customize Docker Compose External DNS Labels, Instance ID, Frequency, and Log Level Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This example shows how to customize the project label, instance ID, execution frequency, and log level settings for the Docker Compose External DNS service. It also demonstrates a CNAME record with proxy enabled. Note: This example uses the insecure API_TOKEN for simplicity. ```YAML services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - PROJECT_LABEL=dns.com.example - INSTANCE_ID=project-subdomain - EXECUTION_FREQUENCY_SECONDS=120 - LOG_LEVEL=info - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'dns.com.example:project-subdomain=[{ "type": "CNAME", "name": "project.example.com", "target": "example.com", "proxy": true }]' ``` -------------------------------- ### Configure Docker Compose External DNS with API Token Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This example demonstrates the most basic setup of the Docker Compose External DNS container with default values. It shows how to use the API_TOKEN environment variable and configure a single DNS entry. Note: API_TOKEN is insecure, API_TOKEN_FILE is recommended. ```YAML services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[{ "type": "A", "name": "my-domain.com", "address": "8.8.8.8", "proxy": false }]' ``` -------------------------------- ### Configure A Record for Docker External DNS Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This example configures an A record for my-domain.com pointing to 8.8.8.8 without using Cloudflare's proxy. ```yaml services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[{ "type": "A", "name": "my-domain.com", "address": "8.8.8.8", "proxy": false }]' ``` -------------------------------- ### Configure MX Record with A and CNAME for Mail Server Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This example demonstrates how to set up an MX record for a domain, pointing to a mail server defined by an A record and a CNAME alias. It shows the sequence of A, CNAME, and MX record definitions required for proper mail routing. ```DNS Record Configuration type = A name = example.com server = 8.8.8.8 type = CNAME name = mx1.example.com target = example.com type = MX name = example.com target = mx1.example.com ``` -------------------------------- ### Configure NS Record for Subdomain Delegation Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This example illustrates how to set up an NS record to delegate a subdomain to a different name server, typically for internal network resolution. It includes an A record for the delegated server and the NS record itself. ```DNS Record Configuration type = A name = lan.example.com server = 192.168.0.1 type = NS name = example.com server = lan.example.com ``` -------------------------------- ### Docker Compose Configuration for External DNS Records Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This YAML snippet illustrates a complete Docker Compose configuration. It sets up the `docker-external-dns` service, linking it to the Docker daemon for label reading, and shows an example `other-service` with labels defining multiple DNS records (A, CNAME, MX, NS) for different domains and subdomains. It highlights the use of `API_TOKEN` for authentication and the `docker.sock` volume for container introspection. ```yaml services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[ { "type": "A", "name": "my-domain.com", "address": "DDNS", "proxy": false }, { "type": "CNAME", "name": "mx1.my-domain.com", "target": "my-domain.com", "proxy": false }, { "type": "MX", "name": "my-domain.com", "server": "mx1.my-domain.com", "priority": 0 }, { "type": "CNAME", "name": "subdomain.my-domain.com", "target": "my-domain.com", "proxy": false }, { "type": "A", "name": "lan.my-domain.com", "address": "192.168.0.1", "proxy": false }, { "type": "CNAME", "name": "ns1.lan.my-domain.com", "target": "lan.my-domain.com", "proxy": false }, { "type": "NS", "name": "lan.my-domain.com", "server": "ns1.lan.my-domain.com" }]' ``` -------------------------------- ### Configure MX Record for Docker External DNS Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This example sets up an MX record for my-domain.com that points to mx1.my-domain.com with a priority of 0. This is used to specify the mail server for the domain. ```yaml services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[ { "type": "A", "name": "my-domain.com", "address": "8.8.8.8", "proxy": false }, { "type": "CNAME", "name": "mx1.my-domain.com", "target": "my-domain.com", "proxy": false }, { "type": "MX", "name": "my-domain.com", "server": "mx1.my-domain.com", "priority": 0 }]' ``` -------------------------------- ### Configure CNAME Record for Docker External DNS Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This setup includes a CNAME record that aliases sub.my-domain.com to my-domain.com, following the A record configuration for my-domain.com. ```yaml services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[ { "type": "A", "name": "my-domain.com", "address": "8.8.8.8", "proxy": false }, { "type": "CNAME", "name": "sub.my-domain.com", "target": "my-domain.com", "proxy": false }]' ``` -------------------------------- ### Preserve DNS Records for Stopped Containers in Docker Compose External DNS Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This example demonstrates a configuration which preserves the DNS records for containers which become stopped. Setting `PRESERVE_STOPPED` to `true` ensures that the DNS entry remains even if the associated service is stopped. ```YAML services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= - PRESERVE_STOPPED=true volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[{ "type": "A", "name": "my-domain.com", "address": "8.8.8.8", "proxy": false }]' ``` -------------------------------- ### Docker Image Tagging Conventions for docker-external-dns Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Describes the various image tagging conventions used for the 'timk153/docker-external-dns' project. It outlines tags for latest releases, major version releases, specific semantic versions, and development builds. ```APIDOC tag: latest example: timk153/docker-external-dns:latest description: the latest release of the most recent major version tag: -latest example: timk153/docker-external-dns:1-latest description: the latest release of that major version. In the example it's the latest release of version 1. tag: semantic version number example: timk153/docker-external-dns:1.4.2 description: a specific release. In the example it's release 1.4.2 tag: semantic version with additional identifier example: timk153/docker-external-dns:1.4.2-alpha description: a alpha, beta or development build. In the example it's an alpha release of version 1.4.2. ``` -------------------------------- ### Manage Multiple Domains with Separate DNS Services Using PROJECT_LABEL Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Shows how to configure two separate `docker-compose-external-dns` services, each managing a specific domain (`my-domain.com` and `my-other-domain.org`). Services are distinguished by unique `PROJECT_LABEL` values, enabling isolated API tokens and DNS record definitions. ```yaml services: docker-compose-external-dns-1: image: 'timk153/docker-external-dns:latest' environment: - PROJECT_LABEL=dns.com.my-domain - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' docker-compose-external-dns-2: image: 'timk153/docker-external-dns:latest' environment: - PROJECT_LABEL=dns.org.my-other-domain - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'dns.com.my-domain:1=[{ \"type\": \"A\", \"name\": \"my-domain.com\", \"address\": \"8.8.8.8\", \"proxy\": false }]' - 'dns.org.my-other-domain:1=[{ \"type\": \"A\", \"name\": \"my-other-domain.org\", \"address\": \"8.8.8.8\", \"proxy\": true }]' ``` -------------------------------- ### A Record DNS Entry Properties Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Defines the required properties for configuring an A record, which maps a domain name to an IP address (e.g., `example.com` resolving to `8.8.8.8`). Includes details on record type, domain name, target address (including DDNS option), and Cloudflare proxy settings. ```APIDOC A_Record_Properties: - property: "type" value: "A" description: "The type of the record. In this case it should be A." - property: "name" value: "" description: "This is the domain you want this A record to resolve for. For example: example-domain.com" - property: "address" value: " OR \"DDNS\"" description: "The address you want your domain name to resolve to. Or the string literal \"DDNS\" which instructs the project to compute your current public ipv4 address and use it for this record." - property: "proxy" value: "true or false" description: "True uses Cloudflare's proxy to hide your address. False causes Cloudflare to act as a normal DNS server. Documentation: https://developers.cloudflare.com/dns/manage-dns-records/reference/proxied-dns-records/#proxied-records" ``` -------------------------------- ### Manage Multiple Domains with Separate DNS Services Using INSTANCE_ID Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Illustrates setting up two distinct `docker-compose-external-dns` services, each responsible for a different domain (`my-domain.com` and `my-other-domain.org`). Services are differentiated by unique `INSTANCE_ID` values, allowing independent API tokens and DNS record management. ```yaml services: docker-compose-external-dns-1: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' docker-compose-external-dns-2: image: 'timk153/docker-external-dns:latest' environment: - INSTANCE_ID=2 - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[{ \"type\": \"A\", \"name\": \"my-domain.com\", \"address\": \"8.8.8.8\", \"proxy\": false }]' - 'docker-compose-external-dns:2=[{ \"type\": \"A\", \"name\": \"my-other-domain.org\", \"address\": \"8.8.8.8\", \"proxy\": true }]' ``` -------------------------------- ### PROJECT_LABEL and INSTANCE_ID Interpolation Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Explains how PROJECT_ID and INSTANCE_ID combine to form a unique label for Docker Containers, used as the DNS entry comment in Cloudflare. The interpolation format is `${PROJECT_ID}:${INSTANCE_ID}`. Best practices for naming conventions are also highlighted. ```APIDOC PROJECT_LABEL_INSTANCE_ID_FORMAT: "${PROJECT_ID}:${INSTANCE_ID}" Examples: - PROJECT_ID: "docker-compose-external-dns" INSTANCE_ID: "1" EXAMPLE: "docker-compose-external-dns:1" USE_CASE: "The default" - PROJECT_ID: "docker-compose-external-dns" INSTANCE_ID: "production" EXAMPLE: "docker-compose-external-dns:production" USE_CASE: "Could be used to target a production Cloudflare subscription" - PROJECT_ID: "docker-compose-external-dns" INSTANCE_ID: "production" EXAMPLE: "docker-compose-external-dns:non-production" USE_CASE: "Targets the non-production Cloudflare subscription" - PROJECT_ID: "dns.com.mydomain" INSTANCE_ID: "project" EXAMPLE: "dns.com.mydomain:project" USE_CASE: "DNS entries for a specific subdomain of yours." ``` -------------------------------- ### Manage Multiple Domains with a Single Docker Compose External DNS Service Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Demonstrates configuring a single `docker-compose-external-dns` instance to manage A records for `my-domain.com` and `my-other-domain.org`. DNS entries are defined within a single service's labels, showcasing how to apply different settings like Cloudflare proxying for individual records. ```yaml services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[ { \"type\": \"A\", \"name\": \"my-domain.com\", \"address\": \"8.8.8.8\", \"proxy\": false }, { \"type\": \"A\", \"name\": \"my-other-domain.org\", \"address\": \"8.8.8.8\", \"proxy\": true }]' ``` -------------------------------- ### CNAME Record Properties API Documentation Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This section details the required and optional properties for configuring a CNAME DNS record. It specifies the type, name, target, and proxy settings, along with their accepted values and descriptions, including important notes on Cloudflare proxying limitations. ```APIDOC CNAME Record Properties: - property: "type" value: "CNAME" description: "The type of the record. In this case it should be CNAME." - property: "name" value: "" description: "This is the alias you want this CNAME record to resolve for. For example: subdomain.example-domain.com." - property: "target" value: "" description: "The full name of the relevant A or CNAME record this should resolve to. For example, use 'example-domain.com' to point at the A record above." - property: "proxy" value: "true or false" description: "True uses Cloudflare's proxy to hide your address. False causes Cloudflare to act as a normal DNS server. Documentation: [Proxied DNS Records](https://developers.cloudflare.com/dns/manage-dns-records/reference/proxied-dns-records/#proxied-records). Please note, only one level of subdomain can be proxied. If it's two subdomains deep (e.g. test.subdomain.example.com) it cannot be proxied unless you have a premium subscription." ``` -------------------------------- ### NS Record Property Definition Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Defines the required properties for configuring an NS (Name Server) DNS record. It specifies the record type, the domain to forward queries for, and the target name server. ```APIDOC property: type value: NS description: The type of the record. In this case it should be NS property: name value: description: This is the domain you want to forward queries for. For example: example-domain.com property: server value: description: The full name of the relevant A or CNAME entry this should resolve to. For example 'lan.example-domain.com' ``` -------------------------------- ### Configure NS Record for Docker External DNS Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This configuration includes an NS record specifying ns1.lan.my-domain.com as the nameserver for lan.my-domain.com, alongside an A record for lan.my-domain.com. ```yaml services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN= volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[ { "type": "A", "name": "lan.my-domain.com", "address": "192.168.0.1", "proxy": false }, { "type": "CNAME", "name": "ns1.lan.my-domain.com", "target": "lan.my-domain.com", "proxy": false }, { "type": "NS", "name": "lan.my-domain.com", "server": "ns1.lan.my-domain.com" }]' ``` -------------------------------- ### LOG_LEVEL Configuration Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Defines the logging verbosity for the application. Levels range from 'fatal' (most specific) to 'verbose' (least specific), with each level including those above it. Based on NestJS logging levels. ```APIDOC LOG_LEVEL: type: string default: "error" description: "The current logging level. Each level includes the levels above it from most specific to least specific.\nLevels (most specific to least): fatal, error, warn, log, debug, verbose.\nBased on NestJS project logging levels." ``` -------------------------------- ### MX Record Property Definition Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Defines the required properties for configuring an MX (Mail Exchange) DNS record. It specifies the record type, domain name, mail server target, and priority, along with their valid values and descriptions. ```APIDOC property: type value: MX description: The type of the record. In this case it should be MX property: name value: description: This is the domain you want this mail server to handle mail for. For example: example-domain.com property: server value: description: The full name of the relevant A or CNAME entry this should resolve to. For example 'mx1.example-domain.com' (assuming you've made a CNAME or A record resolving mx1). property: priority value: 0 to 65535 description: The priority of this mail server, allowing you to have more than one mail server for a domain. Must be an integer between the stated values. ``` -------------------------------- ### Environment Variables Configuration Source: https://github.com/timk153/docker-external-dns/blob/main/README.md Defines the complete set of environment variables available for configuring the Docker External DNS service. Each variable controls a specific aspect of the container's behavior, from DNS record management to API authentication. ```APIDOC EnvironmentVariables: PROJECT_LABEL: type: string default: "docker-compose-external-dns" description: "Forms part of the label the project looks for on Docker containers to interpret as DNS entries. Also written as a comment to Cloudflare DNS entries managed by this instance of the project." INSTANCE_ID: type: integer default: 1 description: "Forms part of the label the project looks for on Docker containers to interpret as DNS entries. Also written as a comment to Cloudflare DNS entries managed by this instance of the project." EXECUTION_FREQUENCY_SECONDS: type: integer default: 60 description: "How frequently the CRON job should execute to detect changes. Default is every 60 seconds. Undefined or empty uses the default. Minimum is every 1 second. There is no maximum. This must be an integer." DDNS_EXECUTION_FREQUENCY_MINUTES: type: integer default: 60 description: "Determines how frequently the DDNS Service checks for a new public IP address. This setting only applies if you're using DDNS otherwise the service will not be started." PRESERVE_STOPPED: type: boolean default: false description: "Determines if DNS entries for stopped containers are synchronised to the DNS server. `false` doesn't synchronise, meaning containers which are stopped will have their DNS entries removed. `true` means stopped containers won't have their entries removed. Removed containers will always have their DNS entries removed." API_TOKEN: type: string default: "" description: "You must supply either API_TOKEN or API_TOKEN_FILE but not both. Your API token from Cloudflare. Must be granted Zone.Zone read and Zone.DNS edit. IMPORTANT Use of this property is insecure as your API_TOKEN will be in plain text. It is recommended you use API_TOKEN_FILE. Use at your own risk." API_TOKEN_FILE: type: string default: "" description: "You must supply either API_TOKEN or API_TOKEN_FILE but not both. Secure way to share your Cloudflare API Token with the project. Recommended approach for Docker Swarm. Compatible with Docker Compose (but less secure). Read Docker Compose docs for more information." ``` -------------------------------- ### Securely Configure Docker Compose External DNS with API Token File Source: https://github.com/timk153/docker-external-dns/blob/main/README.md This configuration demonstrates the preferred method of passing the API token securely using Docker secrets. This is more secure than using API_TOKEN. The API_TOKEN_FILE environment variable points to the secret file, which contains the API token. This approach is recommended for better security, especially in production environments. ```YAML services: docker-compose-external-dns: image: 'timk153/docker-external-dns:latest' environment: - API_TOKEN_FILE=/run/secrets/CLOUDFLARE_API_TOKEN secrets: - CLOUDFLARE_API_TOKEN volumes: # Used to read labels from containers - readonly - '/var/run/docker.sock:/var/run/docker.sock:ro' other-service: image: 'busybox:latest' command: 'sleep 3600' labels: - 'docker-compose-external-dns:1=[{ "type": "A", "name": "my-domain.com", "address": "8.8.8.8", "proxy": false }]' secrets: CLOUDFLARE_API_TOKEN: environment: 'CLOUDFLARE_API_TOKEN' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.