caddyserver / caddy-docker

Source for the official Caddy v2 Docker Image
https://hub.docker.com/_/caddy
Apache License 2.0
408 stars 74 forks source link

Cannot instanciate more than one caddy container from the docker image #243

Closed ij1 closed 2 years ago

ij1 commented 2 years ago

When trying to start more than one caddy container with docker-compose from the stock docker image, it fails:

Creating caddy-rproxy ... error

ERROR: for caddy-rproxy  Cannot start service caddy-rproxy: driver failed programming external connectivity on endpoint caddy-rproxy (...): Bind for 0.0.0.0:443 failed: port is already allocated

The reason for this seems to be that Dockerfile EXPOSEs ports 80, 443, and 2019. As one of the caddy containers has already reserved those ports (even though it doesn't need them for anything nor does my docker-compose file specify those ports for the container), the second caddy fails to start. It seems that if Dockerfile exposes a port, there is no way to unexpose ports on docker level; the moby issue asking for a way to unexpose is still open and very old by now so likely no resolution from that direction is expected any time soon.

ij1 commented 2 years ago

Nevermind. I had some old container running block it. I'm sorry for the noise.