dockerfile not updating container
Asked Answered
H

1

5

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 tried docker-compose restart, I tried docker-compose down followed by docker-compose up, I 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 made?

Snippet of docker-compose.yml:

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"
Hjerpe answered 22/3, 2019 at 23:3 Comment(4)
I've also tried php7.0-bcmath, php7.1-bcmath and php-bcmath. None of which work.Hjerpe
How do you build a Docker image? This instruction added to docker-compose or you build it with a command?Schmidt
Oh I have to rebuild the image? I didn't know the containers and images are separate, so you have to explicitly rebuild the image and then spin up containers? I guess I suspected it'd be like vagrant where you just vagrant up and it does everything in oneHjerpe
"If you want to force Compose to stop and recreate all containers, use the --force-recreate flag." I read that from the docs, which made be believe thats what I needed to do.Hjerpe
S
8

You need to rebuild the image

docker-compose build

and next re-run containers

docker-compose up -d
Schmidt answered 22/3, 2019 at 23:44 Comment(1)
And if it doesn't want to apply the change due to cache, you can add the --no-cache.Sixth

© 2022 - 2024 — McMap. All rights reserved.