How to copy a vagrant image to another machine

Author:
Email: jonas.pfannschmidt at gmail.com
Date: 29/10/2015

Introduction

Copying a vagrant image to another machine can be tricky and you usually shouldn't do that at all. The whole point of vagrant is to reproducible create and provision VMs from only the Vagrantfile.

If for whatever reason you need to do it anyway, here are the steps (Main source: http://stackoverflow.com/questions/19094024/is-there-any-way-to-clone-a-vagrant-box-that-is-already-installed)

Step by step

  1. Copy the ssh key from ~/.vagrant.d/insecure_private_key and append it to the same file on the other machine. This is necessary to be able to log into the VM later.
  2. Check the VM name: VBoxManage list vms
  3. Package the vagrant VM: vagrant package --base vm-name --output /path/to/mybox.box
  4. Copy the *.box file and the Vagrantfile to the other machine
  5. Modify the Vagrantfile: config.vm.box_url= "/path/to/mybox.box"
  6. Run the VM: vagrant up

Note: The VM will be restarted during this process. You'll loose anything ephemeral!