By now, you probably have heard many great things about Docker's approach to DevOps. I first looked into Docker in 2015, when I was mentoring a GSoC project, and the project had a need to open new Drupal 8 sandbox very often. Since then I have been pushing updates to the official Docker Drupal library.
Docker or the approach Containerization, in my opinion, is like Drupal. It makes DevOps like building legos. My use cases are below:
- Quickly create a new sandbox for testing. It only takes two commands (including downloads and configurations) in a few seconds to create a new site on local computer or on a public server. See this tutorial.
- Front-end development has become complex with development tools dependency. But, with Docker, we can put designers or front-end developers back to their focus. See example, one command to get everything for Zen 7.x-6.x Style-guide Driven Development or Polymer development tool kit
- Basing on the official Docker Drupal library, we created a version for development. The purpose is that the development version inherits the official library but includes all the dev tools, so developers use dev container, while the deployment team always knows they will deploy the exactly same system-requirements container as the developers use. Plus, the dev version has Xdebug Remote debugging enabled as default; all those took to set up was one command.
- Sometimes, I tech Drupal to students at universities. I used to ask my students to make a full backup before class, and prepare to install Ubuntu on day one. But, now, no matter they use Windows, MacOS or Linux. I send them to the same tutorial and ask them to build a first simple Drupal site in 30 minutes.
- We built our own muti-site hosting with run-time PHP separation. Diagram demonstration here.
- Some projects have multiple Drupal sites or other web projects, they do communicate with each other (Our recent example was this Drupal Commerce on Drupal 8 to Magento stock synchronization). With the tools above, we can create dev environments the same way before, and two extra commands to network them together. Xdebuging them at the same time with different PHP versions or dependencies is just as easy as typing a new URL on the address bar.
- At the end of the work, you always know, you can completely shut down your dev environments or delete them. There will be no hidden wasted resources left, including CPU or Disk space.
A few things to keep in mind about the official Docker Drupal library
- There are many contributed Docker libraries for Drupal on the web. With the official library, you need at least two commands to build a Drupal site, one command is for creating a database, the other is for installing Drupal and all supporting software (except database). Some contributed libraries even made one command to achieve this. However, one-command approach is more like a Virtual Machine approach, which puts everything into one box and ready to use. Although, there is nothing wrong with this approach, this approach won't allow your DevOps experience like lego building. Docker's value is more than a faster VM.
- The official Docker Drupal library follows closely to the official Drupal installation documentation. This allows the docker library always follow the Drupal requirements and best practice.
- The official library is not trying to be one solution for all. In fact, this image doesn't contain most PHP libraries for contributed modules. However, this library tries to be the base building block for all Drupal sites. Here is one example: Commerce on Drupal 8 distribution library and its developer version built on top of the official library
- This library is open sourced here. Constructive critique is welcome!