I apologize in advance if this starts a religious war – that is not my intent. But I have been thinking hard about Docker versus Vagrant for building development environments. I wanted to share my current thinking and welcome constructive feedback. (And if you found this article at random on the web, the following discussion is oriented around Magento development.)
Why does it matter?
There are a multiple efforts by different people on development environments for Magento 2. Mark Shust immediately comes to mind on the Docker side, Joshua Warren has MageScotch on the Vagrant side, I would of course be remiss to not mention the Vagrant box used by a number of internal Magento developers, and there are lots more (feel free if you develop one to drop a link in the comments). It’s a great community, and I am sure there will be more out there as people work on and refine these images.
But I do get asked “why doesn’t Magento just define a single recommended way to do things”. The point here is not to restrict developers to that one way, but rather for people who just want to get going, is there a recommended path forward so they don’t have to do the evaluation of alternatives themselves.
Why not support both?
The answer may be to support both. But it goes against the “have one recommendation so I don’t have to think” approach.
Why is this sort of Virtualization better than a native environment?
There are a few benefits (and a few negatives).
- It is less work to get going – someone has installed all the tools for you. MAMP, WAMP, XAMP etc are proving to be less effective with M2 because they do not include all the tools needed for modern development. Vagrant boxes / Docker images are filling effectively the same gap, but anyone can build such an environment.
- If you work on multiple projects, you can have tools sets correct per project. (I don’t only mean Magento projects here – I mean any projects.) Sometimes you need a specific version of PHP, MySQL, Memcached, and so on.
- IDEs tend to work better natively.
- Performance of filesystem access has been a problem, which impacts performance during development.
So what do you think Alan?
Right now, Vagrant seems to have the greater mindshare and adoption for development. Roughly twice the people seem to be using Vagrant than Docker for this sort of situation (at least for people I bump into). It is also integrated into PHP Storm better, the most common IDE for Magento developers.
Docker definitely has the greater mindshare in terms of deployment (being used live in production). There are lots of hosting partners with native Docker support. Docker also feels like it has greater momentum and investment. But a good local development environment is not the same as a production environment, so Docker popularity in production does not make it more important for local development.
I am very interested in is the upcoming Docker release that claims to have eliminated some of the slowness of filesystem access with full inotify access (for Mac at least – not sure about Windows). https://blog.docker.com/2016/03/docker-for-mac-windows-beta/. The main issue for Windows users is it needs Windows 10, and it won’t be available probably until June 2016.
Regarding installation effort, some people say Vagrant is easier to install. Personally I found the latest version of Docker easier to install (with Docker Toolbox). A single download and it installed all required software for me. Vagrant needed more things installed – I had to find Virtual box, install some extension to it, and then I could start using it.
Today, even though I personally am more of a Docker advocate, it feels like Vagrant still has the edge. (A personal prediction is in 6 months’ time this may no longer be true.) The basis for this is really around PHP Storm integration. It has better built in Vagrant support today. There are articles on running PHP Unit tests with PHP Storm running locally and unit tests running inside the Vagrant box.
So my questions to you, the community
- Do you think Magento should publish an “official” development environment? (My personal answer is “yes”.)
- Do you have concrete reasons why you think Vagrant is not the best option here?
Remember, think about it from the mass of developer’s point of view – what is best for the product, not only for yourself. Personally, I am probably going to keep using Docker more than Vagrant. But my personal reasons I do not think are applicable to the greater developer audience. Vagrant feels like the right choice, at least for the next 6 months.
And yes, the next question is which Vagrant box to use as a basis for standardizing on. But that feels like an easier question – that is just a matter of comparing a few boxes for coverage, seeing if the current owner is happy for Magento to “own” at least a fork of the external project, and so on. That is a much easier question than Docker vs Vagrant.