Why you should prune your docker networks
So... Today I spent 8 hours. Yes 8, not 4, not 1. 8 HOURS debugging a network issue.
For a project I'm working on I had to setup a very specific IP range on a router, the why doesn't really matter. Now, the router I was using was an old router I had laying around on which I had flashed OpenWRT (basically a popular Open Source router firmware). After resetting the router, changing the settings to reflect the correct range I wanted I pressed Save & Apply and nothing. The web interface was not responding anymore, so I tought well, let's try again because I probably made a mistake in the setup.
After trying again, I figured, well maybe the firmware is not up-to-date so I updated, changed it all again, still nothing. Web interface not reachable, but, internet connectivity worked which was weird and kinda tripping me up. How come routing to the internet worked but accessing the Web UI did not. So I thought, as dumb as it was, well probably OpenWRT acting up. Why I thought that, I have no clue, but I acted on this assumption and reflashed the stock firmware of the router. Changed everything again and still no luck.
This is where I completely went of the rails and did not think straight, I thought maybe the router is just broken. So I went and fetched a different one, set everything up and still nothing. Then I thought well maybe it's the browser acting up and I tried Chrome, also nothing just a host unreachable error. Hint: That should've been a big clue.
Me going completely bonkers didn't really help, so after a not so relaxing drive home I tried again with a fresh mind. I started investigating the host unreachable errors, surely this would be something which would be obvious in the routing tables. So after executing the command to view the routes, I saw 2 times the same IP address, one correct but down and another one which was incorrect and UP. This is when it hit me, I had created a docker network to test some containers I was building for the same project but forgot to clean up the network once I was done. And I remember telling myself when I was testing the containers: "If I forget to remove this network I'm sure it will bite me in the a** sooner or later."
So after pruning my docker networks
docker network prune
I tried again, and wouldn't you know it, it worked. So if you are on your own development machine which has docker and you see some weird networking error. Be sure to check (maybe even prune) your docker networks to prevent wasting 8 hours.