PRi*_*era 143 desktop virtualbox virtual-machine vagrant
我公司的开发环境基于VirtualBox上运行的虚拟机.我们希望更进一步,并使用Vagrant的功能在文本文件中获得机器的描述,然后能够基于该文本文件"提升"该机器.结合木偶,这将解决每个人在VM中安装不同软件版本的问题.
然而,Vagrant似乎非常专注于在主机上开发,让机器在后台运行.我们需要在机器中拥有我们的开发环境,因此我们需要一个完整的GUI,因此当输入"vagrant up"时,应该出现具有完整桌面环境(XFCE,KDE ...)的机器.
到目前为止,我已经设法从Xubuntu发行版中创建了一个"基础"框.但是当我键入"vagrant up"时,虽然桌面出现了,并且我能够正确登录,但Vagrant会在"等待机器启动时消息"中冻结.这可能需要几分钟......".过了一会儿,Vagrant因超时而崩溃.因此,不会创建共享文件夹,也不会执行包配置程序-puppet-.
如何使用vagrant创建具有完整GUI的虚拟机?
Air*_*Air 143
我刚刚完成了基本上三个步骤的工作.来自askubuntu.com我的建议并不适用,所以试试这个简化版本:
vagrant ssh.Vagrantfile:config.vm.provider :virtualbox do |vb| vb.gui = true end
xfce4.使用vagrant ssh和:sudo apt-get install xfce4 sudo startxfce4&
就是这样,你应该参加一个xfce4会议.
更新:为了获得更好的体验,我建议您进行以下改进:
vagrant用户.为此,您需要允许任何人启动GUI:sudo vim /etc/X11/Xwrapper.config并将其编辑为allowed_users=anybody.$ sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11 $ sudo VBoxClient-all
vagrant用户,用$ startxfce4&.更新2:今天尝试了这个,VBoxClient-all并不总是安装脚本.如果它丢失了,你可以用等效的替换:
sudo VBoxClient --clipboard sudo VBoxClient --draganddrop sudo VBoxClient --display sudo VBoxClient --checkhostversion sudo VBoxClient --seamless
Nik*_*Nik 74
这是Air的一个很好的答案 Vagrantfile
Vagrant.configure(2) do |config|
# Ubuntu 15.10
config.vm.box = "ubuntu/wily64"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
end
# Install xfce and virtualbox additions
config.vm.provision "shell", inline: "sudo apt-get update"
config.vm.provision "shell", inline: "sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11"
# Permit anyone to start the GUI
config.vm.provision "shell", inline: "sudo sed -i 's/allowed_users=.*$/allowed_users=anybody/' /etc/X11/Xwrapper.config"
end
Run Code Online (Sandbox Code Playgroud)
启动vm
vagrant up
Run Code Online (Sandbox Code Playgroud)
使用用户名登录:vagrant,密码:vagrant通过虚拟机GUI上的登录提示.
启动xfce
startx
Run Code Online (Sandbox Code Playgroud)
Ter*_*ang 10
我的2美分
确保您正在运行最新的vagrant(现在为1.3.3)+ VirtualBox(4.2.18)以避免错误.
您可以使用shell脚本或内联命令来安装桌面环境或轻量级窗口管理器
例如,在vagrantbox.es的Ubuntu 12.04精确基本框之上安装LXDE
Vagrant.configure("2") do |config|
# ... other configuration
config.vm.provision "shell" do |s|
s.inline = "apt-get install lubuntu-desktop -y"
end
end
Run Code Online (Sandbox Code Playgroud)
我正在使用ubuntu桌面映像,它与带有虚拟盒提供程序的Windows上的两个监视器很好地配合.
Vagrant.configure(2) do |config|
config.vm.box = "box-cutter/ubuntu1404-desktop"
config.ssh.forward_agent = true
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.synced_folder "../../git", "/home/vagrant/git"
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.customize ["modifyvm", :id, "--monitorcount", "2"]
vb.memory = "2048"
end
end
Run Code Online (Sandbox Code Playgroud)
这是针对Ubuntu 18.04 LTS / bionic的略微改编的Vagrantfile-感谢Air和Nik的回答,并且本文说明了使用VirtualBox时如何增加磁盘大小(默认= 10 GB)。
VM包含一个LightDM登录屏幕。
更新:我已经从该示例创建了一个GitHub存储库,并添加了许多用于前端+后端开发的软件包。
# Optional - enlarge disk:
#vagrant plugin install vagrant-disksize
vagrant up
vagrant reload
# After reboot, the VM screen should show the LightDM login screen.
# Log in as user "vagrant", password "vagrant".
Run Code Online (Sandbox Code Playgroud)
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/bionic64"
# Optional - enlarge disk (will also convert the format from VMDK to VDI):
#config.disksize.size = "50GB"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
end
# https://askubuntu.com/questions/1067929/on-18-04-package-virtualbox-guest-utils-does-not-exist
config.vm.provision "shell", inline: "sudo apt-add-repository multiverse && sudo apt-get update"
# Install xfce and virtualbox additions.
# (Not sure if these packages could be helpful as well: virtualbox-guest-utils-hwe virtualbox-guest-x11-hwe)
config.vm.provision "shell", inline: "sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11"
# Permit anyone to start the GUI
config.vm.provision "shell", inline: "sudo sed -i 's/allowed_users=.*$/allowed_users=anybody/' /etc/X11/Xwrapper.config"
# Optional: Use LightDM login screen (-> not required to run "startx")
config.vm.provision "shell", inline: "sudo apt-get install -y lightdm lightdm-gtk-greeter"
# Optional: Install a more feature-rich applications menu
config.vm.provision "shell", inline: "sudo apt-get install -y xfce4-whiskermenu-plugin"
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
88250 次 |
| 最近记录: |