Can I bring up the GUI for a Vagrant managed Virtual box while the box is running?

69,184

Solution 1

There are 3 ways I've found to get a gui on a running headless machine if you can see it in the VirtualBox Manager:

  • You can suspend the machine (Close|Save State or vagrant suspend) and then start it again. When you restart it, you will see the GUI.

or, if you don't want to stop the machine at all:

  • You can go to display settings and enable the Remote Display Server while it's running (you may want to change the default port), and then use an RDP viewer (On Windows use Remote Desktop Connection) to access the GUI.

  • [Edit July 2015] With VirtualBox 5.0, click on the headless VM, choose "Show", and it will bring up the gui.

Solution 2

You'll have to do vagrant reload after enabling gui.

But there is a trick (a bit risky in my opinion) 1. save the state of the VM VBoxManage controlvm NAME_OR_UUID savestate 2. star vbox gui and resume

BTW: BTW: Why do you need GUI for Vagrant managed (headless) running VMs? If you prefer GUI to manage headless VMs, try phpVirtualBox.

Solution 3

From my experience with vagrant once you start completely headless there is no way to boot the GUI, you have to boot it on start with the line you mention above.

Solution 4

If it's running on VirtualBox (what vagrant typically uses) :

preface: you can't without (shortly) interrupting the VM! So you can't just open it for a running instance in VirtualBox.

You may find http://www.toptensoftware.com/VBoxHeadlessTray/ helpful, it has minor bugs if you ask me but nice to have to save what you can do ...

... On console: you might simply do what @terry-wang wrote:

  1. suspend machine by VBoxManage controlvm <NAME_OR_UUID> savestate
  2. restart with gui option VBoxManage startvm <NAME_OR_UUID> --type gui
    alternative: start gui manager yourself as terry wrote
    revert / make headless from gui: VBoxManage startvm <NAME_OR_UUID> --type headless

Update on VirtualBox 5: VirtualBox GUI has the function to start in Background nativly included now, so still the tool is a shortcut but not even more needed to not be forced using the console

Share:
69,184
mattwise
Author by

mattwise

Updated on May 10, 2020

Comments

  • mattwise
    mattwise almost 4 years

    I know that I can configure my Vagrantfile to boot my machine with a GUI according to http://docs.vagrantup.com/v2/virtualbox/configuration.html with:

    config.vm.provider "virtualbox" do |v|
      v.gui = true
    end
    

    But if I've started a box headless, is there any way to bring up a GUI while the machine is running? Virtualbox provides the small preview, so I suspect it is possible but I haven't found any documentation on how to do this.

    Edit: Terry pointed out that I can vagrant reload after changing the setting above to get a gui, but that reboots the box. I'm still hoping there's a easy way to enable the gui without a reboot.

  • mattwise
    mattwise over 10 years
    I'm using Vagrant to manage a cluster for development/testing, and for the most part, a gui will just get in the way. Now and again I need a local web browser to test some http end points that should only be available internal.
  • Aaron Blenkush
    Aaron Blenkush over 10 years
    @mattwise If you only need to test if the page is accessible, you can do that from the shell with curl, wget, something similar. stackoverflow.com/a/2924444/873263
  • Victor Roetman
    Victor Roetman over 9 years
    @mattwise, you can access ports bound internal only with ssh port forwarding, for example ssh -L8888:127.0.0.1:80 [email protected]:2222, changing the port numbers to what is appropriate for you, where 2222 is the ssh forward port to the vagrant machine, 8888 is the local port you point your web browser to, and 80 is the port only visible inside the virtual machine.
  • matbrgz
    matbrgz almost 9 years
    Note that Remote Display Server requires an extension pack from Oracle.
  • Brad Pitt
    Brad Pitt almost 5 years
    what I clicked 'show', the GUI brought up was very small and ugly. Is there anyway to fix that?