Containers on separate hosts on same network using Caddy

I have two linux devices on my home network. One is running Caddy as a reverse proxy using DNS challenge for SSL. This is working fine for containers on that same host, and involved creating a Docker network for them to use.

The second host is running an Immich container. I’d like to have Caddy handling this in the same way, but the container won’t initiate as it does not recognise the Docker network above (error message says declared as external but could not be found).

Before submitting any code, some help with general understanding would be useful. I’ve read that using swarm/an overlay network can enable containers in separate hosts to communicate. Is that what is required here? Or can it be achieved as above with some Immich/Caddy/firewall tinkering?

Docker by itself only works on a single host. If you want to connect multiple hosts, you can use Docker Swarm. It will create a Docker overlay network across hosts, in which all containers can communicate with each other.

Traefik reverse proxy can auto-configure all Docker Swarm services (example). Not sure if caddy supports Swarm.

Of course you should be able to manually configure caddy to proxy requests to another internal network IP, when publishing the port of the container on the other host.

Thanks for your reply, much appreciated. Sorry is your last point regarding Caddy an aside from docker being in swarm mode? Or are you saying it should be able to function once an overlay network is in place?

At least when using Traefik, there is a difference between using Docker or Swarm for auto-configuration of target services via labels. So you would need to check with Caddy, how they handle it.

I see, ok I’ll have a look more closely at how those work together and give it a try, thank you again!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.