Docker4Drupal Getting Started

Docker4Drupal is a set of docker containers optimized for Drupal. Use docker-compose.yml file from docker4drupal repository to spin up local environment on Linux, Mac OS X and Windows.

Docker4Drupal is designed to be used for local development, if you're looking for a dev/staging/production solution consistent with Docker4Drupal check out Wodby.

Overview

The Drupal stack consist of the following containers:

Container Versions Service name Image Enabled by default
Nginx 1.10 nginx wodby/drupal-nginx
Drupal 8, 7, 6 php wodby/drupal
PHP 5.3, 5.6, 7.0, 7.1 php wodby/drupal-php
MariaDB 10.1 mariadb wodby/mariadb
Redis 3.2 redis wodby/redis
Varnish 4.1 varnish wodby/drupal-varnish
Solr 5.5, 6.3, 6.4 solr wodby/drupal-solr
Memcached 1.4 memcached wodby/memcached
Mailhog latest mailhog mailhog/mailhog
phpMyAdmin latest pma phpmyadmin/phpmyadmin
Node.js 7 node _/node
Traefik latest traefik _/traefik

Supported Drupal versions: 6, 7, 8.

Requirements

Must know before you start

  1. (!!!) You will lose MariaDB data if you run docker-compose down. Instead use docker-compose stop to stop containers. Alternatively, you can use a manual volume for mariadb data (see compose file), this way your data will always persist
  2. To avoid potential problems with permissions between your host and containers please follow this instructions
  3. For macOS users: Out of box Docker for Mac volumes has poor performance. However there's a workaround based on docker-sync project, read instructions here

Usage

There 2 options how to use docker4drupal – you can either run vanilla Drupal from the image or mount your own Drupal codebase:

1. Run Vanilla Drupal from Image (default)

  1. Download docker-compose.yml file
  2. Optional: update php and nginx images tags if you want to run Drupal 6 or 7 (by default Drupal 8)
  3. Run containers: docker-compose up -d
  4. Wait a few seconds for containers initialization
  5. That's it! Proceed with Drupal installation at http://drupal.docker.localhost:8000. Default database user, password and database name are all drupal, database host is mariadb

2. Mount my Drupal Codebase

  1. Read must know before you start
  2. Download docker-compose.yml file to your Drupal project root
  3. Replace php image from wodby/drupal (PHP + vanilla Drupal) to wodby/drupal-php (just PHP)
  4. Depending on your Drupal version use appropriate tags for php and nginx images
  5. Update nginx and php volumes to - ./:/var/www/html to mount your codebase
  6. Update NGINX_SERVER_ROOT to /var/www/html unless your project is based on composer template
  7. Ensure your settings.php uses the same credentials as mariadb service
  8. Optional: import existing database
  9. Optional: uncomment lines in the compose file to run redis, solr, etc
  10. Optional: configure domains
  11. Run containers: docker-compose up -d
  12. That's it! Your drupal website should be up and running at http://drupal.docker.localhost:8000. If you need to run multiple projects simultaneously see this article

You can stop containers by executing:

docker-compose stop

Feel free to adjust volumes and ports in the compose file for your convenience. Also, read how to access containers and how to get logs

Status

We're actively working on these instructions and containers. More options will be added soon. If you have a feature request or found a bug please submit an issue on GitHub or Wodby Slack join us on Slack

We update containers from time to time by releasing new image tags.

License

This project is licensed under the MIT open source license.