<p>I'm using docker desktop for mac.</p>
<p>I have built a docker image for a Node.js app that connects to an external MongoDB database via URI (the db is running on an AWS instance that I'm connected to over vpn). This works fine - I run the container and the app can connect to the database. Happy days.</p>
<p><strong>Then...</strong></p>
<p>I enable Kubernetes on docker desktop. I apply a <code>deployment.yml</code> to run the container but this deployment fails when trying to connect to the db. From my app's logs (I'm using mongoose):</p>
<pre><code>MongooseServerSelectionError: connect EHOSTUNREACH [MY DB IP] +30005ms
</code></pre>
<p><strong>Interestingly...</strong></p>
<p>I can now no longer connect to the db by running my docker container either. I get the same error.</p>
<p>I have to disable kubernetes, restart docker desktop (twice), prune my previous container and network, and re-run my container. Then it will work again.</p>
<p>As soon as I enable kubernetes again, the db becomes unreachable again.</p>
<p><strong>Any ideas why this is and/or how to fix it?</strong></p>

<p>So the issue for us turned out to be an IP range clash. Exactly the same as described in this SO question:</p>
<p><a href="https://stackoverflow.com/questions/53590312/change-kubernetes-docker-for-desktop-cluster-network-ip">Change Kubernetes docker-for-desktop cluster network ip</a></p>
<p>Unfortunately, like this user, we haven't been able to find a solution</p>
