Use a common base image for services (configured via ENV).
Deploy services via docker stack deploy or Docker SDK.
Use Traefik for dynamic routing and service discovery.
Swarm works best with replicated services, not lots of unique, one-off containers. Consider adapting your setup for that. Want a quick example docker-compose.yml for Swarm + Traefik?
It is unclear what swarms role is supposed to be in your architecture.
Where swarm can help:
It could help by placing services on different nodes
this requires the images to be hosted on a container image registry
Since a container can be scheduled on any node, local volume data is not going to work, if you need a container needs to puck up its previous state from a volume. This would work with a remote nfs or cifs share though.
it supports to run identical replicas of a service, that are internally exposed through a service vip and balanced in a round-robin manner by the kernel loadbalancer IPVS. If you publish a port on the service, it will point to the service vip.
You need to share more (and less ambiguous) information of what the solution should be able to do.
I don’t use replicated services since each of my services are unique as @tim753milner says “Swarm works best with replicated services, not lots of unique, one-off containers.”
I will take a look on Traefik, thank you
@meyay I was unclear about how to use swarm but now it’s ok , I see I can’t use it in my project