Evening y’all
I’ll try to keep it brief, I need to move my reverse proxy (traefik) to another machine and I’m opting to utilize Docker Swarm for the first time this way I’m not exposing a bunch of ports on my main server over my network, so ideally I’d like to have almost everything listening on local host while traefik does it’s thing in the background
Now I gotta ask, is Docker Swarm the best way to go about this? I know very little about Kubernetes and from what I’ve read/watched it seems like Swarm was designed for this very purpose however, I could be entirely wrong here.
What are some key changes that differ typical Compose files from Swarm?
I’ve worked with Swarm in a startup setting. It was an absolute nightmare. We eventually gave up and moved to Kubernetes.
That said, your use case does sound simpler. As I recall, we had to set up service discovery (with Hashicorp Consul) and secret management (with Hashicorp Vault) ourselves. I believe we also used Traefik for load balancing. There were other components as well, but I don’t remember it all. This was over 5 years ago, though.
The difficulty wasn’t configuring each piece but getting them to work together. There was also the time burned learning all the different tools. Kubernetes is great because everything is meant to work together.
But if it’s just two machines with separate configuration, do you even need orchestration? Is there a lot of overhead to just manage them individually?
Unfortunately, it was too long ago to remember the details of differences between compose and swarm. I do remember it was a very trivial conversion.
I run swarm in my homelab and have done for years, traefik runs on my manager and uses the docker swarm networks to get to services.
My traefik compose makes all the service networks, then each service compose has an external network that all the containers connect to.
This is my example config, this might help - https://github.com/mhzawadi/docker-stash/tree/master/swarm
Well first off swarm doesn’t work with environment variables, so if you pass any in you’re going to need to pipe the output of docker compose read into docker swarm service create.
Your port settings are gonna give it a problem too, swarm doesn’t support that new syntax, and as a result you can only assign a single network interface to a service.
Regarding networking, since the whole paradigm is that you’re not defining a single container but a service that can live/move across multiple nodes; any traffic to any node in your swarm will be routed (round robin style) across the copies of that service. (This makes logging setup a PITA, ask me how I know!)
Bind mounts aren’t recommended, volumes are preferred. Otherwise everything needs to be mirrored across all nodes, depends on the use case.
That being said I’m not convinced that swarm is the right answer here, I concur with @talentedkiwi@sh.itjust.works. You should just install pangolin on your second machine.