Using virtual machine orchestrator tools in software development brings many advantages but doesn’t come without potential errors. In this article we cover some pros and cons of Vagrant and Docker and go through how to solve the occasional Your VM has become ”inaccessible” -error that you get time to time when using Vagrant and Oracle Virtualbox.
At PHZ Full Stack we have hundreds of internal and customer projects and always use either Docker or Vagrant for our development environments to make management of different programming language versions feasible and easy for developers. For example when we are working on a half dozen customer projects which all have micro-service architectures consisting of ten or so sub-projects written in all possible languages such as Java, Node.js, Clojure, Python, PHP and Ruby on Rails, finding and installing the right combinations of frameworks and versions on the host machine without virtualization would be a nightmare.
Vagrant vs. Docker
Vagrant is a virtual machine orchestrator tool which very handy for managing development environments. The benefits of Vagrant over Docker include that Vagrant can actually run also Docker containers in addition of twenty or so other virtualization platforms while docker-compose can manage only Docker containers. Vagrant with Virtualbox also runs real virtualization making it possible to virtualize Windows, Mac, Linux, and BSD machines while Docker can run only Linux containers.
Other than that, all orchestrator tools perform essentially the same task so it is only a matter of opinion and prior experience which tool to use. In my personal opinion, Vagrant with Virtualbox is the easiest environment for development environments but Oracle Virtualbox is too unstable and low performance to be used in production. However, if you pay for VMWare licenses, you will get performance and stability at a cost.
While Docker has received popularity recently, after hundreds of projects and tens of thousands of failed image builds, I find it to be absolutely great for production environments for performance and security points of view (it’s a ”chroot on steroids”).
On the other hand, Docker is nightmarish for new developers, a difficult beast to master and ill-suited for development environments due to it’s not-so-obvious technical solutions and aggressive caching. It will either make using it in development a very long trip into learning Docker internals or once you master it, you anyway have the problem of Docker cache clearing slowing down your development cycle so much that you end up not using Docker at all.
”Your VM has become inaccessible”
Rarely, however, you will get ”Your VM has become inaccessible” -error, when you run any Vagrant command on your box, such as vagrant status. You can’t even clean the environment by running vagrant destroy -f and recreate the box. You are basically stuck.
vagrant status
Current machine states:default inaccessible (virtualbox)
The VM is inaccessible! This is a rare case which means that VirtualBox can’t find your VM configuration. This usually happens when upgrading VirtualBox, moving to a new computer, etc. Please consult VirtualBox for how to handle this issue.
How to solve the problem?
At PHZ Full Stack we have developed a one-liner to solve the problem. It was documented on our internal Wiki for years but to promote our core values of Skill and Teamwork together with Knowledge Sharing principles, everybody is better of if this information is made public and linked also on Stack Overflow and Google index.
The following command will first list all virtual machines and then pipe (forward) the output for grep-command for filtering the boxes that are on status ”inaccessible”. The cut-command will split the line by space and take the 2nd entry. After this two more cuts are done by { and } characters to find the virtual machine box id. The xargs-command is then run to execute VBoxManage unregistervm -command and passing the id of the box as argument.
VBoxManage list vms |grep inaccessible |cut -d " " -f 2 | cut -d "{" -f 2 |cut -d "}" -f 1 |xargs -I{} VBoxManage unregistervm {}
Alternatively you can also run the commands manually and use clipboard with copy & paste.
VBoxManage list vms
”” {0656ce02-a274-4cf2-b576-4911a64f2060}
VBoxManage unregistervm 0656ce02-a274-4cf2-b576-4911a64f2060
Knowledge Management makes knowledge visible
Knowledge management is a process to transform the (silent) tacit knowledge to explicit knowledge (visible). In other words the information and knowledge held by PHZ Full Stack Senior Developers should be transferred to other developers by using practices such as Pair Programming but in addition the technical knowledge should be written down to systems like Wiki. We are using MediaWiki for our internal records but if there is no confidential information involved, the piece of knowledge should be made public and shared as broadly as possible. The benefit of this practice is in addition of making solving the problem much easier next time, if you can easily google for the answer and find it on Stack Overflow, but to also promote the personal and company prestige as experts to increase salaries and value we bring to our customers.