Skip to content
This repository was archived by the owner on Jan 1, 2021. It is now read-only.
This repository was archived by the owner on Jan 1, 2021. It is now read-only.

Give the VM a hostname in the init script #85

Open

Description

@bfirsh

docker-osx adds localdocker to /etc/hosts to make accessing ports really easy: https://github.com/noplay/docker-osx/blob/master/docker-osx#L37-L61

I see some work has been done to automatically forward dynamically assigned ports in #73, but when doing development work I want my server to be at a predictable address (so, for example, I could always go to http://boot2docker:8000 in my web browser).

Activity

  1. aheissenberger commented on Jan 16, 2014

    @aheissenberger
    Contributor

    Just add a host only interface to your vm setup. Look at my fork for some fixes to get this setup running

    On Thu, Jan 16, 2014 at 8:29 PM, Ben Firshman [email protected]
    wrote:

    docker-osx adds localdocker to /etc/hosts to make accessing ports really easy: https://github.com/noplay/docker-osx/blob/master/docker-osx#L37-L61

    I see some work has been done to automatically forward dynamically assigned ports in #73, but when doing development work I want my server to be at a predictable address (so, for example, I could always go to http://boot2docker:8000 in my web browser).

    Reply to this email directly or view it on GitHub:
    #85

  2. moul commented on Jan 22, 2014

    @moul
    Contributor

    👍

  3. bfirsh commented on Jan 22, 2014

    @bfirsh
    ContributorAuthor

    @aheissenberger As well as having a predictable IP address, it's also useful to have the VM on a memorable domain name.

  4. aheissenberger commented on Jan 22, 2014

    @aheissenberger
    Contributor

    the current setup uses NAT and port forwarding - you have a predictable name wich is always "localhost" or the name you gave your host which runs the VM. Use my patch to forward the dynamical created ports to your local ip and you can access your container similar to a setup without a VM.

  5. bfirsh commented on Jan 22, 2014

    @bfirsh
    ContributorAuthor

    Then, unfortunately, you get unpredictable port numbers, which is almost as bad as having to remember an IP address.

  6. aheissenberger commented on Jan 22, 2014

    @aheissenberger
    Contributor

    with docker it is up to you what you get - you can specify it e.g.:
    docker run -p 127.0.0.1:80:8080 ubuntu bash
    This binds port 8080 of the container to port 80 on 127.0.0.1 of the host inside the vm machine. Now you need have a virtual box port forwarding setting which does bind 8080 to 8080 on your host running the VM.

    more info: http://docs.docker.io/en/latest/use/port_redirection/#port-redirection

    If you use dynamic binding, the port number can be accessed by this:
    docker port 4c01 80

  7. bfirsh commented on Jan 22, 2014

    @bfirsh
    ContributorAuthor

    "Now you need have a virtual box port forwarding setting which does bind 8080 to 8080 on your host running the VM." – that's the problem.

    With docker-py, you don't need to do any manual work to get that. If I expose port 8080 to the Docker VM, then I can just type http://localdocker:8080 into my browser to access it.

    Maybe I'm not explaining myself properly – I'm thinking of this in context of development environments, where stuff needs to be available on a predictable host and a predictable IP without without any of the hassle of port forwarding, etc.

  8. aheissenberger commented on Jan 22, 2014

    @aheissenberger
    Contributor

    I do understand what you want as I have similar requirements.

    Option 1) As long as the docker client is not integrated with the vm and does this manipulation for you, you have to write a wrapper script which will do the dynamic port forward changes for you and then calls the docker client.

    Option 2) you need to use a host only or bridged setup to get direct access to the host running the docker vm

    I am planning to setup this:

    • Dnsmasq on my host running the VM to allow multiple virtual domains for development e.g. "*.dev"
    • a container with pound (reverse proxy) on port 80 exposed to my host
    • a container per project which will registere its dynamic port and domain at the reverse proxy
  9. SvenDowideit commented on Aug 21, 2014

    @SvenDowideit
    Contributor

    This is now much more plausible, so I added it during some refactoring - not sure if it'll get commited for 1.2.0 - depends on how much time is left to debug.

  10. andyshinn commented on Dec 31, 2014

    @andyshinn

    Is this still on the roadmap? I'm trying to use boot2docker for testing service discovery locally with fig. One container I use (https://github.com/progrium/registrator) uses the IP address of the resolved hostname when I run the container with --net host. On most hosts, this is usually the first assigned IP address. But on boot2docker it is 127.0.0.1. Would be nice to map it to the hostonly or NAT private interface instead.

  11. SvenDowideit commented on Jan 2, 2015

    @SvenDowideit
    Contributor

    I just reviewed and found some solveable problems in the pre-req to that PR, so its possible that we might get there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions