简体   繁体   English

在两台 Mac 上运行 vagrant

[英]Running vagrant on two macs

I have Vagrant installed on my iMac but I would also like to install and run it on my MacBook.我在 iMac 上安装了 Vagrant,但我也想在我的 MacBook 上安装和运行它。 Is it possible to run the same Vagrant box across two Macs?是否可以在两台 Mac 上运行同一个 Vagrant 机器?

I have done a Vagrant up command within a shared Dropbox folder - so i'm guessing that all I need to do is install vagrant on the second mac and then navigate to the Dropbox shared folder and do vagrant up .我在共享的 Dropbox 文件夹中执行了Vagrant up命令 - 所以我猜我需要做的就是在第二台 Mac 上安装 vagrant,然后导航到 Dropbox 共享文件夹并执行vagrant up

Would this work?这行得通吗?

Known solution:已知解决方案:

  1. ssh to the host machine ssh 到主机
    • user@MacBook: ssh user@imac用户@MacBook:ssh 用户@imac
  2. then vagrant up;然后流浪起来; vagrant ssh.流浪的ssh。
    • user@imac: vagrant up; user@imac:流浪者; vagrant ssh无业游民ssh
    • vagrant@vagrantvm: vagrant@vagrantvm:

This would be the most straight forward way I can think of.这将是我能想到的最直接的方式。

Another option:另外一个选项:

  • RDP to imac and run vagrant up;vagrant ssh as normal RDP 到 imac 并运行 vagrant up;vagrant ssh 正常

Yet another option:还有一个选择:

  • If your vagrant file is complete enough you should be able to vagrant up on any host to give you the same vagrant env.如果您的 vagrant 文件足够完整,您应该能够在任何主机上使用 vagrant 来为您提供相同的 vagrant env。 This relies on your use case but is how I use vagrant.这取决于您的用例,但这是我使用 vagrant 的方式。

Vagrant stores the state of the machine and machine id inside the .vagrant folder. Vagrant 将机器的状态和机器 ID 存储在 .vagrant 文件夹中。 The running machine (vm) itself is handled by virtualbox/vmware or any provider your using.正在运行的机器 (vm) 本身由 virtualbox/vmware 或您使用的任何提供程序处理。 Lets say the virtualbox box is stored somewhere else on your system and referenced by Vagrant.假设 virtualbox 存储在您系统上的其他位置并由 Vagrant 引用。

If you access the folder from two systems your basically remote controlling two different machine on two different systems.如果您从两个系统访问该文件夹,则您基本上可以远程控制两个不同系统上的两台不同机器。 Not a good solution.不是一个好的解决方案。 Furthermore, you will run into problems if the states are different, eg its "up" on system one but "destroyed" on system two.此外,如果状态不同,您将遇到问题,例如它在系统一上“启动”而在系统二上“销毁”。

Additionally to the above solutions I propose the following:除了上述解决方案,我还提出以下建议:

  • Vagrant Share !流浪者分享 Enable Vagrant http-/ssh-Share between your systems.在您的系统之间启用 Vagrant http-/ssh-Share。
  • Vagrant machines should be repeatable and destroyable. Vagrant 机器应该是可重复和可破坏的。 Therefore, put your Vagrantfile under version control and checkout on the two systems.因此,请将您的 Vagrantfile 置于版本控制之下并在两个系统上进行检出。
  • Configure your provider to store the box itself on the dropbox.配置您的提供商以将框本身存储在保管箱中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM