julien-duponchelle / docker-osx

Fast and easy installation of Docker on OS X
1.02k stars 70 forks source link

Give Vagrant VM a static IP address #19

Closed bfirsh closed 10 years ago

bfirsh commented 10 years ago

This sort of sucks, because we can't guarantee that 10.10.10.10 (or whatever) won't clobber something on your local network, but I'm not sure what a better solution is.

Ideally we'd also use something like this to set up a docker hostname or similar:

https://github.com/smdahlen/vagrant-hostmanager

Unfortunately installing Vagrant plugins is slow, which makes this complicated. I'll open a new issue about that.

julien-duponchelle commented 10 years ago

Hmm 10.10.10.10 will probably broke some entreprise network. We should output a warning on console when we start for the first time. (related to #20 i think)

bfirsh commented 10 years ago

Yeah. Perhaps we should add hostname support and use a more obscure address in 172.16.0.0/12 or something. Addresses in 192.168.0.0/12 that aren't 192.168.0.0/24 or 192.168.1.0/24 are rarely used too.

Networking! shakes fist

bfirsh commented 10 years ago

How about this: we use 172.16.42.43 which is unlikely to be used locally, and we add localdocker to /etc/hosts to point at that.

For the case where you're on a network where 172.16.42.43 is used, you can set a DOCKER_OSX_IP environment variable to configure the IP.

julien-duponchelle commented 10 years ago

Inst Le 31 déc. 2013 17:09, "Ben Firshman" notifications@github.com a écrit :

How about this: we use 172.16.42.43 which is unlikely to be used locally, and we add localdocker to /etc/hosts to point at that.

For the case where you're on a network where 172.16.42.43 is used, you can set a DOCKER_OSX_IP environment variable to configure the IP.

— Reply to this email directly or view it on GitHubhttps://github.com/noplay/docker-osx/pull/19#issuecomment-31400052 .

Swatto commented 10 years ago

The environnement variable makes more sense

kumavis commented 10 years ago

Maybe the default static IP could be overridden in the extra_config https://github.com/noplay/docker-osx/pull/21

bfirsh commented 10 years ago

@kumavis That's a good idea.

bfirsh commented 10 years ago

Right – I've set the address to be 172.16.42.43 (Vagrant picks addresses within 172.16.0.0/16 it seems) and added a localdocker to /etc/hosts so you don't have to remember that. @noplay – thoughts?

julien-duponchelle commented 10 years ago

172.16.42.43 it's better, less conflict possible

Instead of modifying /etc/hosts (you need root permission for that) we can setup a public DNS with that. Something like local.orchardup.com.

bfirsh commented 10 years ago

Possibly, although I like the parallels of localdocker with localhost. It would seem odd for something local to break if I didn't have a network connection.

bfirsh commented 10 years ago

Besides, you need root access to install and run VirtualBox – it's not like this is entirely in user space.

kumavis commented 10 years ago

+1 host instead of public DNS. ever stuck without internet?

julien-duponchelle commented 10 years ago

Right, but it can be broken after a system update or by another application (ex: Cisco VPN)

I agree with the point about problems if you don't have network, and it can happen more often than a broken /etc/host.

We can also check at each startup if the host file is valid.

bfirsh commented 10 years ago

@noplay yep – that's what it does. It checks on every execution. :)

bfirsh commented 10 years ago

Although this is sort of related to #20 too. I quite like the idea of having an installation function. Then, if stuff breaks, you can run it again (similar to brew doctor).

bfirsh commented 10 years ago

@noplay Does this look good? Pretty eager to get the thumbs up – I'm working on a project which I'd like to release tonight which depends on it. :)

julien-duponchelle commented 10 years ago

:+1:

mmerickel commented 10 years ago

Can we make the IP configurable via an env variable, similar to the docker version, vagrant cwd, etc?

Also, in the interest of wanting to run multiple docker instances, you do not need to forward the 4243 port when doing this, just configure DOCKER_CMD="$DOCKER_BIN -H=tcp://localdocker:4243".

mmerickel commented 10 years ago

Nevermind, I will formulate a PR since this was just merged.

bfirsh commented 10 years ago

@mmerickel Good idea. The IP is configurable with a local vagrantfile and manually setting the hosts file (see #21), but it's a bit of a faff. I think I like the idea of an environment variable.