dockerfile not updating container

I’m working with an app using docker (i’m not super familiar) and I need to add 2 new php extensions. I have changed the dockerfile on an existing image as follows:

FROM php:7.2-fpm

RUN apt-get update

RUN apt-get install -y git unzip

RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer

RUN apt-get install -y git libpng-dev 
    && docker-php-ext-install gd

RUN apt-get install -y mysql-client 
    && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd 
    && docker-php-ext-install pdo_mysql

RUN apt-get install -y libgmp-dev bcmath 
    && docker-php-ext-configure gmp 
    && docker-php-ext-install gmp 
    && docker-php-ext-install bcmath

RUN pecl install xdebug 
    && docker-php-ext-enable xdebug

ADD docker/templates/usr/local/etc/php/conf.d/uploads.ini /usr/local/etc/php/conf.d/uploads.ini

My new lines are:

RUN apt-get install -y libgmp-dev bcmath 
&& docker-php-ext-configure gmp 
&& docker-php-ext-install gmp 
&& docker-php-ext-install bcmath

I’ve tried docker-compose restart, I’ve tried docker-compose down followed by docker-compose up, I’ve removed the container entirely and re-created with up. However hard I try, I always get this error when doing a composer require

the requested PHP extension bcmath is missing from your system.

I’m not sure why this is happening. Why won’t the extension install, and how come if I completely delete the contents and write garbled text in the dockerfile, it always runs successfully. Is it caching it?

Can somebody explain how i’d re-provision with the new changes I’ve made?

Here’s a snippet from by docker-compose.yml too.

services:
  web:
    build:
      context: ./
      dockerfile: docker/web.docker
    working_dir: /var/www
    volumes:
      - ./:/var/www
    ports:
      - 81:80
  app:
    build:
      context: ./
      dockerfile: docker/app.docker
    working_dir: /var/www
    volumes:
      - ./:/var/www
    environment:
      - "LARAVEL_ENVIRONMENT=local"

Thanks.

Source: StackOverflow