Container stack for exposing an n8n instance through a temporary Cloudflare Tunnel. The setup splits the tunnel sidecars from n8n itself so you can run them together or independently.
- Docker Engine 24+
- Docker Compose V2 (
docker compose) or legacydocker-compose - Host ports:
5678for n8n, random high ports opened by Cloudflare tunnel ./runtime,./local-files,./shareddirectories writable by Docker- If Docker requires root on your host, prefix commands with
sudo(or add your user to thedockergroup).
docker-compose.tunnel.yml: BusyBox cleaner, Cloudflare tunnel, URL capture sidecardocker-compose.n8n.yml: n8n service, volumes, health check, logging configscripts/: custom entrypoints (n8n-entrypoint.sh,wait-tunnel.sh)runtime/: shared runtime state (cloudflared.log,tunnel_url,n8n.log)compose-up.sh: helper that restarts the stack with both compose files
./compose-up.sh # stops existing containers, then runs `docker compose up -d`
# or manually
docker compose \
-f docker-compose.tunnel.yml \
-f docker-compose.n8n.yml \
up -d --remove-orphansThe tunnel URL appears in runtime/tunnel_url; n8n logs are written to runtime/n8n.log.
docker compose \
-f docker-compose.tunnel.yml \
-f docker-compose.n8n.yml \
down --remove-orphansIf you previously ran the stack from another directory name, use docker compose --project-name <old-name> down to clean up the old containers.
- Tunnel status:
tail -f runtime/cloudflared.log - n8n health:
docker compose exec n8n node -e "fetch('http://localhost:5678/healthz').then(r=>console.log(r.status)).catch(console.error)" - Check tunnel reachability from the tunnel container:
docker compose exec tunnel /usr/local/bin/cloudflared --version
- Edit
docker-compose.n8n.ymlenvironment variables to adjust n8n behaviour. - Override
scripts/n8n-entrypoint.shif you need additional bootstrapping logic. - To split stacks or extend services, layer extra compose files with
docker compose -f ... -f ... up.
- The Cloudflare image is distroless—no shell utilities are available inside the tunnel container.
- Quick tunnels (
trycloudflare.com) have no uptime guarantees; use named tunnels with credentials for production setups. - Runtime directory is cleared by the
runtime-cleanerservice on each start.