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

Time:02-04

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?

CodePudding user response:

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
  •  Tags:  
  • Related