According to the documentation it's easy to run a Vagrant VM in GUI mode:
config.vm.provider "virtualbox" do |v|
v.gui = true
end
However, is there a way to do this from the command-line, for example when running vagrant up
? For example,
vagrant up --gui
vagrant up --headless
Different users may prefer to boot the UI or not; it doesn't seem like it should be specified in the Vagrantfile that everyone will use!
The GUI option is provider specific (and only very few providers support it), so it doesn't feel right for a top level vagrant command to add a switch for it.
To my experience the most common use cases for GUI are:
If you anyway have a setup where it's normal to switch the GUI on and off, you can use environment variables. For example something like this in Vagrantfile:
# Returns true if `GUI` environment variable is set to a non-empty value.
# Defaults to false
def gui_enabled?
!ENV.fetch('GUI', '').empty?
end
Vagrant.configure('2') do |config|
config.vm.provider 'virtualbox' do |v|
v.gui = gui_enabled?
end
end
Then on command line on a *nix system:
GUI=1 vagrant up
And on Windows:
set GUI=1
vagrant up
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With