Creating a Drupal 8 dev or test environment with Docker

Drupal and Docker logos

This video tutorial supposes Docker already installed, and shows how to create two containers, one for MySql, one for Drupal 8, link both and configure the Drupal 8 install.

To install Docker, follow the instructions written here: https://www.docker.com/community-edition

 

 

Here are the commands typed in the movie:

Here is the docker command to launch a MySQL 5.7 container, name it "drupaltutorialmysql", set a few environment variables, expose the MySQL port 3306 as 3308 on the local host and daemonise it:

docker run   \
  --name drupaltutorialmysql   \
  -e MYSQL_ROOT_PASSWORD=my-secret-pw   \
  -e MYSQL_DATABASE=drupalTutorial   \
  -e MYSQL_USER=DrupalWebSite   \
  -e MYSQL_PASSWORD=DrupalDemoPass   \
  -p 3308:3306   \
  -d   \
  mysql:5.7


Here is the docker command to launch Drupal 8 in a "drupaltutorial" container, link it to the previous container's MySQL port, expose it's web port 80 as 8010 on the local host and daemonise it:

docker run   \
  --name drupaltutorial   \
  --link drupaltutorialmysql:mysql   \
  -p 8010:80   \
  -d   \
  drupal:8

To run a Drupal 7 instance instead, just replace drupal:8 with drupal:7