Below are steps to modify the vagrant image and save it for future use
1. Login to you vagrant machine. Here I am taking example of Ubuntu 16.04
vagrant ssh
2. Remove APT cache
sudo apt-get clean
For Centos you can use
yum clean all
3. Reduce the size of OS
sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY
4. Exit from the VM and create vagrant base box
vagrant package --output mynew.box
Note: You should run the command in same folder where Vagrantfile is located for customized VM
5. Add the mynew.box to vagrant box repository
vagrant box add myubuntu16 mynew.box
6. Verify if box is added
vagrant box list
7. Now you can deploy your customized VM
vagrant init myubuntu16
Comments
Post a Comment