Machine: Question: How do you forward ports with Virtualbox to boot2docker?

Created on 4 Mar 2015  路  3Comments  路  Source: docker/machine

Hello,

I have created a VM using docker-machine create --driver virtualbox dev
I have a container running on 8500:8500 on this dev vm and boot2docker

I would like to forward my port from the Host -> virtualbox -> boot2docker so i can target my container from my host : curl localhost:8500
Can anyone point me to the right direction ?

Thank you

Most helpful comment

the best thing to do is _not_ port forward. instead, use the second network attached to your machine

get it using docker-machine ip - the mapped container ports will be there already.

The only reason to port forward to the host's network is to allow other computers on your network to access the container's port.

but specifically for your curl localhost:8500 example

replace it with curl $(docker-machine ip):8500

All 3 comments

You can run

vboxmanage controlvm dev natpf1 "8050,tcp,127.0.0.1,8050,,8050"

the best thing to do is _not_ port forward. instead, use the second network attached to your machine

get it using docker-machine ip - the mapped container ports will be there already.

The only reason to port forward to the host's network is to allow other computers on your network to access the container's port.

but specifically for your curl localhost:8500 example

replace it with curl $(docker-machine ip):8500

Thank you very much for the answers, appreciated !
@SvenDowideit : It makes sense, thanks

Was this page helpful?
0 / 5 - 0 ratings