Access services running on the host machine inside a Swarm-managed container

Hello,

I’m deploying a simple application that relies on a PostgreSQL and a Redis instance.
These instances are live on the host machine, outside of any container.

My application needs to connect to these services.
However, I can’t find a way to connect to the host machine network from the container…

I tried creating an external network with the overlay driver and the --attachable flag, but nothing.
And I can’t seem to be able to create any other network type due to Swarm restrictions.

I could switch back to a simple Docker Compose, however I really like the way deployment is handled via Swarm… and it would annoy me to return back to something more primitive.

Is there a way to “mount” the host’s localhost into some IP address inside the container?

Thanks.

I don’t know if the last solution would work the same way with swarm, but I just shared it in another topic minutes ago.

For swarm host network I found this old topic

I don’t know what your expectation was by using overlay networks. Maybe I get something wrong, but you either use the host network mode in containers or make a service listen on an IP which is available from containers.