Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to properly connect a custom PHP file with Drupal 8 within Docker, all through docker-compose

I have the following docker compose yml file which spins up both my Drupal 8 site, AND volume path for php under my same Visual Studio Code workspace…


version: '3.9'

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

But…Drupal’s configuration page is not connecting to my custom PHP file for modifications.

  • Any attempt I make at renaming the PHP file has failed to solve anything. I am using the path that PHP info() page is saying it checks.
  • My workspace path php/php.ini does exist on the root, with a modified value for post_max_size, but no change is reflected in Drupal.
  • I have read the original hub source https://hub.docker.com/_/drupal/, but nothing is noted on attaching a custom php.ini file.

What would be a protentional reason for the disconnect between my custom php.ini file and Drupal?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are launching two separate containers, with separate file systems. The php container you are launching has nothing to do with the php running in your drupal container.

Try adding the following to your drupal container service definition

volumes:
  - ./php/php.ini:/usr/local/etc/php/conf.d/my.ini
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading