2

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.

4
  • Do you need to run the key store in a separate vm like this? Feb 24, 2016 at 15:30
  • Locally at least it would make more sense to have a single vm with all of your containers, then use --link to handle dns names (in host files) automatically for you. Feb 24, 2016 at 15:45
  • I want to emulate distribution, test how my service discovery and services behave in such environments Feb 24, 2016 at 16:14
  • Then you have to simulate that environments way of mapping a vm host ip to an dns name at startup, just like you'd have to do at amazon, azure, self hosted I'd think. Unless there is some swarm magic I am not aware of, possible because I use AWS for the prod env, you have to account for dns name updates with your vm tooling of choice. Feb 24, 2016 at 16:27

0

You must log in to answer this question.

Browse other questions tagged .