I have set up a Tunnel to my server and configured for all requests to be routed to my traefik proxy.
The cloudflared service is also running inside a container on the same host. But there seems to be a difference if I run the container with docker run
vs running it in docker-compose, because with compose it cannot connect to the origin service (traefik).
My run command:
docker run --rm -v /opt/docker/data/cloudflared/.cloudflared:/home/nonroot/.cloudflared/ cloudflare/cloudflared:2022.2.0 tunnel run
My compose file:
version: "3.9"
services:
cloudflare:
image: cloudflare/cloudflared:2022.2.0
container_name: cloudflared-tunnel
restart: always
volumes:
- /opt/docker/data/cloudflared/.cloudflared:/home/nonroot/.cloudflared/
command: tunnel run
As I see it (and apparently I’m wrong, bc it doesn’t work) they both should be exactly the same.
However, when run through compose, this is in the logs:
{"level":"error","error":"Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared: dial tcp 127.0.0.1:443: connect: connection refused","cfRay":"2083rns3p87149-ABC","ingressRule":"0","originService":"https://my-hostname","time":"2022-02-20T11:20:16Z"}
When adding network_mode: host
to compose it works again, but I’m wondering why this isn’t needed when using docker run.