在正在运行的系统上更改Vagrant端口转发 [英] Change Vagrant port forwarding on a running system

查看:102
本文介绍了在正在运行的系统上更改Vagrant端口转发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经启动并运行了一个Vagrant系统,我想对其进行更改,就像更改转发规则之一一样。

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.

来自此页面


像其他
配置一样,在无用状态期间应用转发的端口。但是,如果您已经有一个正在运行的系统,则调用
无用重载将应用它们,而无需重新导入和重建
的所有内容。

Forwarded ports are applied during vagrant up like any other configuration. But if you already have a running system, calling vagrant reload will apply them without re-importing and re-building everything.

请注意,转发端口需要重新启动虚拟机,因为
VirtualBox在完全重新启动
之前不会在转发的端口上启动。

Note that forwarding ports requires a virtual machine restart since VirtualBox won’t pick up on the forwarded ports until it is completely restarted.

听起来完全像我想要的声音!但是,如果我尝试重新装入无用的容器,我的所有厨师食谱都被重新装入,并且由于整个过程大约需要半个小时,所以我必须去厨房拿起第n个杯子

Sounds exactly like what I want! But if I try a vagrant reload all of my Chef recipes are reloaded and since the full process takes about half an hour, I have to go to the kitchen and grab the nth cup of coffee.

是否有任何方法可以在运行的系统上应用Vagrantfile更改而无需花费整个预配过程?我不能喝太多咖啡。

Is there any way to apply Vagrantfile changes on a running system without going trough the whole provisioning process? I cannot drink so much coffee.

推荐答案

您是否尝试过使用VirtualBox用户界面手动添加新的端口转发规则?打开VirtualBox并选择正在运行的VM,然后点击 Settings-> Network-> Port Forwarding 并将新规则添加到例如,转发 127.0.0.1:2223 10.0.2.15:22 。完成此操作后,我能够在端口2222(按常规)和2223(新规则)上连接到我的VM。

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).

自然地,您将添加此新规则同时到您的 Vagrantfile ,以确保映射在最终重启后变为永久性。

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.

此外,如果您的VM调配花费了这么长时间,您是否考虑过将一些厨师/木偶步骤移到实际的基本框中?例如,也许您正在安装一堆服务器软件,这些服务器软件需要一段时间才能安装。重新包装已经安装了该软件的包装盒可以大大减少您的Vagrant启动时间。

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.

希望这会有所帮助!

这篇关于在正在运行的系统上更改Vagrant端口转发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆