-
-
Couldn't load subscription status.
- Fork 68
BasicUsageSingleDomain.md
This is the standard method for exposing a single service from a Docker container through DockFlare using one public hostname.
You add a set of labels directly to the container definition, using the keys described in Container Labels.
Here's an example of exposing a simple nginx service as my-web-app.example.com. Assume DockFlare and this service are on the same cloudflare-net Docker network.
version: '3.8'
services:
# Your DockFlare service definition (from Quick Start)
dockflare:
image: alplat/dockflare:stable
container_name: dockflare
restart: unless-stopped
ports:
- "5000:5000"
env_file:
- .env
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- dockflare_data:/app/data
networks:
- cloudflare-net # DockFlare needs access to the network
# The service you want to expose
my-web-app:
image: nginx:latest
container_name: my-nginx-app
restart: unless-stopped
networks:
- cloudflare-net # Must be on a network DockFlare can reach
labels:
# --- DockFlare Labels ---
# 1. Enable DockFlare management for this container
cloudflare.tunnel.enable: "true"
# 2. Define the public hostname (must be in a zone you control via CF_ZONE_ID or zonename label)
cloudflare.tunnel.hostname: "my-web-app.example.com"
# 3. Define the internal service target (protocol://container_name_or_ip:port)
# Using container name requires Docker's internal DNS resolution on the shared network.
cloudflare.tunnel.service: "http://my-web-app:80"
# 4. Optional: Specify the zone if different from CF_ZONE_ID
# cloudflare.tunnel.zonename: "example.com"
# 5. Optional: Disable TLS verification if the internal service uses HTTPS with self-signed certs
# cloudflare.tunnel.no_tls_verify: "true"
volumes:
dockflare_data:
networks:
cloudflare-net:-
cloudflare.tunnel.enable: "true": Tells DockFlare to manage this container. -
cloudflare.tunnel.hostname: "my-web-app.example.com": Specifies that traffic tomy-web-app.example.comshould be routed through the tunnel. DockFlare will create a CNAME DNS record for this hostname pointing to the tunnel. -
cloudflare.tunnel.service: "http://my-web-app:80": Instructs the Cloudflare Tunnel to forward requests formy-web-app.example.comto port 80 of the container namedmy-web-appusing HTTP. The container namemy-web-appis resolvable on thecloudflare-netnetwork via Docker's built-in DNS. -
cloudflare.tunnel.zonename(Optional): Ifexample.comis not the zone specified by theCF_ZONE_IDenvironment variable in DockFlare's configuration, you would uncomment and set this label. -
cloudflare.tunnel.no_tls_verify(Optional): Only needed if your internal service useshttps://and has a certificate that Cloudflare shouldn't (or cannot) verify (like a self-signed certificate). For standard HTTP services, it's not required.
When you run docker compose up -d with this configuration, DockFlare will detect the my-web-app container and automatically configure Cloudflare Tunnel and DNS to make http://my-web-app.example.com (or https:// if Cloudflare provides it) accessible publicly.