如何安装带有图形用户界面(gnome、kde等)的Vagrant Linux虚拟机?

9

我该如何安装带有桌面图形界面(gnome,kde等)的Vagrant Linux box?

是否有已经预装了桌面环境的Vagrant box发行版?

在执行“vagrant up”后,我如何登录到此虚拟机并激活GUI?


我使用主机上的GUI通过共享/同步驱动器在客户VM上工作(编辑和处理版本控制)。VM运行站点/应用程序。您可以添加vm.gui=true以使用VirtualBox GUI,或者只需vagrant ssh即可。 - user2182349
2个回答

12

这个问题是一个重复问题,这里有一个详细的答案:使用 Vagrant 运行带有桌面环境的虚拟机

是的,您需要在 Vagrant 文件中启用 GUI,但首先您需要:

  • 安装 Virtual Box Guest Additions
  • 安装您的桌面环境

从上面链接中的一个答案(https://dev59.com/02Mk5IYBdhLWcg3w5Bzy#33138627),您可以使用以下 Vagrant 文件:

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

这对我有用。要启动桌面,请登录到VirtualBox实例并键入“startx”。 - user3078690
当我尝试这样做时,wily64出现了404错误。在下载远程文件时发生错误。 请求的URL返回错误:404未找到当我尝试使用以下内容替换它时 config.vm.box = "ubuntu/xenial64"我遇到了x11错误。 默认值:运行:内联脚本 默认值:sed:无法读取/etc/X11/Xwrapper.config:没有那个文件或目录 - openCivilisation

5
如果您想进入桌面GUI,可以修改Vagrantfile文件并添加vb.gui = true。例如:
config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true

    # Customize the amount of memory on the VM:
    # vb.memory = "1024"
end
然后您可以使用vagrant up命令,在VirtualBox中进入它。

请展示您的完整Vagrantfile以执行此操作。如果我使用的是64位Ubuntu,则无需添加任何GUI系统文件?也就是说,VirtualBox将作为独立于Ubuntu的GUI? - Ken
4
嗯,我以为你只是想通过虚拟机进入它,如果你希望它显示桌面,Ubuntu 必须使用 sudo apt-get install ubuntu-desktop 安装桌面。 - haofly

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接