New solution
You need to create a new Dockerfile for a specific service, in this case php :
php/Dockerfile
FROM php:7.1.1-fpm RUN apt -yqq update RUN apt -yqq install libxml2-dev RUN docker-php-ext-install pdo_mysql RUN docker-php-ext-install xml
And then a link to it in your docker-compose.yml , like this:
services: // other services php: build: ./php ports: - "9000:9000" volumes: - .:/dogopic links: - mariadb
Please look at the build parameter - it points to the directory where this new Dockerfile is located.
Old decision
I got around the problem. I realized that I can still run this docker-php-ext-install script using the following command:
docker-compose exec <your-php-container> docker-php-ext-install pdo pdo_mysql mbstring
And because of the convenience, I created this simple batch file to simplify the creation of containers with only one command: ./docker.bat
@ECHO OFF docker-compose build docker-compose exec php docker-php-ext-install pdo pdo_mysql mbstring docker-compose up
Albert221
source share