問題点:vagrant up でエラーが出る
解決したいこと:1つ目の仮想マシンを正常に起動させられるようにすることと、複数の仮想マシンを正常に立ち上げる際には、どの点に注意すれば良いのか。
###問題に至った経緯
2つ目の仮想マシンを立ち上げようと思って、新たなフォルダを作り、そこにvagrantfileを作って、2つ目の仮想マシンを起動させた。
しかし、1つ目の仮想マシンに戻ろうと思い、フォルダに移動してvagrant upしたら下記のエラーが出てきて、立ち上げられないようになってしまった。
mba:centos mango$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'centos/7' is up to date... ==> default: A newer version of the box 'centos/7' for provider 'virtualbox' is ==> default: available! You currently have version '1804.02'. The latest is version ==> default: '1809.01'. Run `vagrant box update` to update. Vagrant cannot forward the specified ports on this VM, since they would collide with some other application that is already listening on these ports. The forwarded port to 2222 is already in use on the host machine. To fix this, modify your current project's Vagrantfile to use another port. Example, where '1234' would be replaced by a unique host port: config.vm.network :forwarded_port, guest: 22, host: 1234 Sometimes, Vagrant will attempt to auto-correct this for you. In this case, Vagrant was unable to. This is usually because the guest machine is in a state which doesn't allow modifying port forwarding. You could try 'vagrant reload' (equivalent of running a halt followed by an up) so vagrant can attempt to auto-correct this upon booting. Be warned that any unsaved work might be lost.
###2つ目の仮想マシンを立ち上げる際に行った一連の流れ
ホームディレクトリに移動
cd
今後複数の仮想マシンを作ることを想定して、それらをまとめるフォルダ(MyVagrant)を作る
mkdir MyVagrant
MyVagrantに移動する
cd MyVagrant
仮想マシンを作るフォルダを作る(MyCentOS)
mkdir MyCentOS
MyCentOSに移動する
cd MyCentOS
仮想マシン設定用のVagrantfileを作る
vagrant init bento/centos-6.8
Vagrantfileを編集して仮想マシンのIPアドレスを192.168.33.10にする
sed -i '' -e 's/# config.vm.network "private_network", ip: "192.168.33.10"/config.vm.network "private_network", ip: "192.168.33.10"/' Vagrantfile
仮想マシンを起動する(少し時間かかります)
vagrant up
仮想マシンの状態を確認する
vagrant status
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。