Top / Vagrant
インストール †MacだとbrewでVirtualBox?とともに入れるのがイイかな 2018/04/23追記: と思ったけど https://www.vagrantup.com/docs/installation/ ここみるとぜひオフィシャルのインストーラを使えと。 あとはVirtualBox?もわすれずに。。。 https://www.virtualbox.org/wiki/Downloads Boxのダウンロード、一覧、削除 †$ vagrant box add ubuntu/xenial64 ==> box: Loading metadata for box 'ubuntu/xenial64' box: URL: https://vagrantcloud.com/ubuntu/xenial64 ==> box: Adding box 'ubuntu/xenial64' (v20180420.0.0) for provider: virtualbox box: Downloading: https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20180420.0.0/providers/virtualbox.box ==> box: Successfully added box 'ubuntu/xenial64' (v20180420.0.0) for 'virtualbox'! でダウンロード完了 一覧表示 $ vagrant box list ubuntu/xenial64 (virtualbox, 20180420.0.0) イメージの削除 $ vagrant box remove ubuntu/xenial64 で削除。ちなみにイメージは、 $ ls -lrt ~/.vagrant.d/boxes/ total 0 drwxr-xr-x 4 masatomix staff 136 7 1 11:59 ubuntu-VAGRANTSLASH-xenial64 $ ココ。 試しにUbuntuをインストール †$ mkdir ubuntu && cd $_ /Users/masatomix/Desktop/ubuntu $ vagrant init ubuntu/xenial64 A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. $ ls -lrt Vagrantfile -rw-r--r-- 1 masatomix staff 3031 7 1 12:04 Vagrantfile OS起動 $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'ubuntu/xenial64'... ==> default: Matching MAC address for NAT networking... ==> default: Checking if box 'ubuntu/xenial64' is up to date... ==> default: Setting the name of the VM: ubuntu_default_1524405925055_36290 ==> default: Fixed port collision for 22 => 2222. Now on port 2200. ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat ==> default: Forwarding ports... default: 22 (guest) => 2200 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2200 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: Mounting shared folders... default: /vagrant => /Users/masatomix/Desktop/ubuntu iMac5K:ubuntu masatomix$ $ OSが起動しました。 $ vagrant ssh Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-119-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud 0 packages can be updated. 0 updates are security updates. vagrant@ubuntu-xenial:~$ ログインできました。 ステータス $ vagrant status Current machine states: default running (virtualbox) 一時停止 $ vagrant suspend $ vagrant status Current machine states: default saved (virtualbox) $ vagrant resume $ vagrant status Current machine states: default running (virtualbox) 停止 $ vagrant halt $ vagrant status Current machine states: default poweroff (virtualbox) $ IPをNATでなくてBridgeにする †環境変数で Vagrant の bridge を指定できるようにする - Qiita こちらからの情報そのまんまですが、デフォルトだとネットワーク設定がNAT設定になってしまいますが、Bridgeにするには Vagrantfile に以下を追加します。 # SHELL # ココから if ENV['VAGRANT_BRIDGE'] interfaces = %x(VBoxManage list bridgedifs) re = /Name: +(.*#{ENV['VAGRANT_BRIDGE']}.*)/ if interfaces =~ re config.vm.network :public_network, bridge: $1 end end # ココまで end 起動時に以下の環境設定を追加します。 VAGRANT_BRIDGE=Wi-Fi vagrant up 関連リンク †
この記事は Top / Vagrant
現在のアクセス:3609 |