Vagrant box update vs apt-get upgrade

2

What advantages does updating/upgrading my vagrant virtual machine with vagrant box update have (if any) over doing a regular sudo apt-get update && sudo apt-get upgrade from within the VM? My guest OS is Ubuntu.

mehmet

Posted 2017-01-06T03:18:59.963

Reputation: 185

Answers

4

When you do vagrant box update all it does is update the local box a Vagrant machine was initially built with. Meaning any already existing Vagrant machines will not be upgraded.

But if you do an update via apt-get within the Ubuntu Vagrant machine, then your already existing machine will be upgraded.

The pluses and minuses depend on usage.

For example, let’s say you do tons of development on one of those boxes and have tons of work on that Vagrant machine that is not easily replicated. In a case like that, upgrading Ubuntu via apt-get is the safest bet since it will assure you that any work you have done on that box after it was built will still be there when the upgrade completes.

The main benefit of vagrant box update is for creating new Vagrant machines. Using the example above, if you know you can replicate your work on that box, then blowing away that Vagrant machine is fine. Cases where you would do something like this would be where you have provisioning scripts in place to configure the Vagrant machine on creation and even if you deploy code to the box from some other place—like a GitHub repository—so your Vagrant machine is just a platform of some type.

In my case, I routinely build, destroy and rebuild Vagrant machines since I build them mainly for deployment and provisioning testing before moving onto a more permanent environment. It let’s me test ideas on server configuration before I make them “live” on a “real” virtual machine or bare metal server.

JakeGould

Posted 2017-01-06T03:18:59.963

Reputation: 38 217

JakeGould: when vagrant tells me that a newer box is available online, I do vagrant box update and that warning goes away. So does that mean it is not doing any good unless I destroy my existing machine and redo it? I was under the impression base OS was replaced keeping my files and configurations via some sort of VM magic :) – mehmet – 2017-01-06T04:10:43.440

@mmatt “So does that mean it is not doing any good unless I destroy my existing machine and redo it?” Exactly. – JakeGould – 2017-01-06T09:31:51.233