Exporting boxes.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 16 Dec 2018 22:37:48 +0200
changeset 2301 a99f277a9eae
parent 2300 e538e158c38b
child 2302 f47dd29b4e06
Exporting boxes.
vagrant.rst
--- a/vagrant.rst	Fri Dec 14 21:33:27 2018 +0200
+++ b/vagrant.rst	Sun Dec 16 22:37:48 2018 +0200
@@ -45,11 +45,12 @@
 Managing boxes
 ==============
 
-Adding new box from catalog::
+Store new box from catalog locally::
 
   $ vagrant box add ubuntu/trusty64
+  $ vagrant box add --provider virtualbox hashicorp/precise64
 
-Checking for box updates::
+Check for box updates::
 
   $ cd $BOXDIR
   $ vagrant box outdated
@@ -89,6 +90,39 @@
 https://www.vagrantup.com/docs/boxes/versioning.html
   Box Versioning.
 
+Exporting boxes
+===============
+
+Any VirtualBox VM can be packages as Vagrant box. Find VM name or UUID with::
+
+  $ VBoxManage list vms
+
+Pass it to one of::
+
+  $ vagrant package --base $VM_NAME
+  $ vagrant package --base $VM_UUID
+  $ vagrant package --base $VM_NAME --output my.box
+  $ vagrant package --base $VM_UUID --output my.box
+
+If you are in Vagrant managed directory (with ``.vagrant`` subdirectory) it is as simple as::
+
+  $ vagrant package
+
+.. note:: Only one VM is packages even if Vagrant file defines several VMs.
+
+Import packages box::
+
+  $ vagrant box add --name $NAME /path/to/new.box
+  ...
+  $ vagrant init $NAME
+  ...
+  $ vagrant up
+
+https://www.vagrantup.com/docs/boxes/base.html
+  Create own vagrant image.
+https://www.vagrantup.com/docs/cli/package.html
+  ``package`` command.
+
 Managing plugins
 ================