I'm trying to wrap my head around Docker and the various tools around it. And a common problem for me is that if my VM's are restarted, they might end up with different IP addresses. e.g. VirtualBox does this when running locally, Azure does this when patching VM's.
So how do I deal with this in a docker environment? For example, https://docs.docker.com/engine/userguide/networking/get-started-overlay/
$ docker-machine create \
-d virtualbox \
--swarm --swarm-master \
--swarm-discovery="consul://$(docker-machine ip mh-keystore):8500" \
--engine-opt="cluster-store=consul://$(docker-machine ip mh-keystore):8500"\
--engine-opt="cluster-advertise=eth1:2376" \
mhs-demo0
In that case, they are pointing the service discovery to a fixed IP, the IP of the mh-keystore machine.
If my VM's are restarted and the IP's are refreshed, this setup will fail as it might end up pointing to a completely different machine.
So for a dev that is really not used to the ops side of things. What are my best bets here? Use DNS names? force machines to have static IPs? (not sure if that is even an option in every environment)
There is a related issue with this when machines are rebooted, Docker sometimes end up not starting, complaining that the certs are out of sync as the IP's have changed.
running Docker-machine regenerate-certs ....
solves that.
But my impression is that docker overall plays badly with refreshed IP addresses.
Any pointers on that would be welcome too.