VitualBox + Vagrant 搭虚拟机

Install VirtualBox and Vagrant

  • VirtualBox
  • Vagrant

Box: Execute commands

ubuntu.box

vagrant init ubuntu/trusty64
vagrant up

result

==> default: Successfully added box 'ubuntu/trusty64' (v20170918.0.0) for 'virtualbox'!
==> default: Importing base box 'ubuntu/trusty64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Setting the name of the VM: VOS_default_1505893534153_40845
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.3.36
    default: VirtualBox Version: 5.1
==> default: Mounting shared folders...
    default: /vagrant => /Users/bqliu/Documents/VOS

Check

vagrant box list

Setup Network

config.vm.network "private_network", ip: "192.168.33.10"

Restart VM

vagrant up

SSH

vagrant ssh
...
sudo passwd

Command

stop:vagrant halt
restart:vagrant reload
destroy:vagrant destroy

My Pair: Yaxin

你可能感兴趣的:(VitualBox + Vagrant 搭虚拟机)