LoginSignup
0
0

More than 3 years have passed since last update.

vagrant upに失敗した時の対応策

Posted at

DXを大幅に低下させるDocker for Macを捨ててMac最速のDocker環境を手に入れる - Qiita

Vagrantを使う「Mac最速のDocker環境」を初心者向けに解説【遅いMac for Dockerを卒業】 - Qiita

上記の記事を参考にvagrant upした所、以下のようなエラーが出ました。

The provider for this Vagrant-managed machine is reporting that it
is not yet ready for SSH. Depending on your provider this can carry
different meanings. Make sure your machine is created and running and
try again. Additionally, check the output of `vagrant status` to verify
that the machine is in the state that you expect. If you continue to
get this error message, please view the documentation for the provider
you're using.

解決方法を残しておきます。

1. Vagrantfileを修正

mutagenを使っている部分でエラーが出ているようなので、以下の部分をコメントアウトします。

Vagrant.configure('2') do |config|
  config.vm.box = 'ubuntu/xenial64'

  config.vm.hostname = 'vagrant01'

  config.vm.network :private_network, ip: '10.212.212.212'

  config.vm.provider :virtualbox do |vb|
    vb.gui = false
    vb.cpus = 4
    vb.memory = 4096
    vb.customize ['modifyvm', :id, '--natdnsproxy1', 'off']
    vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'off']
  end

  config.disksize.size = '30GB'
  # ここからコメントアウトする
  # config.mutagen.orchestrate = true

  # config.vm.synced_folder './', '/home/vagrant/app', type: "rsync",
  #   rsync_auto: true,
  #   rsync__exclude: ['.git/', 'node_modules/', 'log/', 'tmp/']

  # config.vm.provision :docker, run: 'always'
  # config.vm.provision :docker_compose
  # ここまで
end

2. Vagrant up

Vagrantfileを修正した状態で起動すると成功します。

vagrant up

3. Vagrantfileを元に戻す

このままではコメントアウトした部分の設定が反映されてないので、virtualboxを停止してからVagrantfileを戻します。

vagrant halt

これで停止しますので、Vagrantfileのコメントアウトを外します。

4. Vagrant up

再度起動します。1回目より時間がかかります。

vagrant up

5. 確認

ssh接続できれば成功です。

vagrant ssh

私のPCにはもともと~/.ssh/configは存在していたのですが、実行後に再確認すると追記されていました。

おまけ

vagrant validate

上記のコマンドでVagrantfileが正しく書かれているかチェックできます。

私はconfig.vm.hostname = 'vagrant_test'という設定をしていた所、ハイフンとかアンダーバーは使えないよ的な警告を受けました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0