gcp-dynamic-dns

gcp-dynamic-dns

Docker app from johnwesturner's Repository

Overview

Automatically sync your public IP address to Google Cloud DNS records. Perfect for home servers, self-hosted services, and dynamic IP environments. Supports multiple IP detection methods including external services, local interface, and UPnP.

Google Cloud Dynamic DNS Client

CI Release Docker Pulls Docker Image Version Go Version License

Note: This is an actively maintained fork of luontola/gcp-dynamic-dns with updated dependencies and modernized GCP SDK.

Automatically sync your public IP address to Google Cloud DNS records. Perfect for home servers, self-hosted services, and dynamic IP environments.

Features

  • Multiple IP Detection Methods
    • External web service (default)
    • Local network interface
    • Router via UPnP
  • Flexible Authentication
    • Environment variable (JSON string)
    • Mounted credentials file
  • Lightweight
    • Minimal Docker image (~10MB)
    • Single static binary
  • Multi-Architecture
    • linux/amd64
    • linux/arm64

Table of Contents


Quick Start

docker run -d \
  --name gcp-dynamic-dns \
  --network host \
  --restart always \
  -e DNS_NAMES="example.com." \
  -e GOOGLE_PROJECT="your-project-id" \
  -e GOOGLE_CREDENTIALS_JSON='{"type":"service_account",...}' \
  b1tsized/gcp-dynamic-dns sync

Installation

Docker Compose

services:
  dyndns:
    image: b1tsized/gcp-dynamic-dns
    container_name: gcp-dynamic-dns
    command: sync
    network_mode: host
    restart: always
    environment:
      DNS_NAMES: example.com. www.example.com.
      GOOGLE_PROJECT: your-project-123456
      # Option 1: Credentials as JSON string (recommended)
      GOOGLE_CREDENTIALS_JSON: '{"type":"service_account","project_id":"..."}'
      # Option 2: Credentials as file
      # GOOGLE_APPLICATION_CREDENTIALS: /gcp-keys.json
    # volumes:
    #   - ./gcp-keys.json:/gcp-keys.json:ro

UnRaid

Click to expand UnRaid installation guide

Adding the Container

  1. In UnRaid's Docker tab, click Add Container
  2. Configure:
Field Value
Name gcp-dynamic-dns
Repository b1tsized/gcp-dynamic-dns
Network Type host
Post Arguments sync
Restart Policy always

Environment Variables

Variable Value
DNS_NAMES yourdomain.com. (must end with .)
GOOGLE_PROJECT Your GCP project ID
GOOGLE_CREDENTIALS_JSON Your service account JSON

Verifying It Works

Check the container logs. You should see:

Using credentials from GOOGLE_CREDENTIALS_JSON environment variable
Current IP: 203.0.113.42
Updated DNS: example.com. A -> 203.0.113.42

Configuration

Authentication

Two methods are supported for GCP credentials:

Option 1: Environment Variable (Recommended)

Pass the entire service account JSON as an environment variable:

environment:
  GOOGLE_CREDENTIALS_JSON: '{"type":"service_account","project_id":"...","private_key":"..."}'

Pros: No file mounts, works great with container orchestrators

Option 2: File Mount

Mount the JSON key file into the container:

environment:
  GOOGLE_APPLICATION_CREDENTIALS: /gcp-keys.json
volumes:
  - /path/to/credentials.json:/gcp-keys.json:ro

Environment Variables

Variable Required Default Description
DNS_NAMES Yes - Space-separated DNS names (must end with .)
GOOGLE_PROJECT Yes - GCP project ID
GOOGLE_CREDENTIALS_JSON * - Service account JSON content
GOOGLE_APPLICATION_CREDENTIALS * - Path to credentials file
MODE No service IP detection mode (see below)
SERVICE_URLS No [see below] Custom IP detection URLs
INTERFACE_NAME No auto Network interface name

* One of GOOGLE_CREDENTIALS_JSON or GOOGLE_APPLICATION_CREDENTIALS is required

IP Detection Modes

Mode Description
service Query external web services (default)
interface Read from local network interface
upnp Query router via UPnP protocol

Note: Modes interface and upnp require network_mode: host

Default Service URLs

https://ipv4.icanhazip.com/
https://checkip.amazonaws.com/
https://ifconfig.me/ip
https://ipinfo.io/ip

Services are queried in round-robin fashion every 5 minutes.


GCP Setup

  1. Go to GCP Console → IAM & Admin → Service Accounts

  2. Create a service account

    • Name: dns-updater
    • Role: DNS Administrator (roles/dns.admin)
  3. Create a JSON key

    • Click on the service account
    • Keys → Add Key → Create new key → JSON
    • Download and save securely
  4. Ensure DNS records exist

    • Records must already exist in Cloud DNS
    • Must be type A records
    • Names must end with . (e.g., example.com.)

Development

Prerequisites

Local Development

# Run tests
cd src/app
go test -v ./...

# Build binary
go build -o ../../app

# Run locally
DNS_NAMES="example.com." GOOGLE_PROJECT="test" ./app list-ip

Docker Build

# Build image
docker build -t b1tsized/gcp-dynamic-dns .

# Test container
docker run --rm b1tsized/gcp-dynamic-dns help

CI/CD

Workflow Trigger Action
CI Push/PR to main Run tests, build
Release GitHub Release Build & push to Docker Hub

Creating a Release

  1. Go to ReleasesCreate a new release
  2. Create tag: v2.0.0 (semantic versioning)
  3. Click Publish release

The workflow automatically builds multi-arch images and pushes:

  • b1tsized/gcp-dynamic-dns:latest
  • b1tsized/gcp-dynamic-dns:2.0.0
  • b1tsized/gcp-dynamic-dns:2.0
  • b1tsized/gcp-dynamic-dns:2

Repository Secrets

Required for releases:

Secret Description
DOCKERHUB_USERNAME Docker Hub username
DOCKERHUB_TOKEN Docker Hub access token

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Changes from Upstream

This fork includes:

  • Updated to Go 1.25
  • Updated all dependencies to latest versions
  • Modernized GCP SDK (dns.NewService() instead of deprecated dns.New())
  • Narrower OAuth scope (NdevClouddnsReadwriteScope)
  • New: GOOGLE_CREDENTIALS_JSON environment variable support
  • New: Multi-architecture Docker images (amd64/arm64)
  • New: GitHub Actions CI/CD
  • Code quality improvements

License

Apache License 2.0

Original work Copyright © 2023 Esko Luontola


Report Bug · Request Feature

Install gcp-dynamic-dns on Unraid in a few clicks.

Find gcp-dynamic-dns in Community Apps on your Unraid server, review the template, and click Install. Unraid handles the Docker app or plugin setup from the published template.

Open the Apps tab on your Unraid server Search Community Apps for gcp-dynamic-dns Review the template variables and paths Click Install

Download Statistics

238
Total Downloads

Related apps

Explore more like this

Explore all

Details

Repository
b1tsized/gcp-dynamic-dns
Last Updated2026-04-02
First Seen2026-04-06

Runtime arguments

Network
host
Shell
sh
Privileged
false

Template configuration

DNS_NAMESVariable

Space-separated DNS names to update (must end with period, e.g., example.com.)

GOOGLE_PROJECTVariable

Your Google Cloud Platform project ID

GOOGLE_CREDENTIALS_JSONVariable

Service account JSON content (paste entire JSON key file content)

MODEVariable

IP detection mode: service (external web services), interface (local network interface), or upnp (query router)

Default
service
INTERFACE_NAMEVariable

Network interface name (only used when MODE=interface)