# PHP bcmath extension doesn't get installed in Dockerfile

**URL:** <https://forums.docker.com/t/php-bcmath-extension-doesnt-get-installed-in-dockerfile/99773>\
**Category:** General\
**Tags:** docker, build\
**Created:** [October 18, 2020, 6:49am UTC](https://forums.docker.com/t/php-bcmath-extension-doesnt-get-installed-in-dockerfile/99773 "2020-10-18T06:49:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinzeltin](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/martinzeltin/32/25630_2.png) [@martinzeltin](https://forums.docker.com/u/martinzeltin)\
**Post date:** [October 18, 2020, 6:49am UTC](https://forums.docker.com/t/php-bcmath-extension-doesnt-get-installed-in-dockerfile/99773/1 "2020-10-18T06:49:33Z")

</div>

I have run into a strange problem where bcmath PHP extension doesn’t get installed in Dockerfile but later if I go into my container then I can install it manually. But the problem is if I restart the container all changes are lost.

**My Dockerfile**

```auto
FROM php:7.2-fpm

WORKDIR /var/www

RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    curl

RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
RUN docker-php-ext-install bcmath

EXPOSE 9000
CMD ["php-fpm"]

```

By the output of `php -m` I see that bcmath extension did not get installed.

But I can install it manually like this

```auto
$ docker-compose exec php bash

$ docker-php-ext-install bcmath

$ kill -s USR2 1

```

Now bcmath extension is installed and works. But when I restart the container it’s gone again. Why didn’t it install it from Dockerfile I don’t understand… What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![martinzeltin](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/martinzeltin/32/25630_2.png) [@martinzeltin](https://forums.docker.com/u/martinzeltin)\
**Post date:** [October 18, 2020, 7:51am UTC](https://forums.docker.com/t/php-bcmath-extension-doesnt-get-installed-in-dockerfile/99773/2 "2020-10-18T07:51:41Z")

</div>

I just noticed that if I build my Dockerfile **without** docker-compose _(docker build)_ then bcmath gets installed. But if I use Docker compose then it doesn’t get installed. Not sure what is going on…

**Edit:**  
I finally found the problem. I removed all containers and all images and re-built everything and now everything installed correctly. So the solution was to rebuild the PHP image.
