In a scenario where one service connects to the other one's network (as in the example .yml below), is there a way to use --scale to scale both and make them connect to the correct network?
As in app1 uses vpn1 network, app2 uses vpn2 network etc.
services:
vpn:
image: myvpn
app:
image: myapp
depends_on: vpn
network_mode: service:vpn
I want to be able to run the container with docker-compose up -d --scale app=5 --scale vpn=5
The issue is that if I scale both containers the way it's currently setup (lets say with two instances of each service to simplify), both "app" services connect to the first "vpn" service.
I can confirm it by inspecting both app-1 and app-2. In "HostConfig" they both show "NetworkMode": "container:ef37426bec3dbd9c182187d87faf5fe8c92c1e1fa26066f57d163f301af2574e", which is the first vpn container.
I understand this is the expected behavior, as the .yml file indicates network_mode: service:vpn and not something like network_mode: service:vpn-${container ID here}
I want to find a way to set app-1 to use vpn-1 as NetworkMode, app-2 to use vpn-2 as NetworkMode, etc.

