Public | Automated Build

Last pushed: 6 days ago
Short Description
Western Michigan University's image for testing Drupal site projects with Behat.
Full Description

Supported tags and respective Dockerfile links

For more information about this image and its history, please see the westernmichiganuniversity/docker-drupal-behat repository on Bitbucket.

What is included?

This image contains the components needed to install a Drupal site project and test it with Behat, including:

  • PHP 5.6
  • Apache
  • MySQL server
  • Selenium

What is not included?

The image does not include the executables for Drush (to install the site) or Behat (to run the tests) because it assumes that you are managing your project with Composer and have already added these as dependencies. If you created your project using the WMU Drupal project template, then this has already been set up for you.

If you did not use the template, simply run composer require drush/drush and composer require behat/behat to add Drush and Behat to your project. By default, this will place the executables at vendor/bin/drush and vendor/bin/behat in your project directory. If your Composer configuration installs these executables to a different location, however, you can tell the container where to find them by setting the DRUSH environment variable and overriding the container's default runtime command. For example, if your Composer configuration installs these executables in /path/to/my/project/bin, you would run the container like so:

docker run -v /path/to/my/project:/opt/project -e DRUSH=/opt/project/bin/drush westernmichiganuniversity/drupal-behat /opt/project/bin/behat

How to use this image

To test a Drupal site project with Behat:

  1. Map your project directory (containing behat.yml, features/ and the Drupal root directory) into the container as /opt/project.
  2. (optional) Set the DRUPAL_ROOT environment variable to the path of the Drupal root directory. Default is /opt/project/web.
  3. (optional) Set the PROFILE environment variable to the machine name of the Drupal install profile to use to install your site. Default is minimal.

By default, on run, the container executes the command vendor/bin/behat --no-interaction --format=junit --format=pretty in the /opt/project directory. You can override this command by passing a new command as an argument to docker run.


Running with default options

docker run -v /path/to/my/project:/opt/project westernmichiganuniversity/drupal-behat
  • docker run ... westernmichiganuniversity/drupal-behat: Starts a Docker container using this image.
  • -v /path/to/my/project:/opt/project: Maps the /path/to/my/project directory on your local machine into the container as the /opt/project directory.
  • Looks for your site's Drupal root directory in the default location, /opt/project/web (i.e., the /path/to/my/project/web directory on your local machine).
  • Installs your site in the container using the default profile, minimal.
  • Runs all test suites defined in behat.yml.

Running with overridden defaults

docker run -v /path/to/my/project:/opt/project -e DRUPAL_ROOT=mysite -e PROFILE=myprofile westernmichiganuniversity/drupal-behat vendor/bin/behat --no-interaction --format=junit --format=pretty features/example.feature

Overrides the defaults as follows:

  • -e DRUPAL_ROOT=mysite: Looks for your site's Drupal root directory in /opt/project/mysite (i.e., the /path/to/my/project/mysite directory on your local machine).
  • -e PROFILE=myprofile: Installs your site in the container using the myprofile profile (i.e., /path/to/my/project/mysite/profiles/myprofile/myprofile.profile on your local machine).
  • vendor/bin/behat --no-interaction --format=junit --format=pretty features/example.feature: Runs only the tests defined in example.feature (i.e., /path/to/my/project/features/example.feature on your local machine).


  • The ${DRUPAL_ROOT}/sites/default/settings.php file will be ignored by the container. This is meant to prevent the container from attempting to connect to another environment's database (such as the production database) rather than creating a new database inside the container. However, this also means that any custom settings you may have defined in settings.php will not be present in the container's test environment. If such settings are necessary for testing the site, consider moving them to Strongarm or using Composer to patch default.settings.php in your project.
  • The ${DRUPAL_ROOT}/sites/default/files directory will also be ignored, in order to prevent a large volume of files from being copied into the container. If your tests depend on the presence of one or more files having been uploaded to the site, consider including some sample files as fixtures in your test cases and uploading them to the site in a step at the beginning of the test.


License information for the software contained in this image is available from:


This image is supported for use by Western Michigan University web developers on Docker version 17.03.0-ce.

Docker Pull Command

Comments (0)