gitmyhub

cf-docker-tunnel-sync

Python ★ 2 updated 2d ago

Dynamically expose Docker containers via Cloudflare Zero Trust Tunnels using simple container labels. Automatically creates tunnels, configures ingress rules, syncs CNAME records, cleans up obsolete DNS entries, and provides a simple web dashboard. Runs with zero local dependencies.

Automatically exposes Docker containers to the internet using Cloudflare tunnels by adding simple text labels, skipping manual router and DNS configuration.

PythonDockerCloudflaresetup: moderatecomplexity 3/5

This project helps you put Docker containers on the internet using Cloudflare, a service that sits between your containers and the wider web. Normally, exposing a container running on your own machine, like a home server or a Raspberry Pi, means dealing with router settings, DNS records, and manual tunnel setup. This tool handles that for you. You add simple text labels to your containers specifying a domain name and a port, and the tool takes care of creating the connection and updating DNS automatically.

To get started, you need a domain name managed by Cloudflare. You create a single API token in your Cloudflare account with specific permissions for tunnels and DNS. Then you run the project alongside Cloudflare's own connector software using a configuration file. The tool scans your running containers every 30 seconds by default, looking for the labels that tell it what to expose. When it finds them, it configures the tunnel and creates the DNS records needed to make the container reachable at the domain you chose.

The tool also handles cleanup. When you stop a container, it removes the DNS entries that are no longer needed. A simple web dashboard on port 8090 shows you the current routing status and live logs. The dashboard is password protected, though the README notes the default credentials are "admin" and "admin", so you should change those. The README also recommends against exposing the dashboard to the public internet.

You can expose services that are not running in Docker by using a small bridge container. This is a lightweight container that holds the labels and points the tunnel to a service running directly on your host machine, like a program running on your Mac or Pi. The project works on both standard Linux computers and Raspberry Pi devices.

Where it fits