I'm trying to set up communication between containers that are running in two separate VPNs managed by gluetun. Each VPN has its own container, and I've connected multiple services to each VPN. Specifically, I need the services from one VPN to reach services in the other VPN. Here's the setup:
- **Container for VPN A** (gluetunA) with serviceA connected. It has exposed ports 1111 and 2222.
- **Container for VPN B** (gluetunB) with serviceB connected. It has exposed ports 3333 and 4444.
The challenge is that serviceB needs to access serviceA's port 1111, but since they are in separate VPNs, I'm unsure how to configure this. I've considered alternatives like using split tunneling, but I'm not certain if that's the right approach. I'm running Docker version 27.5.0 on TrueNAS Scale 25.04.2.1.
1 Answer
It sounds like you're trying to connect services across different VPNs on the same host. If that's the case, you can create an 'external' Docker network that both containers can join. This way, they'll be able to communicate using their service names instead of needing to deal with localhost.
You might do something like this:
```yaml
services:
gluetunA:
networks:
shared_network:
serviceA:
networks:
shared_network:
gluetunB:
networks:
shared_network:
serviceB:
networks:
shared_network:
```
Make sure both VPNs are set to allow communication through the network. This should enable serviceB to reach serviceA as long as they are on that shared network.

Got it, thanks for the tip! I'll create that shared network and see how it goes. Do I need to specify subnet settings, or will Docker handle that automatically?