Vagrant Basic Command Use detailed _linux

Source: Internet
Author: User
Tags ssh

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

# vagrant Up

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:

# vagrant SSH

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:

# vagrant Halt

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.