HeadlinesBriefing favicon HeadlinesBriefing.com

Run Cloudflare Tunnel with Docker in 5 Minutes

DEV Community •
×

Developers seeking secure service exposure without public IPs or complex proxies can use Cloudflare Tunnel. A small Bash script runs the `cloudflared` container via Docker, keeping servers private while Cloudflare manages public traffic. This method uses a Tunnel Token for authentication and operates entirely within a Docker network.

This approach simplifies secure access for self-hosted applications and internal tools. By routing traffic through Cloudflare's network, it eliminates the need for dynamic DNS or firewall rules. The script is designed for reliability, with a restart policy and a specific, stable `cloudflared` image version to ensure consistent operation.

To implement, users generate a token from their Cloudflare account and insert it into the script. The container runs detached, connecting the tunnel to the Cloudflare network. This setup is ideal for side projects or development environments where exposing a public IP is undesirable or impractical.