mindthump

Packaging a Vagrant box from existing machine

Jun 29th, 2020 (edited)
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

Prep the base machine

init, up, ssh; apt as needed

Make it small:

Dump the package remnants after install

sudo apt-get clean

For Ubuntu, make a huge zeroed file then remove it so it can compress out:

sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY

Clear bash history and bail out:

cat /dev/null > ~/.bash_history && history -c && exit

Repackage it

vagrant package --output mynew.box

Stash somewhere, like artifactory :)

Add it to the local box store

vagrant box add mynewbox mynew.box

Trash the builder machine

vagrant destroy
rm Vagrantfile

Use the new box

vagrant init mynewbox

Add Comment
Please, Sign In to add comment