machine icon indicating copy to clipboard operation
machine copied to clipboard

Make VirtualBox port forwarding configurable

Open joshjdevl opened this issue 11 years ago • 14 comments

Hi,

It would be helpful if we can configure the port forwarding when installing a new box.

Thanks

joshjdevl avatar Dec 07 '14 23:12 joshjdevl

SSH is forwarded. What other ports should be forwarded?

bfirsh avatar Dec 08 '14 23:12 bfirsh

SSH is forwarded. What other ports should be forwarded?

Additional port should be configurable when creating a new box.

joshjdevl avatar Dec 08 '14 23:12 joshjdevl

Can't this be done directly through VirtualBox? What cases would it be useful to have Machine do this too?

bfirsh avatar Dec 09 '14 16:12 bfirsh

Can't this be done directly through VirtualBox? What cases would it be useful to have Machine do this too?

Can't this be done directly when the machine is first setup to standard the configuration process? What cases would it be useful to have an additional step when creating a "Machine"?

joshjdevl avatar Dec 09 '14 17:12 joshjdevl

:+1: I'd love to see this support. It would make it easier for my dev's to setup an environment and be able to copy/paste the URLs of their local machines around so that others can see their work.

ianneub avatar Feb 18 '15 21:02 ianneub

Bonus points for being able to give it a range of ports to forward. Use cases: Our devs are working on multiple website projects at once and we want to pass the URLs of the local machine around to team leaders or what have you to inspect/critique the work.

ianneub avatar Feb 18 '15 21:02 ianneub

:+1:

divyakumarjain avatar Jun 02 '15 16:06 divyakumarjain

:+1:

MiLk avatar Jul 04 '15 01:07 MiLk

:+1:

charlesg3 avatar Jul 17 '15 21:07 charlesg3

This would be badass. Otherwise, I don't know how docker-machine is calling ssh, but port forwarding that way would also be fine by me.

pnovotnak avatar Jul 29 '15 18:07 pnovotnak

Using a container as a local server is a use case. I want to provide my developers with the ability to create and start a machine that can serve web applications that can be hit from other machines on the network. What I DON'T want to have is instructions like "Open virtual box GUI, do these steps, click this box, and now you have port forwarding. What I DO want is to provide a command "docker-machine create -d virtualbox -p 8080:8080 default"

cdierkens avatar Aug 26 '15 21:08 cdierkens

Yeah, so I wrote this Fish function that I tied into some other functions to prepare the vm for my project. Maybe someone will find some use for it.

function vbox_port -d 'Forwards VirtualBox port'
  set name $argv[1]
  set port $argv[2]

  VBoxManage modifyvm drought --natpf1 "$name,tcp,127.0.0.1,$port,,$port"
end

One problem I have is that I create my VM but when I put my laptop through a suspend cycle port forwarding breaks and I'm not sure why. The only fix I've found is removing the vm and then recreating it. The downside is that I have to pull down my containers again and that's kinda' puts a halt towards development on the go.

howdoicomputer avatar Sep 11 '15 02:09 howdoicomputer

 BLUE='\033[1;34m'
 GREEN='\033[0;32m'
 RED='\033[0;32m'
 NC='\033[0m'
 VM=app-docker   
 
 if [ ! -z "$VBOX_MSI_INSTALL_PATH" ]; then
   VBOXMANAGE="${VBOX_MSI_INSTALL_PATH}VBoxManage.exe"
 else
   VBOXMANAGE="${VBOX_INSTALL_PATH}VBoxManage.exe"
 fi
echo -e "${BLUE}VBoxManage -v ${NC} = $("${VBOXMANAGE}" -v)"
VBoxManage modifyvm "${VM}" --natpf1 "my-web,tcp,127.0.0.1,8080,,80"
VBoxManage modifyvm "${VM}" --natpf1 "my-ssh,tcp,127.0.0.1,2200,,220"

farums avatar Mar 25 '20 15:03 farums

Make it usefull: https://github.com/selvaraj-kuppusamy/port_forwading-virtualbox

selvaraj-kuppusamy avatar Sep 18 '21 03:09 selvaraj-kuppusamy