How do I associate a Vagrant project directory with an existing VirtualBox VM?

后端 未结 10 1801
梦如初夏
梦如初夏 2020-12-02 03:57

Somehow my Vagrant project has disassociated itself from its VirtualBox VM, so that when I vagrant up Vagrant will import the base-box and create a new virtual

10条回答
  •  不思量自难忘°
    2020-12-02 04:09

    I'm using Vagrant 1.8.1 on OSX El Capitan

    My vm was not shut correctly when my computer restarted, so when i tried vagrant up it was always creating new vm. No solutions here worked for me. But what did work was a variation of ingmmurillo's answer

    So instead of creating .vagrant/machines/default/virtualbox/id based on the id from running VBoxManage list vms. I had to update the id in .vagrant/machines/local/virtual_box/id

    I've got a one liner that essentially does this for me:

    echo -n `VBoxManage list vms | head -n 1 | awk '{print substr($2, 2, length($2)-2)}'` > .vagrant/machines/local/virtualbox/id

    This assumes the first box is the one i need to start from running VBoxManage list vms

提交回复
热议问题