Saving and sharing changes made to Vagrant box

2019-03-10 03:19发布

问题:

I setup an Ubuntu 13.04 box from www.vagrantbox.es. Post that I made changes to the box - installed ruby, rails, git, mysql, ngnix, etc. How do I share the modified box with someone else?

回答1:

After making your changes, use vagrant package in the directory with the Vagrantfile. It will shut the machine down and start saving it to a file.

You'll end up with a boxfile in that directory that you can share.



回答2:

As already answered, vagrant package creates a new base box out of an existing VM.

Anyway "the Vagrant way" is to use and share a Vagrantfile with provisioners. This way the installation of the software is repeatable. The downside is that initial vagrant up takes longer while it installs all the software, but on the other hand the shared base box is smaller. Depends on your use case what is the best.

If you choose to share a pre-installed image you can still benefit from automated provisioning using e.g. Packer to build the box.



标签: vagrant