Forked from Docker4Drupal repository

Repository URL


This project comes to resolve some issues when we need to develop a Drupal site. It’s based on Docker and have some improvements from the docker4drupal project:

  • Easy installation: we provide a set of scripts to install all the requirements to handle te project
  • Improved environment settings: the .env file define almost all the environment variables needed to manage the project
  • Included script for Drupal Installation: the script performs a drupal installation with the default settings
    • Support for choosing the drupal theme to be installed
    • All the basic modules to develop a modern Drupal site in stable state
  • Architecture Best practice included: the “basic installation” includes and configures the integration with:
  • Latest versions: we have included and test the last version of the services and the modules
  • Behat integration
  • Scripts for:
    • Generating the docker images: with these scripts we can create and upload the docker images needed by the project
    • Managing the database dumps and the configuration files
    • Check the drupal status
    • Install only the actual state of the project, not all the steps from the initial development
    • and much more…

Installation For all systems

  • Download the repository, cloning the repo or download the zip from the repository and extract it into aa folder
  • Move into the folder
  • Create a copy of the .env.example to .env cp .env.example .env
  • Edit the .env file to change the variables if needed


We need to install all the following software, with the help of the specific script for each operating system or manually:

  • Docker (at least v19.03.8)
  • docker-compose (at least v1.27.4)
  • composer (v2 recommended)
  • drush (see .env file)
  • git (last version)
  • nodejs (last version)
  • npm (last version)
  • curl (last version)
  • php (al least 7.4 version)
    • extensions needed: curl, gd, mysqli, pdo_mysql, zip, mbstring, xml
    • Review the memory limit, max_execution_time, etc…
  • mysql-client (valid for mariadb version)
  • Look the available ports in docker-compose.yaml

Script Installation for Ubuntu 20.04

use the script:

Script Installation For Centos 8

use the script:

Installation Tips For Windows

  • git bash with the Use Windows default console window setting, not the Use Mintty one

Development environment

.env File

Inside the .env file should be defined the environment variables that defines the installation and the rest of the environments

Copy the .env.example to the .env file, if is not done before

cp .env.example .env

Edit the .env file

Edit the variables for your case if it’s necessary

Drupal first installation


Windows Install Script

With the Gitbash terminal execute: ./

¿What does?

  • ./ // download the drupal defined in the DRUPAL_VERSION variable
  • ./ // create the folders needed
  • docker-compose up -d // start the environment containers
  • sleep 10 // wait for the mysql start process
  • ./ // install drupal and dependencies
  • echo “Enter to http://localhost/” Note: the windows scripts are similar but with _windows postfix

Nginx URL








Complemental ports

  • redis: 6379
  • app-mariadb: 3306
  • php-fpm: 9002
  • matomo: 8082
  • matomo-mariadb: 3308

Include your IP in the configuration

We need to include you server IP intro the drupal_etc/settings-dev.php file, this file will mount into the PHPFPM docker container into the default installation folder. $settings['trusted_host_patterns'] = [ '^localhost$', ]; into $settings['trusted_host_patterns'] = [ '^localhost$', 'server_ip' ];


  • If you have problems to start the containers, and not found the correct images, check if you have the .env file defined. If not copy, the .env.example file to .evn file. And check the variables that defines the docker image versions.
  • If you have problems to start te containers because a mount problem of the settings.php file:
    • delete the drupal/www/site/default/settings.php
    • copy the drupal_etc/settings-dev.php to drupal/www/site/default/settings.php
    • remove the mount point in the app container into the docker-compose.yaml file
    • Try to restart the containers: docker-compose up -d
  • If you need to restart all the environment, DELETING all the data, including the drupal folder, execute the script

Backup Drupal database


Managing the environment

Stop the environment

./docker-compose down

Start the environment

./docker-compose up -d

Creating dev images

To create the dev images we need to execute: ./ Note: Don’t forget to change the .env file with the name of the images and their tags

Upload drupal code

Erase the .gitignore file line that prevents that the drupal folder could be commited and pushed into the repository:





Onboarding a new team member

If you need to deploy a new development environment with a project that is in active development we need to follow the next steps:

  • download the last version of the development branch from your repository
  • Install the requirements: ./
  • Execute the environment: ./
  • If you is installing is a remote/virtual machine server check teh settings-dev.php to include the server ip at the bottom of the file
  • Access to the main URL: http://localhost/ or http://server_ip/


We provide a way to manage BDD test with Behat

Requirements on system

  • php-curl
  • drush on system
    • composer global require drush/drush
    • export PATH=$PATH:$HOME/.composer/vendor/bin
    • or export PATH=$PATH:$HOME/.config/composer/vendor/bin

requirement in the container

  • docker-compose exec app composer require drupal/drupal-extension -d /var/www



show possible steps

./drupal/vendor/bin/behat -dl

Features location

  • ./features
    • home.feature

Production Environment

.env File

Such the development environment, in production, we need to define some variables in the .env file, such as the Docker images for production

BE CAREFUL, this steps overwrite the drupal database in production

Create Docker Production images


SQL import in production

copy the sql dump file into /tmp/drupal-export.sql in the production app container (app-prod)

Launch the production environment


¿What does?

  • Create the production docker images
  • Create the volume directories for production
  • Execute: docker-compose -f docker-compose-prod.yaml up -d
  • Wait 10 seconds
  • Import the sql dump file intro production database

Production Varnish URL


Production Nginx URL


About me

Who is doing this

My name is David Vaquero. I have the following skills:

  • Docker/Kubernetes
  • Drupal/Symfony
  • PHP Rocks


How this is deployed

Actual Architecture Local development environment Requirements Docker Docker Compose Composer Drush PHP IDE Recomendations Provided development code repository Works on develop branch Local database Always branching for new features, releases, issuing, with GitFlow Development/Testing environment Based on development branch on Git repository Gitlab CI/CD integration Mariadb Server: Helm charts: Percona Operator: Memcached/Redis Cache Server: Memcached: Redis: Operator: https://github. [Read More]