使用Vagrant在桌面环境中运行虚拟机 [英] Using vagrant to run virtual machines with desktop environment
问题描述
我公司的开发环境基于在VirtualBox上运行的虚拟机。我们想进一步前进,并使用Vagrant的功能在文本文件中包含对机器的描述,然后能够基于该文本文件提升该机器。结合使用p,可以解决我们每个人在VM中安装了不同软件版本的问题。
My company's development environment is based on virtual machines, running on VirtualBox. We would like to move one step further, and use the capabilities of Vagrant to have the description of the machine in a text file and then be able to "raise" that machine based on that text file. Combined to puppet, this would solve us the problem that everyone have different software versions installed in the VM.
但是,Vagrant似乎非常专注于在主机上进行开发,使机器处于后台。我们将需要在计算机中拥有我们的开发环境,因此我们需要一个完整的GUI,因此在键入无用功时,应显示具有完整桌面环境(XFCE,KDE ...)的计算机。
However, Vagrant seems very focused to develop on the host, letting the machine in the background. We would need to have our development environment within the machine, so we would need a complete GUI, so when typing "vagrant up" a machine with a complete desktop environment (XFCE, KDE...) should appear.
到目前为止,我已经设法通过Xubuntu发行版创建了一个基本框。但是,当我键入 vagrant up时,尽管出现了桌面,并且我能够正确登录,但Vagrant冻结了消息正在等待计算机启动。这可能需要几分钟...。过了一会儿,Vagrant崩溃了,因为超时了。因此,不会创建共享文件夹,也不会执行软件包供应商-puppet-。
So far, I've managed to create a "base" box from a Xubuntu distribution. But when I type "vagrant up", although the desktop appears, and I am able to login properly, Vagrant freezes at the message "Waiting for machine to boot. This may take a few minutes...". After a while Vagrant crashes due timeout. So shared folders are not created, nor the package provisioner -puppet- is executed.
如何使用流浪汉创建具有完整GUI的虚拟机?
How to create a virtual machine with a complete GUI using vagrant?
推荐答案
我只需要三个步骤就可以完成此工作。 askubuntu.com
的建议对我而言并不奏效,因此请尝试以下简化版本:
I just got this working with basically three steps. The advice from askubuntu.com
didn't quite work for me, so try this simplified version:
- 获取基本的Ubuntu映像。您应该能够启动它,并
。 - 接下来,启用VirtualBox显示,默认情况下处于关闭状态。停止VM并在
Vagrantfile
:
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
xfce4
。使用 vagrant ssh
并:
sudo apt-get install xfce4
sudo startxfce4&
如果这是您首次运行此Ubuntu环境,则在安装xfce4之前,需要运行以下命令:
If this is the first time you're running this Ubuntu environment, you'll need to run the following command before installing xfce4:
sudo apt-get update
就是这样,您应该进入 xfce4
会话。
That's it, you should be landed in a xfce4
session.
更新:为了获得更好的体验,我建议进行以下改进:
Update: For a better experience, I recommend these improvements:
- 不要以root用户身份启动GUI。您确实想保留
vagrant
用户。为此,您需要允许任何人启动GUI:sudo vim /etc/X11/Xwrapper.config
并将其编辑为allowed_users = anybody
。 - 接下来,在启动GUI之前,先安装VirtualBox来宾工具 。这将为您提供健康的屏幕分辨率,集成的鼠标等。
- Don't start the GUI as root. You really want to stay the
vagrant
user. To do this you need to permit anyone to start the GUI:sudo vim /etc/X11/Xwrapper.config
and edit it toallowed_users=anybody
. - Next, install the VirtualBox guest tools before starting the GUI. This will give you a healthy screen resolution, integrated mouse, etc.
$ sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
$ sudo VBoxClient-all
vagrant
用户身份启动GUI,与 $ startxfce4&
。
vagrant
user, with $ startxfce4&
. 更新2:今天尝试过此方法,并非总是安装 VBoxClient-all
脚本。如果缺少它,则可以用等效项替换:
Update 2: Tried this today and the VBoxClient-all
script isn't always installed. If it's missing, you can replace with the equivalent:
sudo VBoxClient --clipboard
sudo VBoxClient --draganddrop
sudo VBoxClient --display
sudo VBoxClient --checkhostversion
sudo VBoxClient --seamless
这篇关于使用Vagrant在桌面环境中运行虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!