Search code examples
dockerdocker-composedockerfile

Installing GMP extention on PHP 7.4 FPM Alpine (Docker)


I'm having troubble installing the gmp extension on my docker image. My docker file looks like:

FROM php:7.4-fpm-alpine 

RUN docker-php-ext-install pdo pdo_mysql gmp

When I run this docker file I get the error:

configure: error: GNU MP Library version 4.2 or greater required.
ERROR: Service 'php' failed to build : The command '/bin/sh -c docker-php-ext-install pdo pdo_mysql gmp' returned a non-zero code: 1

I've tried the solution on this stackoverflow post, however it did not work for me.

Any ideas on how I can resolve this?


Solution

  • Like the error says: configure: error: GNU MP Library version 4.2 or greater required.

    You can install GNU MP (GMP for short) on Alpine Linux by including the following in your Dockerfile:

    RUN apk add gmp-dev
    

    (or RUN apt-get install gmp-dev for other debian distros)