If you have 2 container that is using another container as network_mode in docker this container gets the same IP as the service container. So for example you have this setup:
--- version: "2.1" services: gateway: ... cap_add: - NET_ADMIN devices: - /dev/net/tun:/dev/net/tun ports: - 1001:1001 # container a - 2001:2001 # container b a: ... network_mode: service:gateway b: network_mode: service:gluetun
Now you want to curl container b from container a for example.
You can easily access container b with a curl by using localhost.
I know this sounds absurd. But it works.