Deploying a stack will not work with the current release of docker, you need to have the next major release after 19.03.
More info: https://github.com/moby/moby/pull/39204
The magic that allows this to happen is adding a line into docker-compose.yml
hostname: "{{.Service.Name}}.{{.Task.Slot}}"
And voila, now external services such as haproxy can connect to your database servers (they must be on the same docker network in order to resolve the DNS).
Deploying a stack will not work with the current release of docker, you need to have the next major release after 19.03. More info: https://github.com/moby/moby/pull/39204
The magic that allows this to happen is adding a line into docker-compose.yml hostname: "{{.Service.Name}}.{{.Task.Slot}}"
And voila, now external services such as haproxy can connect to your database servers (they must be on the same docker network in order to resolve the DNS).