1

I am looking for the best method to connect two different Docker containers (ie allow them to ping eachother) that are on different networks.

I have a WireGuard container that's connected to wg-net in the 192.168.200.0/24 range, and another that's connected to the default bridge network, 172.17.0.0/24.

Pinging from one container to the other fails; and ideally I'd like to route certain IP traffic from one container through the other container, and thus connect to the WireGuard VPN.

Pinging either networks from the Docker host works fine.

What would be the best method to achieve this? I could create a 3rd network and connect the two containers to eachother, but that seems overkill. Is there no other way to have the Docker host route traffic between the two networks?

  • A shared third network is correct. Bridge network is best. It does look like you can adjust iptables on the host to allow it though: stackoverflow.com/a/51373066 – Dre Oct 9 at 23:47
0
+50

I could create a 3rd network and connect the two containers to eachother, but that seems overkill

"… Containers can join multiple networks which allows you to provide fine grained network policy for connectivity and isolation …"

Hence you can try solving this by introducing gateway CT that would be connected to both networks.

Otherwise you'd need to adjust netfilter's rules because Docker does enforce network access policy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.