Vagrant Basic commands detailed, as follows:
1, check the current version
# vagrant--version
vagrant 1.8.1
2, List all the box
# vagrant Box List
Centos/7 (VirtualBox, 1603.01)
ubuntu/trusty64 (VirtualBox, 20160406.0.0)
3. Add a Box
# vagrant Box Add address
1) Box name shorthand
Vagrant can download various vagrant image files from here Https://atlas.hashicorp.com/boxes/search.
# vagrant Box Add ubuntu/trusty64
2 Add remote box via the specified URL
# vagrant Box Add https://atlas.hashicorp.com/ubuntu/boxes/trusty64
3) Add a local box
# vagrant Box Add CentOS7.1 file:///D:/Work/VagrantBoxes/CentOS-7.1.1503-x86_64-netboot.box
4, initialization of a new VM
# vagrant Init ubuntu/trustry64
This command creates a configuration file named Vagrantfile in the current directory, which is roughly as follows:
Vagrant.configure (2) do |config|
Config.vm.box = "ubuntu/trusty64" End
When Vagrant is started in this directory, vagrant downloads the box from the Internet "ubuntu/trusty64" to the local and uses it as a VM image.
To search for available box, view here: https://atlas.hashicorp.com/boxes
5. Start VM
If we want to start any VM, we first go to the directory with the Vagrantfile configuration file, and then execute the above command. The output of the console is usually as follows:
Bringing machine ' default ' up with ' VirtualBox ' provider ...
==> Default:box ' Ubuntu/trusty64-juju ' could not to be found. Attempting to find a
nd install
... Default:box provider:virtualbox
default:box Version: >= 0 ==> default:loading metadata for
Box ' ubuntu/t Rusty64-juju '
default:url:https://atlas.hashicorp.com/ubuntu/trusty64-juju
==> default:adding Box ' Ubuntu/trusty64-juju ' (v20160707.0.1) for provider:vir
Tualbox
default:downloading:https:// Atlas.hashicorp.com/ubuntu/boxes/trusty64-juju
/versions/20160707.0.1/providers/virtualbox.box
= = > default:waiting for cleanup before exiting ...
default:progress:0% (rate:0/s, Estimated time remaining:--:--:--):--)
6, enable the SSH login VM
Enter the directory where the Vagrantfile configuration file resides, and execute the following command:
Be aware that the SSH client must be installed on this machine first.
7. Shutdown VM
Enter the directory where the Vagrantfile configuration file resides, and execute the following command:
8. Destroy VM
# vagrant Destory [Name|id]
Like what:
Vagrant Destroy Ubuntu/trusty64
This command stops the VM from running and destroys all the created resources.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.