I have created a specific container for the VPN and different container for apps like sonarr etc…
I wanted to have a script which restart container which have network_mode: container VPN set.
I realize that when the VPN container is restarted, I can stop the APPS using this network but I cannot start it as I am getting the following 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.
the only way to start the sonarr container is through the interface of Truenas.
if anybody have already encounter that, I am using docker version : Docker version 27.1.1, build 6312585
Or the vpn container is not restarted, but instead replaced.
Note: if container B uses network_mode: A, it uses (and depends on) the network namespace of A. I would be surprised if B keeps on running, when A is not running.
What I realised last night is if I use the docker command stop\start on VPN (network A) or docker restart, this one keep the same container id so any command\script work because the container kept the same container id however, if I use the interface of the (truenas scale) to stop and start the container id will be replace\new so it mean its replaced.
Could I put something in the docker compose to change the behaviour or this is outside the box behaviour which will need to be change.
If the webinterface of TrueNAS is what deletes the container instead of stopping it, you won’t fix it by adding anything to the compose file.
Unless… if TrueNAS supports setting the network_mode somehow, you could run a container just for its network namespace (let’s call it vpnnet) and set the vpn container to use the network namespace of the vpnnet container. Then you can delete the VPN container since nothing depends on it.