How to export a Vagrant virtual machine to transfer it

前端 未结 7 1189
臣服心动
臣服心动 2021-01-29 17:29

I have a vagrant box up and running (configured with a LAMP stack). I need to transfer it to another PC. How can I export it? I guess that I can get a file (or files) that can b

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-29 18:14

    You have two ways to do this, I'll call it dirty way and clean way:

    1. The dirty way

    Create a box from your current virtual environment, using vagrant package command:

    http://docs.vagrantup.com/v2/cli/package.html

    Then copy the box to the other pc, add it using vagrant box add and run it using vagrant up as usual.

    Keep in mind that files in your working directory (the one with the Vagrantfile) are shared when the virtual machine boots, so you need to copy it to the other pc as well.

    2. The clean way

    Theoretically it should never be necessary to do export/import with Vagrant. If you have the foresight to use provisioning for configuring the virtual environment (chef, puppet, ansible), and a version control system like git for your working directory, copying an environment would be at this point simple as running:

    git clone 
    vagrant up
    

提交回复
热议问题