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

5

67

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.

Nesto answered 26/11, 2013 at 20:19 Comment(1)
Just open Virtual Box, click on the instance, and click the big Show green arrow icon.Chambermaid
F
48

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.

Fortification answered 25/4, 2014 at 15:48 Comment(2)
Note that Remote Display Server requires an extension pack from Oracle.Studhorse
what I clicked 'show', the GUI brought up was very small and ugly. Is there anyway to fix that?Pilkington
R
7

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.

Rogation answered 27/11, 2013 at 4:18 Comment(3)
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.Nesto
@Nesto If you only need to test if the page is accessible, you can do that from the shell with curl, wget, something similar. https://mcmap.net/q/297210/-how-do-i-determine-if-a-web-page-exists-with-shell-scriptingSpangle
@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.Fortification
D
1

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.

Dorita answered 26/11, 2013 at 21:24 Comment(0)
A
1

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

Actuary answered 18/6, 2015 at 12:44 Comment(0)
D
1

I use:

VBoxManage startvm  <NAME_OR_UUID> --type separate

The type separate is experimental according to the documents, but it seems to work in bringing up the GUI after the VM has already been started headless.

Dividivi answered 20/7, 2022 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.