Installing Vagrant  
2020-12-10 Current Version: 2.2.14  
Install the latest version of Vagrant.
Install VirtualBox

默认安装地址 C:\HashiCorp\Vagrant


vagrant init hashicorp/bionic64

vagrant box add centos7-std ./

vagrant init centos7

vagrant up

vagrant box add --name ${BOX_NAME} ./

在空文件夹初始化虚拟机 vagrant init [box-name]

By default, Vagrant shares your project directory (the one containing the Vagrantfile) to the /vagrant directory in your guest machine.

PS C:\xpc\x-vagrant\centos7-std> vagrant global-status
id       name    provider   state    directory
d523b56  default virtualbox poweroff C:/xpc/x-vagrant/centos7-std
af029a6  default virtualbox poweroff C:/xpc/x-vagrant/test2

PS C:\xpc\x-vagrant\centos7-std> vagrant destroy d523b56


PS C:\Users\xpc>
PS C:\Users\xpc> vagrant.exe
Usage: vagrant [options] <command> [<args>]

    -h, --help                       Print this help.

Common commands:
     autocomplete    manages autocomplete installation on host
     box             manages boxes: installation, removal, etc.
     cloud           manages everything related to Vagrant Cloud
     destroy         stops and deletes all traces of the vagrant machine
     global-status   outputs status Vagrant environments for this user
     halt            stops the vagrant machine
     help            shows the help for a subcommand
     init            initializes a new Vagrant environment by creating a Vagrantfile
     package         packages a running vagrant environment into a box
     plugin          manages plugins: install, uninstall, update, etc.
     port            displays information about guest port mappings
     powershell      connects to machine via powershell remoting
     provision       provisions the vagrant machine
     push            deploys code in this environment to a configured destination
     rdp             connects to machine via RDP
     reload          restarts vagrant machine, loads new Vagrantfile configuration
     resume          resume a suspended vagrant machine
     snapshot        manages snapshots: saving, restoring, etc.
     ssh             connects to machine via SSH
     ssh-config      outputs OpenSSH valid configuration to connect to the machine
     status          outputs status of the vagrant machine
     suspend         suspends the machine
     up              starts and provisions the vagrant environment
     upload          upload to machine via communicator
     validate        validates the Vagrantfile
     version         prints current and latest Vagrant version
     winrm           executes commands on a machine via WinRM
     winrm-config    outputs WinRM configuration to connect to the machine

For help on any individual command run `vagrant COMMAND -h`

Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.
        --[no-]color                 Enable or disable color output
        --machine-readable           Enable machine readable output
    -v, --version                    Display Vagrant version
        --debug                      Enable debug output
        --timestamp                  Enable timestamps on log output
        --debug-timestamp            Enable debug output with timestamps
        --no-tty                     Enable non-interactive output

windows PowerShell CLI

PS C:\Users\xpc\Documents> cd D:
PS D:\> cd .\xas4k\
PS D:\xas4k> mkdir vagrant
PS D:\xas4k> clear

Windows WSL 有报错

root@DESKTOP-PM5KOT8:~# ls /mnt/c/HashiCorp/Vagrant/bin/

root@DESKTOP-PM5KOT8:/mnt/c/HashiCorp/Vagrant/bin# ./vagrant.exe
Vagrant failed to initialize at a very early stage:

Failed to locate the powershell executable on the available PATH. Please
ensure powershell is installed and available on the local PATH, then
run the command again.


报错1 doesn’t have the proper permissions

xpc@DESKTOP-PM5KOT8 C:\HashiCorp\Vagrant\bin
$ vagrant.exe init hashicorp/bionic64
The user that is running Vagrant doesn't have the proper permissions
to write a Vagrantfile to the specified location. Please ensure that
you call `vagrant init` in a location where the proper permissions
are in place to create a Vagrantfile.