Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

This project enables the containerization of a Drupal project for use as a standalone Docker/Podman container, a Docker Compose/Swarm setup, or on Kubernetes.

It is designed for use in remote/production environments. For local development, there're already great solutions out there.

There are also several Dockerfile alternatives for production usage (1, 2, 3). In our opinion, these alternatives are complex, highly opinionated, not suited for usage out-of-the-box or lack some of the features we provide here.

Features

  • Apache + mod_php based.
  • Debian-based.
  • Full project codebase included in the resulting image.
  • Maximum flexibility: we try to not hardcode configuration.
  • Allow to specify APT packages to install.
  • Allow to specify PHP version and extensions to install in addition to Drupal required ones.
  • PHP configuration is managed via environment variables. It is recommented to install drupal/settingsphp in order to manage also Drupal settings via environment variables.

What is included

  • Dockerfile.
  • .env.example.
  • System configuration files.
  • Example Docker Compose files for local testing.

Installation

Recommended method is to use composer, since it is the same process as any other Drupal package, and allows to get updates and perform customizations with patches.

composer require drupal/dockerize
rsync -av vendor/drupal/dockerize/dist/ .
git add .dockerignore docker/

Alternatively you could just copy the contents of dist/ subdirectory from this repository over your Drupal project and commit files.

Usage

Composer patches and other custom files

The Dockerfile copies assets/ subdirectory into the image. It is advised to place composer patches at assets/patches/ and any other custom files such as translations in a subdirectory of assets/.

Build options

Available build arguments:

  • GIT_COMMIT. SHA of the git commit related to this build.
  • PHP_VERSION. Defaults to 8.4.
  • PHP_DEFAULT_EXTENSIONS. Default set of extensions to install. See Dockerfile for details. You can redefine it and exclude extensions.
  • PHP_EXTRA_EXTENSIONS. Set of extensions to install in addition to the default ones. Accepts a list such as bcmath,redis,zip.
  • PHP_ENVIRONMENT. Accepted values: production or development. It indicates which upstream php.ini file to use. Defaults to production.
  • APT_DEFAULT_PACKAGES. Default set of system packages to install. See Dockerfile for details. You can redefine it and exclude packages.
  • APT_EXTRA_PACKAGES. Extra set of packages to install in addition to the default ones. Accepts a list such as curl,jq.

Example

docker build --build-arg GIT_COMMIT=$(git rev-parse HEAD)  --build-arg PHP_EXTRA_EXTENSIONS="bcmath,redis,zip" --build-arg APT_EXTRA_PACKAGES="curl,jq" . -f docker/Dockerfile -t mydrupalsite-web

Manually build and push to a Docker registry

docker build . -f docker/Dockerfile -t registry.example.com/drupal:latest
docker push registry.example.com/drupal:latest

Local testing with docker compose

Copy and adjust .env as needed:

cp docker/.env.example docker/.env

Build, launch and install:

export GIT_COMMIT=$(git rev-parse HEAD)
docker compose -f docker/compose.yml -f docker/compose.local.yml build
docker compose -f docker/compose.yml -f docker/compose.local.yml up
docker compose -f docker/compose.yml -f docker/compose.local.yml exec drupal drush site:install --existing-config --account-pass=admin -y

Visit: http://localhost:8080

Gitlab CI

Basic example based on Auto DevOps.

include:
  - template: Jobs/Build.gitlab-ci.yml

stages:
  - build

build:
  variables:
    DOCKERFILE_PATH: docker/Dockerfile
    AUTO_DEVOPS_BUILD_IMAGE_EXTRA_ARGS: >-
      --build-arg GIT_COMMIT=$CI_COMMIT_SHA
      --build-arg APT_EXTRA_PACKAGES=curl,jq
      --build-arg PHP_EXTRA_EXTENSIONS=bcmath,redis,zip

GitHub Actions

#TODO#

Activity

Total releases
5
First release
May 2025
Latest release
6 months ago
Release cadence
34 days
Stability
60% stable

Release Timeline

Releases

Version Type Release date
1.1.0 Stable Oct 12, 2025
1.1.x-dev Dev Oct 12, 2025
1.0.1 Stable Sep 12, 2025
1.0.0 Stable Aug 5, 2025
1.0.x-dev Dev May 28, 2025