i’m able to setup replicated/global service. i want my application connects only to database running on the local node. fe:
node1: app.1 db.1
node2: app.2 db.2
when i use network overlay, there is a round robin, so i cannot force app.1 connect to db.1.
when i use network host (and bind node hostname into app), i can connect app.1 to node1, but db is exposed externally, which is not secure.
- target: 8443
- target: 5432
is there any setup which accomplishes this?
maybe something similar to network_mode: service:app.
There is not. I smell a hidden “I want the same set of containers on n-nodes, but each should have a different configuration that serves a different customer instance” type of question here… This is not what global/replicated deployments are designed for.
nothing is hidden
i want the same set of containers on n-nodes, with same configuration, horizontally scaled.
maybe you could smell a hidden “i want similar feature to kubernetes pods”. which allows me to connect replicated app and db within same node using private network.
You mean like a StatefulSet in k8s? Compared to Kubernetes, Docker Swarm is pretty basic… featurewise, it is even less powerfull then docker-compose.
I spend the last two years with Swarm and tried to express the strangest things with it. Though, i never encountered a solution for what you are asking for. I am afraid what you ask is not possible with swarm.
Update: oh, i got it. You want to exactly the behavior of a pod with n containers that use localhost to interact with the other containers in the pod.
Maybe this is what you are looking for: https://blog.viktoradam.net/2018/05/14/podlike/
I never used it, and found it rather odd. But this might be what you are looking for.
i’ve already found “podlike”, but it seems too much hacky for production use.
anyway, big thanks for yout hints and help. now i’m quite shure, that there is no easy workaround for this setup.