Trendtopic Docker: What you can do with it and how it is used for Drupal projects within Cocomore

Jose Luis Bellido

A few months ago, maybe a year, Docker became one of the most famous topics between developers DevOps and sysadmins, with a huge number of talks about the advantages of using it in our daily work and in our systems.

At Cocomore we have recently introduced Docker in one of our latest projects, and it was a grateful experience that we’d like to share with you in this article.



Docker? What is Docker?

As we can find on the official website of Docker

“Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.”

So with Docker we can develop images with different applications and reuse them in different projects, running different containers from the same image. The main features of Docker are:

  • Lightweight: All containers running on a single machine share the same operating system kernel, so you can start several of them instantly and the resources of the machine will not notice the difference.
  • IS open: Docker containers are based on open standards, having all major Linux distributions and Microsoft operating systems available.
  • Secure: Containers isolate applications from each other and the underlying infrastructure.


What is the difference from other virtual machines?

It’s true that when using other technologies such as Virtual Box, we have similar resource isolation and allocation benefits, but Docker has a different architectural approach, allowing us to have it more efficient and portable.

What did we want to solve by using Docker in our projects?

With Docker we wanted to be more productive and improve the quality of our projects. Specifically, the improvements that we wanted to do were:

  • Accelerating the developer onboarding, also for external members.
  • Ensuring that everyone on the team works with the same system configuration on different operative systems.
  • Avoiding prior performance problems using other VM.
  • Having reusable images ready for starting new projects.
  • Having a repository with base images and being able to pull them for our projects.


Using Docker for Drupal projects

Our first goal was to develop our Drupal 8 projects within Docker, having a Docker base image for our projects. On the other hand, we wanted to have a Drupal 8 boilerplate for setting up new projects and having them use the same structure.

Our Docker image for Drupal projects

First, we built our custom Docker base image based on Drupal docker container by @wadmiraal. We only had to customize the vhost configuration by editing the Dockerfile. This was needed in order to integrate it with our Drupal 8 project structure and point the vhost to the /htdocs folder. 

So the workflow for building your image is as follows:

  • Once you have defined your image in the dockerfile, you can build your image based on your dockerfile with:

$ docker build -t [YOUR IMAGE NAME]/drupal [PATH TO YOUR DOCKERFILE]

Our Drupal 8 boilerplate

On the other hand, we are developing a Drupal 8 boilerplate, which is available at github and which we use for developing our Drupal 8 projects. Additionally, this boilerplate provides a set of scripts for setting up an initial Drupal instance, resetting it to a given backup or updating it with the latest configuration, database updates, etc.

Running the boilerplate within Docker

The last point is having a Docker container based in our base image and running our new Drupal 8 project inside this container. To do this we only have to follow the next steps:

  • Clone the Drupal 8 boilerplate:

$ git clone new_d8_project

  • Run a new Docker container and bind the Drupal project to it.

$ docker run -d -p 8080:80 --name new-d8-project -v ~/projects/new_d8_project:/var/www/drupal-project -t cocomore/drupal

  • -p: Allows us to forward our local ports (8080) with the apache exposed port by the container (80).
  • -v: Allows us to bind data volume from our local machine to the container. With this, we can edit our project files directly from the local machine and it will be reflected in the Docker container.
  • -t: The name of the Docker image from which we’ll run the new instance.

  • Install your new Drupal project:

$ docker exec -i new-d8-project ./var/www/drupal-project/scripts/

With those 3 steps we’ll have our new project installation running and you’ll have it available at 


Next Steps:

We don’t have a stable version of our boilerplate ready, but we will have it soon. Below are our ideas for continuing this project.

  • Specifying a basic profile for the cocomore_profile with some basic modules and configurations. Currently we are using the same configuration as the standard profile.
  • Using composer instead of drush make for building the contrib dependencies.
  • Providing drush aliases for working with the different environments (local, staging...).
  • Having Behat tests for a functional test coverage.
  • Publishing a Docker image at Docker Hub, ready to use within the boilerplate.


Other interesting projects

Other interesting projects that aim to user Drupal within Docker are the following:

  • Bowline: This is an interesting project that uses Docker Composer for setting up different Docker Containers and using Drupal Console to install your Drupal instance. It also provides
  • Drupal Project: This project aims to manage all Drupal dependencies using composer instead of drush make. Many contributors are working on this project and it looks awesome.


Documentation links:


Our expert

Jose Luis Bellido

Any questions or input? Reach out to our experts!

Send e-mail

Jose Luis Bellido is part of the Cocomore Team as a Drupal Developer since April 2015. Before, he developed other projects with Drupal for more than three years. Working with Drupal, Jose Luis can do what he loves. His job is finding solutions to customer problems on the technical side.
Jose Luis describes himself with these three words: Enjoying each moment.