Skip to content

Quick‐Start‐Docker‐Compose.md

Chris edited this page May 17, 2025 · 10 revisions

Quick Start (Using Docker Compose)

This guide provides the quickest way to get DockFlare running using Docker Compose.

1. Create docker-compose.yml

Create a file named docker-compose.yml with the following content. This defines the DockFlare service, its network, and a volume for persistent state.

version: '3.8'
services:
  dockflare:
    image: alplat/dockflare:stable
    container_name: dockflare
    restart: unless-stopped
    ports:
      - "5000:5000"  # Web UI port
    env_file:
      - .env  # Load environment variables from .env file
    environment:
      - STATE_FILE_PATH=/app/data/state.json
      - TZ=Europe/Zurich  # Set your timezone here  
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro  # Required to monitor Docker events
      - dockflare_data:/app/data  # Persistent storage for state
    networks:
      - cloudflare-net  # Network for communication with cloudflared agent
    labels: # Optional keep in mind to set access policy
      - cloudflare.tunnel.enable=true
      - cloudflare.tunnel.hostname=dockflare.yourdomain.tld # update your domain 
      - cloudflare.tunnel.service=http://dockflare:5000 
volumes:
  dockflare_data:
networks:
  cloudflare-net:
   name: cloudflare-net

2. Create .env File

Create a file named .env in the same directory as your docker-compose.yml. This file stores your sensitive credentials and configuration settings. Replace the placeholder values with your actual Cloudflare details.

# Cloudflare API Token (REQUIRED)
CF_API_TOKEN=your_cloudflare_api_token
# Cloudflare Account ID (REQUIRED) - dash.cloudflare.com/ACCOUNT_ID
CF_ACCOUNT_ID=your_cloudflare_account_id
# Cloudflare Zone ID (REQUIRED)
CF_ZONE_ID=your_cloudflare_zone_id
# Tunnel Name (REQUIRED only when NOT using external cloudflared)
TUNNEL_NAME=DockFlare
# Use External Cloudflared (OPTIONAL)
USE_EXTERNAL_CLOUDFLARED=false
# External Tunnel ID (REQUIRED if USE_EXTERNAL_CLOUDFLARED=true) 
EXTERNAL_TUNNEL_ID=6ff42ae2-765d-4adf-befc-ca51f8e4e688 # Example Tunnel ID format
# Docker Network Name (internal cloudflared mode)
CLOUDFLARED_NETWORK_NAME=cloudflare-net
# Label Prefix for Docker Containers
LABEL_PREFIX=cloudflare.tunnel
# Grace Period for Rule Deletion (seconds, default: 1h)
GRACE_PERIOD_SECONDS=6000
# Cleanup Interval (seconds)
CLEANUP_INTERVAL_SECONDS=300
# Agent Status Update Interval (seconds)
AGENT_STATUS_UPDATE_INTERVAL_SECONDS=10
# Scan All Docker Networks (default: false)
SCAN_ALL_NETWORKS=false
# Max Concurrent DNS Operations (default: 3)
MAX_CONCURRENT_DNS_OPS=3
# Reconciliation Batch Size (default: 3)
RECONCILIATION_BATCH_SIZE=3
# Trusted Proxies (IPs/CIDR ranges)
# TRUSTED_PROXIES=172.16.0.0/12,192.168.0.0/16
# Default TLS Verification Setting (skip verification) (default: false)
DEFAULT_NO_TLS_VERIFY=false
STATE_FILE_PATH=/app/data/state.json

Important: Ensure the .env file is protected and not committed to public repositories.

3. Run DockFlare

Navigate to the directory containing your docker-compose.yml and .env files in your terminal and run:

docker compose up -d

This command will:

  • Pull the alplat/dockflare:stable image (if not already present).
  • Create the cloudflare-net network.
  • Create the dockflare_data volume.
  • Start the dockflare container in detached mode (-d).

DockFlare will now start, connect to Cloudflare, create/verify the specified tunnel (TUNNEL_NAME), start the associated cloudflared agent container, and begin listening for Docker events.

Next Steps

Clone this wiki locally