samos123 / docker-drupal

Drupal image based official php image, database information should be passed by environment variables or linked container. Drush is included
35 stars 11 forks source link

Drupal image without database

This image contains the latest stable Drupal 7-release. It will automatically setup the database and install a default site.

The image doesn't contain a database so you have to create a seperate database container (which is no effort if you use the provided configuration for docker-compose) and link this container or pass the database information of a MySQL- or Postgres-host.

Why create another Drupal image?

Many of the other Drupal images got a database baked in or didn't install Drupal automatically and didn't offer much flexibility. This image can be easily be used as base image for your own Drupal images see below Customization by using Dockerfiles. At the same time you can just use this image for a vanilla Drupal-experience that can be fully administered and extended via the web-interface as well as with drush on the command-line.

Usage

If you want to launch a bare Drupal image with a MySQL backend you can do so:

docker run -d -e MYSQL_ROOT_PASSWORD="test123" --name db mysql
docker run -d --link db:mysql -p 80:80 samos123/drupal

Alternatively you can use Docker-Compose in a directory that contains the provided docker-compose.yml:

docker-compose up

This will launch a new drupal site with a default theme and no additional modules. If you want custom modules, see Customization.

As customizations and uploads are stored you must take care of these directories if you want to keep these:

As these folders are defined as volumes in the sample docker-compose.yml, you can easily update your container to use the latest image while preserving any modifications with:

docker-compose pull && docker-compose up -d

Database options

You can use a linked database-container with the alias mysql or postgres as shown above - Drupal will be automatically configured to it. Or you use an external database-host. Therefore pass the following environment variables to your container:

Postgres

You can alternatively use a Postgres container. The configuration is very similar to that of MySQL as seen in the docker-compose.yml file, with a couple small changes.

There is an example docker-compose.yml available in the examples folder.

Other options

Customization

To create a customized Drupal-image, you can add/modify scripts in a derived image or mount them in your container into these directories: /scripts/setup.d and /scripts/pre-launch.d. Furthermore,

See the folder examples on how to use the Zen-template and the modules_filter-module and build an image containing them.

Drush's system-wide configuration (/etc/drushrc.php) sets its default- behaviour to be verbose (-v) and affirmative (--yes) in order to grant easy and elaborated usage of scripts. If you want to change that behaviour in an interactive environment or for certain sites (e.g. `docker exec -ti

/bin/bash`), change it in an [overriding `drushrc.php`-location](https://raw.githubusercontent.com/drush-ops/drush/master/examples/example.drushrc.php). See the [documentation of php:apache](https://github.com/docker-library/php/) on the usage of `docker-php-ext-configure` and `docker-php-ext-install` to install PHP extensions. ## Credits Authors of image: Sam Stoelinga, Frank Sachsenheim, Eric Rasche Source code: [https://github.com/samos123/docker-drupal](https://github.com/samos123/docker-drupal) Registry url: [https://registry.hub.docker.com/u/samos123/drupal/](https://registry.hub.docker.com/u/samos123/drupal/)