PHP extension unavailable to composer container in docker-compose

Alternatively, you may pass the --ignore-platform-reqs and --no-scripts flags to install or update (as mentioned here).

docker run --rm --interactive --tty \
    --volume $PWD:/app \
    composer install --ignore-platform-reqs --no-scripts

But I always prefer installing composer in my php container.


You are installing the modules in your php service, but not in your composer service.

When composer runs, the php installation in its container doesn't have those modules installed.

You could install composer in your php container, and run it from there.

You could do it by simply adding:

# latest composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

In your php dockerfile, right after your RUN line.

That would require you removing your composer container completely, and run composer directly within the PHP container.

You can also simply run composer and tell it not to check for platform requirements:

docker run --rm --interactive --tty \
    --volume $PWD:/var/www/html \
    composer install --ignore-platform-reqs 

or if you have a separate composer container, for some reason:

docker-compose run composer install --ignore-platform-reqs