8/15/2016
Basic Vagrant Commands
BasicVagrantCommands
BelowaresomebasicVagrantcommandsthatoftenbeusedwhenweworkwithVagrant.
or
Theoutputshouldbesimilartobelow:
1
2
3
Vagrant1.8.1
ThesecommandsalsocanbetocheckwhetherVagrantisreadytoworkonourenvironmentornot.
2.Listallboxes
WemayneedtolistalltheboxesonourPCs,evenjusttoknowthenames.
1
2
3
Theoutputonmyconsole:
1
2
3
4
1
2
3
3.2.AddaremoteboxspecifiedbyURL
1
2
3
3.3.Addalocalbox
http://howtoprogram.xyz/2016/07/11/basic-vagrant-commands/
1/3
8/15/2016
Basic Vagrant Commands
vagrant box add
CentOS7.1
file:///D:/Work/Vagr
4.InitializeanewVM
1
2
3
vagrantinitubuntu/trusty64juju
ThiscommandwillcreateaconfigurationfilenamedVagrantfileinthecurrentdirectory.Thecontentissimilar
asbelow:
1
2
3
4
5
Vagrant.configure(2)do|config|
config.vm.box="ubuntu/trusty64juju"
end
WhenwestartVagrantinthisdirectory,Vagrantwilldownloadthebox:ubuntu/trusty64jujufromtheinternetto
localanduseitastheimageoftheVM.
Ifyouwanttosearchfortheboxes,youcangotoHashicorpwebsite
vagrantup
IfwewanttostartanyVM,simplygotothefolderwhichtheVagrantfileexist.ThecommandwillstarttheVM
andtheoutputconsoleisasbelow:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Bringingmachine'default'upwith'virtualbox'provider...
==>default:Box'ubuntu/trusty64juju'couldnotbefound.Attemptingtofinda
http://howtoprogram.xyz/2016/07/11/basic-vagrant-commands/
2/3
8/15/2016
Basic Vagrant Commands
ndinstall...
default:BoxProvider:virtualbox
default:BoxVersion:>=0
==>default:Loadingmetadataforbox'ubuntu/trusty64juju'
default:URL:https://atlas.hashicorp.com/ubuntu/trusty64juju
==>default:Addingbox'ubuntu/trusty64juju'(v20160707.0.1)forprovider:vir
tualbox
default:Downloading:https://atlas.hashicorp.com/ubuntu/boxes/trusty64juju
/versions/20160707.0.1/providers/virtualbox.box
==>default:Waitingforcleanupbeforeexiting...
default:Progress:0%(Rate:0/s,Estimatedtimeremaining:::):)
6.SSHtotheVM
1
2
3
vagrantssh
IfyouwanttosshtotheVM,simplygotothefolderhastheVagrantfileandissueabovecommand.Notethat
youneedtohavesshclientinstalledonyourPC.
7.ShutdowntheVM
implygotothefolderhastheVagrantfileandissuebelowcommand
1
2
3
http://howtoprogram.xyz/2016/07/11/basic-vagrant-commands/
3/3