docker.recipes

Drupal

intermediate

Enterprise-grade CMS for complex websites and applications.

Overview

Drupal is an enterprise-grade content management system (CMS) built on PHP that has powered millions of websites since 2001. Known for its flexibility, security, and scalability, Drupal excels at managing complex content structures with advanced user permissions, multilingual capabilities, and extensive customization options. Unlike simpler CMS platforms, Drupal is designed for organizations that need sophisticated content workflows, enterprise integrations, and the ability to handle high-traffic applications with complex data relationships. This stack combines Drupal 10 with PostgreSQL 16 to create a robust content management platform optimized for enterprise requirements. PostgreSQL's ACID compliance and advanced querying capabilities complement Drupal's complex content modeling needs, providing superior data integrity compared to MySQL setups. The combination excels at handling structured content with relationships, supporting Drupal's entity system and field API while delivering the performance needed for high-traffic sites with complex queries. This configuration is ideal for organizations building sophisticated web applications, corporate intranets, educational platforms, or government websites that require enterprise-level security, scalability, and content management features. The PostgreSQL backend provides the reliability and performance needed for Drupal's advanced features like Views, Entity API, and custom content types, making it perfect for developers who need to build complex, data-driven websites with professional-grade infrastructure.

Key Features

  • Drupal 10 with modern Symfony-based architecture and Twig templating engine
  • PostgreSQL 16 with JSON/JSONB support for Drupal's configuration and field storage
  • Apache web server with mod_rewrite enabled for clean URLs and .htaccess support
  • Persistent volumes for modules, themes, profiles, and sites directories to survive container updates
  • Entity-relationship modeling with PostgreSQL's advanced constraint and indexing capabilities
  • Full-text search integration using PostgreSQL's built-in search features with Drupal's Search API
  • Composer-ready environment for installing Drupal modules and themes via Packagist
  • Database connection pooling and transaction support optimized for Drupal's entity system

Common Use Cases

  • 1Corporate websites with complex content hierarchies and multiple content types
  • 2Educational institutions requiring multilingual content and user role management
  • 3Government portals with strict accessibility and security compliance requirements
  • 4Publishing platforms with editorial workflows and content scheduling
  • 5E-commerce sites using Drupal Commerce with complex product catalogs
  • 6Community portals with user-generated content and social features
  • 7Intranet applications with document management and employee directories

Prerequisites

  • Minimum 2GB RAM recommended for Drupal and PostgreSQL combined workload
  • Basic understanding of PHP, Drupal architecture, and content management concepts
  • Familiarity with Drupal's admin interface and module/theme management
  • Port 8080 available for web access to the Drupal installation
  • Environment variable POSTGRES_PASSWORD configured in .env file
  • Understanding of PostgreSQL connection parameters for Drupal database configuration

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 drupal:
3 image: drupal:10-apache
4 container_name: drupal
5 restart: unless-stopped
6 volumes:
7 - drupal_modules:/var/www/html/modules
8 - drupal_profiles:/var/www/html/profiles
9 - drupal_themes:/var/www/html/themes
10 - drupal_sites:/var/www/html/sites
11 ports:
12 - "8080:80"
13 depends_on:
14 - postgres
15 networks:
16 - drupal-network
17
18 postgres:
19 image: postgres:16-alpine
20 container_name: drupal-postgres
21 environment:
22 POSTGRES_DB: drupal
23 POSTGRES_USER: drupal
24 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
25 volumes:
26 - postgres_data:/var/lib/postgresql/data
27 networks:
28 - drupal-network
29
30volumes:
31 drupal_modules:
32 drupal_profiles:
33 drupal_themes:
34 drupal_sites:
35 postgres_data:
36
37networks:
38 drupal-network:
39 driver: bridge

.env Template

.env
1POSTGRES_PASSWORD=changeme

Usage Notes

  1. 1Docs: https://www.drupal.org/docs
  2. 2Access at http://localhost:8080 - complete installation wizard
  3. 3Database host: postgres, database: drupal, user: drupal
  4. 4Install Drush CLI: composer require drush/drush
  5. 5Modules/themes persist in mounted volumes across updates
  6. 6Strong ecosystem for enterprise sites, multilingual, accessibility

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

drupal
drupal:
  image: drupal:10-apache
  container_name: drupal
  restart: unless-stopped
  volumes:
    - drupal_modules:/var/www/html/modules
    - drupal_profiles:/var/www/html/profiles
    - drupal_themes:/var/www/html/themes
    - drupal_sites:/var/www/html/sites
  ports:
    - "8080:80"
  depends_on:
    - postgres
  networks:
    - drupal-network
postgres
postgres:
  image: postgres:16-alpine
  container_name: drupal-postgres
  environment:
    POSTGRES_DB: drupal
    POSTGRES_USER: drupal
    POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
  volumes:
    - postgres_data:/var/lib/postgresql/data
  networks:
    - drupal-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 drupal:
5 image: drupal:10-apache
6 container_name: drupal
7 restart: unless-stopped
8 volumes:
9 - drupal_modules:/var/www/html/modules
10 - drupal_profiles:/var/www/html/profiles
11 - drupal_themes:/var/www/html/themes
12 - drupal_sites:/var/www/html/sites
13 ports:
14 - "8080:80"
15 depends_on:
16 - postgres
17 networks:
18 - drupal-network
19
20 postgres:
21 image: postgres:16-alpine
22 container_name: drupal-postgres
23 environment:
24 POSTGRES_DB: drupal
25 POSTGRES_USER: drupal
26 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
27 volumes:
28 - postgres_data:/var/lib/postgresql/data
29 networks:
30 - drupal-network
31
32volumes:
33 drupal_modules:
34 drupal_profiles:
35 drupal_themes:
36 drupal_sites:
37 postgres_data:
38
39networks:
40 drupal-network:
41 driver: bridge
42EOF
43
44# 2. Create the .env file
45cat > .env << 'EOF'
46POSTGRES_PASSWORD=changeme
47EOF
48
49# 3. Start the services
50docker compose up -d
51
52# 4. View logs
53docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/drupal/run | bash

Troubleshooting

  • Database connection failed during installation: Verify postgres container is running and use 'postgres' as database host, not 'localhost'
  • Permission denied errors on file uploads: Check that www-data user has write permissions to sites/default/files directory
  • Memory limit exceeded errors: Increase PHP memory_limit in custom php.ini or switch to drupal:10-fpm-alpine for better memory management
  • Clean URLs not working: Ensure Apache mod_rewrite is enabled and .htaccess files are being processed
  • Drupal installation stalls at database setup: Increase PHP max_execution_time and ensure PostgreSQL has sufficient shared_buffers allocated
  • Module installation fails: Mount a custom sites/default/settings.php with proper database credentials and trusted host patterns configured

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Components

drupalpostgres

Tags

#drupal#cms#enterprise#php

Category

CMS & Blogging
Ad Space