Bind another docker container to vpn tunnel container

I need your help, to bind a WireGuard VPN tunnel from my WG container to another (Nextcloud AIO) container for access to my data behind the tunnel.

What I have:

  • A home network with WG server and NAS storage.
  • A VPS server with some containers (Portainer / proxy / Nextcloud / WireGuard)

What work for now:

  • The Nextcloud AIO container work with its own network (nc_network)
  • The WG connection works in its own container.
    Here, if the VPN tunnel comes up, it creates its own network (vpn-tunnel) within the container - not in Docker visible.
    Within the container I can ping my home network like it should.

Now the problem:
How can I use the vpn-tunnel network within the Nextcloud AIO?

What I tried to do:

  • I bring the Nextcloud container in the WireGuard network - can’t ping home net.
  • I created a separate network (wgtunnel) and connect Nextcloud and WireGuard to it - can’t ping home net.

For my understanding, I should bring Nextcloud directly to the vpn-tunnel network, but this is only visible in the WireGuard container and not as a network in Docker.

Found the issue by myself;

I missed a static route:

ip route add <wg net for example: 10.10.5.0/24> via <vpn-tunnel net for me: 10.0.10.2>

1 Like