Network_mode: container vpn cannot start linked container if VPN has been restart

Hi,

I am using truenas scale electric eel.

I have created a specific container for the VPN and different container for apps like sonarr etc…

I created a script which restart container which have network_mode: container VPN set if VPN is restarted.

if I use the command docker stop\start or restart VPN container, the container id remain the same and the script works.

However, if I use the button stop and start on the truenas scale interface, the container id change and break all the container using Network_mode: container vpn

a docker command on the running container will show the error :
toto@truenas[~]# docker stop sonarr
sonarr
toto@truenas[~]# docker start sonarr
Error response from daemon: No such container: 3d4563b6f71e35e998c05bd372efab9e4eb57e829a526463f9e2095346445fd4
Error: failed to start containers: sonarr

the id 3d4563b6f71e35e998c05bd372efab9e4eb57e829a526463f9e2095346445fd4 is the id of the container VPN before the restart.

it seems instead to perform a stop and start, the interface will replace the existing container.

Any idea if we can specify what should be the behaviour when using the interface ?

Thanks

If you’re using Gluetun as your VPN, you could always enable the HTTP proxy mode it has. The arrs have settings for it as well.

Another idea would be to do all those apps you want on the VPN plus the VPN in a single compose?

Hi Craig,

thanks for the reply.

Yes I am using gluetun.

I did not know about the http proxy, so I could config to use the proxy set by gluetun into each application, and because this is an address, they wont use the container id but the IP port.

Any chance of a leak ? not sure if can setup a kill switch this way.

I would imagine if you set the http proxy in the arrs, they would use that for outgoing. Since that’s the whole purpose of that setting.

I have gluetun and qbittorrent rolled together in a single compose, with qbt’s network interface set to tun0. In theory, if the vpn is down, qbt can’t reach the outside world.