vagrantによるvitrual box設定と起動

 
Name
VirtualBox で、CentOS が起動できたけど、vagrantって何が便利なの?
 
Name
vagrantを使うことで細かい VirtualBox の設定を意識せずに使う事ができるようになるよ。

vagrant のダウンロード

http://www.vagrantup.com にアクセスして自分のマシン環境に合わせたアプリケーションをダウンロード

 

vagrant のインストール

ダウンロードしたファイルを実行して自分のマシンに vagrant をインストールします。インストール後に、再起動を実施しておきます。

vagrant の実行

コマンドプロンプトから vagrant を実行します。
vagrant の環境を保存するディレクトリを作成して、そのディレクトリに移動します。
vagrant init を実行します。

C:\Users\m001\vagrant\centos>vagrant init centos/8
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.
成功すると、Vgrantfile というファイルがカレントディレクトリに作成されるので、ファイルを編集します。
真ん中あたりにあるネットワーク設定のIPアドレスの設定行のコメントアウトを外します。
# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network “private_network”, ip: “192.168.33.10”   =>この行の先頭の # を削除します。
続いて、vagrant を起動します。
C:\Users\m001\vagrant\centos>vagrant up
Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Box ‘centos/8’ could not be found. Attempting to find and install…
<中略>
==> default: Configuring and enabling network interfaces…
==> default: Rsyncing folder: /cygdrive/c/Users/m001/vagrant/centos/ => /vagrant
完了したら、ログインできることを確認します。
C:\Users\m001\centos> vagrant ssh
Last login: Sat Feb 6 23:47:31 2021 from 192.168.33.1
[vagrant@localhost ~]$
[vagrant@localhost ~]$ ls -lat
total 16
drwx——. 3 vagrant vagrant  95 Feb  6 23:54 .
-rw——-. 1 vagrant vagrant  15 Feb  6 23:54 .bash_history
drwx——. 2 vagrant vagrant  29 Feb  6 23:06 .ssh
drwxr-xr-x. 3 root    root     21 Dec  4 17:39 ..
-rw-r–r–. 1 vagrant vagrant  18 Jul 21 2020 .bash_logout
-rw-r–r–. 1 vagrant vagrant 141 Jul 21 2020 .bash_profile
-rw-r–r–. 1 vagrant vagrant 376 Jul 21 2020 .bashrc
[vagrant@localhost ~]$
以上、初めての vagrant でした。
UNIX の仮想環境が手軽に作成できるので、これから始めてみようという方にもおすすめの方法です。
 
 
最新情報をチェックしよう!

  • Warning: Trying to access array offset on value of type bool in /home/kokodayo/hachican.com/public_html/article/wp-content/themes/the-thor/template-parts/single-prevnext.php on line 87

    Warning: Trying to access array offset on value of type bool in /home/kokodayo/hachican.com/public_html/article/wp-content/themes/the-thor/template-parts/single-prevnext.php on line 88

    Warning: Trying to access array offset on value of type bool in /home/kokodayo/hachican.com/public_html/article/wp-content/themes/the-thor/template-parts/single-prevnext.php on line 89
>ワークxライフxマネー

ワークxライフxマネー

生活と仕事、お金のバランスを考えます。 順番が大切!

CTR IMG