如何从docker-compose文件中启用php模块?

时间:2019-11-26 17:00:14

标签: php docker docker-compose

我正在尝试加载PHP日历模块,但出现了一些问题。我尝试了2种方法,但似乎都没有用。

首先是将模块添加到外部Dockerfile-alternate中,但是Dockerfile似乎根本没有加载。

第二个是使用自定义php.ini文件加载该文件(此文件实际上是在加载,因为如果不加载SESSION则无法使用。)在我的php.ini文件中,我添加了extension=calendar.so也是如此。

docker-compose.yml

services:
  php:
    depends_on:
      - mysql
    build:
      context: ./php
      dockerfile: Dockerfile-alternate
      args:
        PHP_VERSION: ${PHP_VERSION}
    ports:
      - "8000:80"
    volumes:
      - ${PROJECT_ROOT}/:/var/www/html/
      - ./config/php.ini:/usr/local/etc/php/conf.d/php.ini
    container_name: php

/ php / Dockerfile-alternate

FROM php:7.2.8-apache

COPY . var/www/html
COPY ./000-apache.conf /etc/apache2/others/000-default.conf

RUN chown -R www-data:www-data var/www/html \
    && a2enmod rewrite

# Comment
RUN echo 'testing' //I do not see this comment. 

RUN docker-php-ext-install mysqli pdo pdo_mysql calendar

任何帮助将不胜感激。

更新 得到这些错误。

php           | PHP Warning:  Module 'pdo_mysql' already loaded in Unknown on line 0
php           | PHP Warning:  PHP Startup: Unable to load dynamic library 'php_pdo_mysql.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/php_pdo_mysql.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/php_pdo_mysql.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/php_pdo_mysql.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/php_pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php           | PHP Warning:  PHP Startup: Unable to load dynamic library 'calendar.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/calendar.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/calendar.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/calendar.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/calendar.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

1 个答案:

答案 0 :(得分:0)

使其正常运行,如果有人遇到此问题,这可能会有所帮助

我运行了docker-compose build --no-cache,这使我对正在发生的事情有了更多的了解。我认为真正的问题是它只是从缓存中构建的。