Container workflow for Cloudflare Locally-Managed Tunnels

My objective is to establish locally-managed tunnels that terminate on docker containers. My preference would be to do this using only environment variables but I can inject configuration using docker volumes. I feel as though the documentation is not clear on the actions required to stand up tunnels in containers (at least not to me). What is the recommended approach for a cloudflared container to authenticate, establish the tunnel and then add a custom yaml?
1 Reply
hhf
hhfOP4mo ago
version: '3.4'

services:

tunnel:
image: cloudflared/cloudflared
container_name: jtunnel
restart: unless-stopped
command: tunnel run
volumes:
- ./cloudlfared/cert.pem:/etc/cloudflared/cert.pem
- ./cloudflared/config.yaml:/etc/cloudflared/config.yaml
networks:
tunnelnet0:
ipv4_address: 192.168.55.5

publicweb:
image: lscr.io/linuxserver/nginx:latest
container_name: tunnelweb33
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
networks:
tunnelnet0:
ipv4_address: 192.168.55.10

networks:
tunnelnet0:
ipam:
config:
- subnet: 192.168.55.0/28
version: '3.4'

services:

tunnel:
image: cloudflared/cloudflared
container_name: jtunnel
restart: unless-stopped
command: tunnel run
volumes:
- ./cloudlfared/cert.pem:/etc/cloudflared/cert.pem
- ./cloudflared/config.yaml:/etc/cloudflared/config.yaml
networks:
tunnelnet0:
ipv4_address: 192.168.55.5

publicweb:
image: lscr.io/linuxserver/nginx:latest
container_name: tunnelweb33
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
networks:
tunnelnet0:
ipv4_address: 192.168.55.10

networks:
tunnelnet0:
ipam:
config:
- subnet: 192.168.55.0/28
this dosent work so i tried to compile dockerfile
FROM cloudflare/cloudflared:latest

COPY cloudflare_configs/credentials.json /etc/cloudflared/credentials.json

COPY cloudflare_configs/cert.pem /etc/cloudflared/cert.pem

COPY cloudflare_configs/config.yaml /etc/cloudflared/config.yaml

CMD ["tunnel", "--no-autoupdate", "run"]
# CMD ["tunnel", "--loglevel", "debug", "--no-autoupdate", "run"]
FROM cloudflare/cloudflared:latest

COPY cloudflare_configs/credentials.json /etc/cloudflared/credentials.json

COPY cloudflare_configs/cert.pem /etc/cloudflared/cert.pem

COPY cloudflare_configs/config.yaml /etc/cloudflared/config.yaml

CMD ["tunnel", "--no-autoupdate", "run"]
# CMD ["tunnel", "--loglevel", "debug", "--no-autoupdate", "run"]
version: "3.8"
services:

cloudflared:
container_name: cloudflared
# env_file: cloudflare_configs/cloudflare.env if the tunnel was setup via the UI
build:
context: .
dockerfile: Cloudflared.dockerfile
networks:
- clientdatabase_network
- lbdatabase_network
- jenkins_network
- finance_network

networks:
clientdatabase_network:
name: clientdatabase_network
driver: bridge
lbdatabase_network:
name: lbdatabase_network
driver: bridge
jenkins_network:
name: jenkins_network
driver: bridge
finance_network:
name: finance_network
driver: bridge
version: "3.8"
services:

cloudflared:
container_name: cloudflared
# env_file: cloudflare_configs/cloudflare.env if the tunnel was setup via the UI
build:
context: .
dockerfile: Cloudflared.dockerfile
networks:
- clientdatabase_network
- lbdatabase_network
- jenkins_network
- finance_network

networks:
clientdatabase_network:
name: clientdatabase_network
driver: bridge
lbdatabase_network:
name: lbdatabase_network
driver: bridge
jenkins_network:
name: jenkins_network
driver: bridge
finance_network:
name: finance_network
driver: bridge
this also dosent work Any help appreciated ??
Want results from more Discord servers?
Add your server