machine
machine copied to clipboard
Add /etc/hosts entry for docker machine
When a docker machine is brought up, is there any way to automatically add in a /etc/hosts entry for the IP of that machine? I want some common keyword I can connect my services to rather than an IP. I can do this manually but it would be a neat feature.
+1
I think this is a bit out of scope for machine CLI, but it makes me want a plugin model which could accommodate this, e.g. git hook style.
+1
+1
So I noticed the Parallels provider does this by default, but not Virtualbox. When I create a machine with the Parallels driver it adds an entry like so:
xx.xxx.xxx.xxx <machine-name>.shared <machine-name> #prl_hostonly shared
This is extremely convenient for the less technical people by automating this step.
I also found that it gradually increments the vm's IP with Parallels, but Virtualbox appears to always grab the lowest available IP in the pool. So if you had a machine on 192.168.99.100, stop it, then create another new box, the new box will be on 192.168.99.100 rather than .101.
So it seems this is more driver related than docker-machine related.
this would also be advantageous for other tools, like docker-py, that are trying to assert the TLS hostname.
+1
+1
+1, but the hook way seems more interesting
+1 or even just a way to control which IP it chooses to use when starting a specific machine (preferably a stable IP per-machine) ...then I could at least hand edit my /etc/hosts file once and be done
Specify an IP is not always possible. For example, in the case of Amazon, the IP is different each time you start an instance. This is the same for GCE I think, an probably for all cloud provider. To be complete, Amazon and GCE have the notion of eternal IP to keep it at each restart of the instance, but it is more expensive, and you cannot choose the IP anymore (the IP is provided by the cloud provided, in a certain range).
The addition of an entry in a the /etc/hosts is a better solution because it is not bound to a particular driver, and therefore more interesting.
But, IMHO, a hook system is even better, because more flexible. You this, you can do a lot of think :
- Add an entry in hosts file
- OR, Register the machine resolution in a dynamic DNS, and so the resolution is not only bound to an unique machine
- Add the machine in a monitoring tools
- ...
What do you think ?
hook system - great being able to specify a specific ip for virtualbox would be a handy quick hack though
I am not sure that is a quicky hack. To force the IP, I think you have to disable the VBox DHCP server and provide an other one that provide your IP.
Or to run command inside the VM to configure the network adapter (like Vagrant do I think).
+1
+1
Trying to get TLS to cooperate with docker-py for automation tools would be way easier.
+1
+1 would improve my automation immensely.
+1
+1
Had the same concern :+1:
At the moment I'm using a custom tool for this (https://github.com/bamarni/docker-machine-dns).
I created a simple script for which I added an alias in my ~/.profile (Tested only on OSX):
alias de=". ~/bin/de.sh"
https://gist.github.com/mjumelet/1cb8f0531243ee5733a6
Since it needs to modify /etc/hosts it will ask for your password
+1
+1
+1
What about a simple sed replacement for the hosts file added to .bashrc?
+1
+1
+1
+1
+1