Drupal on Docker
Status: Maintained
A Docker Compose starter pack for Drupal 11. A complete development stack — PHP 8.4, Nginx and MySQL 8.4 — that gets a new Drupal project running in minutes, with nothing installed on the host.
The point is that Docker is not a side tool here, it is part of the project. The docker/ directory and docker-compose.yml sit in the repository right next to the Drupal codebase and composer.json, and the image is built from that same project. The environment is therefore versioned by the same git history as the application — it cannot drift from the code meant to run in it, and a single git clone brings you both.
Key features
- Docker inside the repository —
docker/php/Dockerfile,docker/nginx/anddocker-compose.ymlare versioned together with the Drupal codebase; no external configuration, no stack generated off to the side - Three services in
docker-compose.yml: PHP 8.4-FPM, Nginx 1.30 and MySQL 8.4 — ports and credentials in a single.env - Multi-stage PHP image: a development layer with Xdebug, a production layer without it — switched by one
TARGET_ENVvariable - Drupal’s PHP extensions preinstalled: gd (WebP/JPEG/FreeType), intl, opcache, apcu, pdo_mysql, pdo_pgsql, zip, xsl, bcmath, exif
- Composer skeleton for Drupal 11.4 with a relocated
web/docroot, Drush 13, composer-patches and recipe support - Safer defaults: the container runs as
www-datarather than root, with aphp-fpm -thealthcheck; production builds run--no-devwith an optimized autoloader - Code quality out of the box — drupal/coder, PHP_CodeSniffer 4 and PHPUnit 11; Xdebug preconfigured for VS Code
Open source. The code is on GitHub
. After cp .env.default .env and docker compose up -d, Drupal is at http://localhost:1577 — the port is set in .env.