Question: Persisting docker /etc/hosts file changes after Docker host restart
Hi,
This is probably just a newbie question instead of an actual issue -- is there a way to restart the docker host while persisting the changes made to the /etc/hosts file?
Thanks, Kurt
By docker host, what I mean is the Linux VM that is created by docker-machine on which the docker daemon is running.
The docker run command allows you to specify a --add-host option. Is there something equivalent for docker-machine create? This way, the docker host will have the host mapping of an internal private registry.
Thanks!
I thought that this was going to be merely a trivial annoying issue, but it turns out that this also prevents pushing into a private repository. Tagging and pushing via the IP address will work but if we want the host name to be mapped to the IP address then we would need to be able to persist that host file entry between Docker host restarts.
How are other folks solving this issue?
@nathanleclaire Any ideas about this one?
You mean /etc/hosts in the VM?
Yes. Is there a way to tell docker-machine to create a host vm or update one with mappings in the host file?
It's not possible currently. You could probably use docker-machine ssh after create is done if desired.
Thanks for the information, Nathan. I will say that it is going to be hard to have to modify the /etc/hosts file each time the host VM is restarted. Now I'm wondering whether there is a way to override the docker-machine start/restart script to include automatically scripting these modifications. Good idea or bad one?
Is this the same for any custom certs that we have? Ideally, I would like to be able to add a directory on the Docker VM to the effect of /etc/docker/certs.d/my.docker.reg.com/ and then store a cert for my registry there. I am not really seeing how Docker Machine's create can handle this situation. Am I missing an optional argument that will allow for this?
Thanks again for the info, @nathanleclaire!
Thanks for the information, Nathan. I will say that it is going to be hard to have to modify the /etc/hosts file each time the host VM is restarted. Now I'm wondering whether there is a way to override the docker-machine start/restart script to include automatically scripting these modifications. Good idea or bad one?
Unfortunately there is no way to do this in Machine itself (without modification) today AFAIK but you could potentially wrap machine start and restart in a little script / alias if the need is strong.
Is this the same for any custom certs that we have? Ideally, I would like to be able to add a directory on the Docker VM to the effect of /etc/docker/certs.d/my.docker.reg.com/ and then store a cert for my registry there. I am not really seeing how Docker Machine's create can handle this situation. Am I missing an optional argument that will allow for this?
Take a look at https://github.com/boot2docker/boot2docker#installing-secure-registry-certificates. B2D accounts for this and you should be able to persist certificates in the VM if installed correctly.
Thanks, Nathan! The boot2docker link looks interesting. I'll play around with B2D (in the next day or so) to see whether it solves the problem.
This issue #1792 is related.
+1
+1
+1