Change Vagrant port forwarding on a running system

后端 未结 2 1269
名媛妹妹
名媛妹妹 2021-02-01 16:52

I have a Vagrant system up and running and I want to apply a change to it which is as little as changing one of the forwarding rules.

From this page:

相关标签:
2条回答
  • 2021-02-01 16:59

    you can do

    vagrant reload --no-provision

    and it should run without chef, puppet, etc.

    although it will still reboot the vm- feels like "But if you have an already running system..." is maybe a bit misleading.

    0 讨论(0)
  • 2021-02-01 17:04

    Have you tried using the VirtualBox user interface to add the new port forwarding rule manually? Open VirtualBox and select the running VM, then hit Settings->Network->Port Forwarding and add the new rule to, for example, forward 127.0.0.1:2223 to 10.0.2.15:22. After doing this I was able to connect to my VM on ports 2222 (as per usual) and 2223 (the new rule).

    Naturally, you would add this new rule to your Vagrantfile at the same time to ensure that the mapping becomes permanent after the eventual restart.

    Also, if your VM provisioning takes so long, have you considered moving some of the chef/puppet steps into the actual base box? For example, perhaps you are installing a bunch of server software that takes a while to install. Repackaging the box with this software already installed could dramatically reduce your Vagrant startup time.

    Hope this helps!

    0 讨论(0)
提交回复
热议问题