lucaslorentz / caddy-docker-proxy

Caddy as a reverse proxy for Docker
MIT License
3.05k stars 174 forks source link

"--mode server" argument erroneously starts controller mode #665

Open DHowett opened 1 month ago

DHowett commented 1 month ago

I'm trying to set up caddy-docker-proxy in somewhat of an unorthodox way (similar to #616), but I've encountered a disparity between the docs and observed behavior.

The README states,

Server instances doesn't need access to Docker host socket and you can run it in manager or worker nodes.

However, when I run caddy docker-proxy --docker-sockets tcp://this-is-not-a-real-url-and-should-not-exist:1000 --mode server, it fails because it tries to connect to the docker daemon.

2024/09/28 22:30:40.299 INFO    docker-proxy    Running caddy proxy controller
2024/09/28 22:30:40.304 ERROR   docker-proxy    Docker ping failed on specify socket    {"error": "error during connect: Head \"http://this-is-not-a-real-url-and-should-not-exist:1000/_ping\": dial tcp: lookup this-is-not-a-real-url-and-should-not-exist on 10.128.1.253:53: server misbehaving", "DockerSocket": "tcp://this-is-not-a-real-url-and-should-not-exist:1000"}
Error: error during connect: Head "http://this-is-not-a-real-url-and-should-not-exist:1000/_ping": dial tcp: lookup this-is-not-a-real-url-and-should-not-exist on 10.128.1.253:53: server misbehaving

I've tracked it down to the spurious "Running caddy proxy controller".

CADDY_DOCKER_MODE=server caddy docker-proxy works properly.

I suspect it is due to mode being declared as a bool flag here:

https://github.com/lucaslorentz/caddy-docker-proxy/blob/6b35fc217dfb744864e9249ca8116c382364987a/cmd.go#L30-L31

and used as a string flag here:

https://github.com/lucaslorentz/caddy-docker-proxy/blob/6b35fc217dfb744864e9249ca8116c382364987a/cmd.go#L154