Hi Alvaro,

Thanks for this. I do get it that there’s that level of indirection you 
explained. So it says that if I don’t specify a vagrantfile for the host vm, 
then it uses a special host for docker using boot2docker. So I take it that my 
Vagrantfile should be fine - it will use a proxy VM then by default via 
boot2docker.

So the ‘ports’ configuration line then maps say port 15672 from my VM to my 
docker container. Therefore now, I need to find a way to map my mac ports to 
the vm port. So how would I set up this level of port forwarding?

The official rabbitmq docker image exposes port 8080 for the management console.

My current Vagrantfile maps the VM’s port 15672 to the docker container port 
8080.

Now, say I want to map my Mac’s port 14672 to my VM’s port 15672 (which in 
turns maps it to docker’s port 8080). I assume this is what I need to 
accomplish? Is this possible?

Or is the solution to not create a port forwarding mapping from my Mac to the 
VM - but to find out the IP address of the VM instead, and use the VM’s IP 
address plus port 15672 to access the management plugin?

I tried the following - but connection is still refused (localhost:14672):

    
    config.vm.network "forwarded_port", guest: 15672, host: 14672


Having a look at the output when I vagrant up - it also feels like the ‘ports’ 
configuration for the docker provider automatically handles proxying my port 
all the way through to the docker container (from my mac host) - take a look at 
this output if I add the “forwarded_port” config:

==> default: Creating the container...
    default:   Name: rabbitmq
    default:  Image: rabbitmq:3-management
    default: Volume: /var/lib/docker/docker_1433750857_54067:/vagrant
    default:   Port: 14672:15672
    default:   Port: 5672:5672
    default:   Port: 15672:8080


It looks like the “forwarded_port” config is accomplishing the same as the 
docker provider’s ‘ports’ option.


I think this is where it is still confusing. I took a look at your Vagrantfiles 
and they seemed so complicated I couldn’t really make sense of them in relation 
to my scenario.

Anyway - your help is greatly appreciated.

Jörg


> On 08 Jun 2015, at 4:18 AM, Alvaro Miranda Aguilera <[email protected]> wrote:
> 
> Hello
> 
> You are missing one piece of the puzzle.
> 
> When you run Vagrant for docker, you are using a nested setup
> 
> 
> host -> proxy vm -> docker
> 
> if you do vagrant up where the vagrant for docker is configured, it
> will always use a proxy vm
> 
> If you are on linux it may not use it.. but you can tell vagrant to
> always use the proxy vm
> 
> 
> so your host need to connect to the proxy vm, and the proxy vm shoudl
> fwd the ports to the docker vm
> 
> 
> on this web:
> https://docs.vagrantup.com/v2/docker/basics.html 
> <https://docs.vagrantup.com/v2/docker/basics.html>
> 
> read this part:
> 
> HOST VM
> 
> On systems that can't run Linux containers natively, such as Mac OS X
> or Windows, Vagrant automatically spins up a "host VM" to run Docker.
> This allows your Docker-based Vagrant environments to remain portable,
> without inconsistencies depending on the platform they are running on.
> 
> 
> if you want a visual vagrantfile, here is one example I did:
> 
> docker vm
> https://github.com/kikitux/hashicorp-demo/blob/master/consul1/docker-dc1/Vagrantfile
>  
> <https://github.com/kikitux/hashicorp-demo/blob/master/consul1/docker-dc1/Vagrantfile>
> 
> and here the host where those docker will run:
> https://github.com/kikitux/hashicorp-demo/blob/master/consul1/host/Vagrantfile
>  
> <https://github.com/kikitux/hashicorp-demo/blob/master/consul1/host/Vagrantfile>
> 
> 
> hope this helps
> 
> 
> On Sun, Jun 7, 2015 at 8:07 PM, Señor J Onion <[email protected] 
> <mailto:[email protected]>> wrote:
>> Hi - I am new to vagrant (and docker) and have set up a simple Vagrantfile
>> to start up a rabbitmq instance inside a docker container (using the
>> official docker image for that).
>> 
>> I want to connect to the rabbitmq management plugin in my browser on my host
>> machine - I am on a Mac. I get a connection refused. I am clearly not yet
>> understanding how perhaps port forwarding works. I am using Vagrant version
>> 1.7.2 - a fresh install of that and Virtualbox. When I "vagrant up" -
>> everything starts up fine and docker-logs shows me that rabbit started too.
>> 
>> This is my Vagrantfile
>> 
>>  Vagrant.require_version ">= 1.6.0"
>>    ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker'
>> 
>>    Vagrant.configure("2") do |config|
>> 
>>      config.vm.synced_folder ".", "/vagrant", type: "rsync",
>> rsync__exclude: ".git/", disabled: false
>> 
>>      config.vm.provider "docker" do |docker|
>>        docker.image = "rabbitmq:3-management"
>>        docker.ports = ['5672:5672', '15672:8080']    # host:container
>>        docker.name = 'rabbitmq'
>>        docker.create_args = ['-e', 'RABBITMQ_NODENAME=johnny-is-a-rabbit']
>>      end
>> 
>>      config.ssh.insert_key = false
>>    end
>> 
>> 
>> Please can somebody let me know what URL to use in my browser so that I can
>> see the rabbitmq management plugin ... Or what changes I would need to make
>> to the Vagrantfile for this to work
>> (I have tried localhost:15672 and localhost:8080 ...)
>> 
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Vagrant" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] 
>> <mailto:[email protected]>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Vagrant" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/vagrant-up/GcbTei30yUM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to