Looking for a A custom Drupal Setup with Docker Compose

I found the official docker compose version of Drupal on the official Docker Hub site - Docker Hub

I was able to get it up and see Drupal on my local development environment. But how can I take this further and apply a custom PHP.ini file to the process so that I can customize PHP commands for the given Drupal environment in my container? What could the Docker Compose “potentially” look like in this case?

Thanks for teaching me in my Journey


The easy way would be to simply mount a local copy of php.ini, into the container (using -v / volumes )

Else since drupal i using php base image ( drupal/Dockerfile at 5236af81c31caa5f66f6779dd2a5d0f55d834da6 · docker-library/drupal · GitHub)

you could try and follow the php repo guide on how to add configurations ( Docker Hub)

This image ships with the default php.ini-development and php.ini-production configuration files.

It is strongly recommended to use the production config for images used in production environments!

The default config can be customized by copying configuration files into the $PHP_INI_DIR/conf.d/ directory.

So just to be on the same page as what you said initially with mounting a local copy, in theory the following example below should be good enough…correct?

    image: app_image
      - ./php.ini:/etc/php7/php.ini

Hi again.

I think you should try and mount it to this directory instead: /usr/local/etc/php/conf.d

  - ./php.ini:/usr/local/etc/php/conf.d/my.ini

Then it will overwrite with the values you define, but keeping the rest

@Terpz, thanks for baring with me up to this point. I was successful in spinning up Drupal and a volume location for PHP, but for some reason Drupal is not recognizing my .ini file or code inside of it. Based on my docker compose below, would there by anything I could try to do differently to get my custom PHP file in my volume, to talk to Drupal?

version: '3.9'

  # don't need db or phpmyadmin loaded here because its already running on the network
  # find the site location at http://docker.drupalphp:17223
    image: drupal:8-apache
      - '17223:80'
      - ./sb01/sites:/var/www/html/sites'
      - ./sb01/mods:/var/www/html/modules'
      - ./sb01/prof:/var/www/html/profiles'
      - ./sb01/themes:/var/www/html/themes'
      - mysql_data
    restart: always
     - wpsite
    image: php:7.4-apache
      - '9000:80'
      - ./php/php.ini:/usr/local/etc/php/conf.d/my.ini
     - wpsite
    external: true

My folder structure


My code inside of php.ini

display_errors = On
#display_startup_errors = Off
#error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors = On
upload_max_filesize = 9M
post_max_size = 17M

Yet, when I go to the PHP info() page within the configuration section of Drupal, there is no change for post_max_size being 8M.

Where should I improve my code to make a connection…

I got it solved. The Drupal image already contains PHP. Instead of adding a separate PHP service, I had to mount my custom php.ini to my drupal service.

Thanks again!

Yes, i was unaware that you had 2 containers :slight_smile:

Glad it worked out