Skip to content

Quick‐Start‐Docker‐Compose.md

Chris edited this page Apr 22, 2025 · 11 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 # Use the desired image tag
    container_name: dockflare
    restart: unless-stopped
    ports:
      - "5000:5000"  # Exposes the Web UI on port 5000
    env_file:
      - .env        # Loads configuration from the .env file
    volumes:
      # Required to monitor Docker container events
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # Persistent storage for state.json (managed rules, deletion timers)
      - dockflare_data:/app/data
    networks:
      # Network for communication with the managed cloudflared agent
      - cloudflare-net

volumes:
  # Define the persistent volume
  dockflare_data:

networks:
  # Define the network used by DockFlare and its managed agent
  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.

# Required Cloudflare credentials
CF_API_TOKEN=your_cloudflare_api_token_here
CF_ACCOUNT_ID=your_cloudflare_account_id_here
CF_ZONE_ID=your_cloudflare_zone_id_here

# Tunnel configuration (Required unless using External Mode)
TUNNEL_NAME=my-dockflare-tunnel # Choose a unique name for the tunnel DockFlare will manage

# Optional: Grace period before deleting rules for stopped containers (Default: 28800 seconds = 8 hours)
# GRACE_PERIOD_SECONDS=28800

# Optional: Prefix for Docker labels (Default: cloudflare.tunnel)
# LABEL_PREFIX=cloudflare.tunnel

# --- Do not uncomment these unless you understand External Mode ---
# Optional: External cloudflared mode (See Advanced Topics)
# USE_EXTERNAL_CLOUDFLARED=true
# EXTERNAL_TUNNEL_ID=your_existing_tunnel_id_if_using_external_mode

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