Clients lose connectivity after restarting the container when using multiple networks?
</span>
</a>
</li>
</ul>
@ -2026,6 +2048,28 @@
</code></pre></div>
</li>
</ol>
<h2id="clients-lose-connectivity-after-restarting-the-container-when-using-multiple-networks"><aclass="toclink"href="#clients-lose-connectivity-after-restarting-the-container-when-using-multiple-networks">Clients lose connectivity after restarting the container when using multiple networks?</a></h2>
<p>When you attach multiple Docker networks (e.g., <code>wg</code> and a reverse proxy network like <code>traefik</code> or <code>nginx</code>) to the <code>wg-easy</code> container, Docker might assign the network interfaces randomly (e.g., swapping <code>eth0</code> and <code>eth1</code>). Since <code>wg-easy</code> expects the wireguard interface to act as <code>eth0</code> and configures <code>POSTROUTING</code> rules for it, connectivity will break if the interfaces are swapped upon container restart.</p>
<p>To solve this, specify the <code>interface_name</code> and <code>gw_priority</code> explicitly in your <code>docker-compose.yml</code> file to guarantee that the <code>wg</code> network always binds to <code>eth0</code> and acts as the default gateway.</p>