Create Custom Drupal Docker Image with REST UI module
Drupal is a content management system (CMS) that allows you create dynamic web sites. It can be somewhat difficult to install because it has a lot of dependencies. Using a docker container to perform the install makes the installation process much easier.
You can use a standard image like drupal:11-apache, but I wanted to include the REST UI module to create a PDF file from Drupal views. I also wanted to include Composer, which can be useful when you try to customize Drupal. This post will show how to create a custom image and use it in your Drupal docker-compose file.
Also, see Using Drupal and DITA OT to Create a PDF File for a Drupal use case that uses the REST UI module.
Create Custom Image
To create your own image that includes Composer and the REST UI module, perform the steps below:
- Create Dockerfile:
FROM drupal:latest
# Install Composer
COPY --from=composer/composer:latest-bin /composer /usr/local/bin/composer
# Install REST UI module
RUN composer require drupal/restui
ENV DRUSH_VERSION 8.4.9
RUN curl -L --silent https://github.com/drush-ops/drush/releases/download/${DRUSH_VERSION}/drush.phar \
> /usr/local/bin/drush && chmod +x /usr/local/bin/drush- Build the docker image with the following command:
docker build -t my-drupal:latest .This command will create my-drupal:latest docker image.
Run Custom Drupal Docker Container using Docker Compose
Create Docker-compose.yml:
# Database username: postgres
# Database password: example
# ADVANCED OPTIONS; Database host: postgres
#
version: '3.1'
services:
drupal:
image: my-drupal:latest
ports:
- 8080:80
volumes:
- modules:/var/www/html/modules
- profiles:/var/www/html/profiles
- themes:/var/www/html/themes
# this takes advantage of the feature in Docker that a new anonymous
# volume (which is what we're creating here) will be initialized with the
# existing content of the image at the same location
- sites:/var/www/html/sites
restart: none
postgres:
image: postgres:16
environment:
POSTGRES_PASSWORD: example
restart: none
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
modules:
profiles:
themes:
sites:
pgdata:NOTE: my-drupal: latest is used as the Drupal image.
Get Eric S’s stories in your inbox
Join Medium for free to get updates from this writer.
Run the following command to start the custom Drupal Docker container:
docker compose up -dThe following are some useful tips that will help with the install of Drupal:
- Use
PostgreSQlas the database type. - Use
postgresas the database name. - Use
postgresas the database user name. - Use
exampleas the database password. - Use
postgresas the host. - Use
5432as the port number.
Originally published at http://hypot2noose.blogspot.com on April 9, 2026.








