1

I tried to install GD Extension in docker with the following command, But it is not installing. Can you please suggest where is the issue? Following is the code in Dockerfile. I would like to install more php extensions like zip also. but am not getting any errors also, when am using composer update command itself

Codes in Dockerfile
FROM php:7.4-apache
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

Following is the code in yml file

version: '3'

services:
    apache_test:
        container_name: apache_test
        build:
            context: ./Dockerfile
            dockerfile: Dockerfile
        image: php:7.4-apache
        restart: always
        dns:
            - 8.8.8.8
            - 4.4.4.4
            - 122.28.0.0
        ports:
            - "83:80"
        volumes:
            - $HOME/projects/test:/www/test/
            - ./apache2.conf:/etc/apache2/sites-enabled/vhost.conf
            - ./php.ini:/usr/local/etc/php/php.ini
        networks:
            test_network:
                ipv4_address: 122.28.1.1
    database_test:
        container_name: database_test
        image: mysql:5.7
        restart: always
        ports:
            - "3310:3306"
        environment:
            - MYSQL_ROOT_PASSWORD=abc123
        networks:
            mastercard_network:
                ipv4_address: 122.28.1.2
        command: mysqld --max_allowed_packet=256M
    phpmyadmin_test:
        image: phpmyadmin/phpmyadmin:4.8.4
        restart: always
        ports:
            - "8180:80"
        environment:
            MYSQL_ROOT_PASSWORD: password
            PMA_HOST: database_mastercard
        networks:
            mastercard_network:
                ipv4_address: 122.28.1.3
        links:
            - database_test
volumes:
  data:
    driver: local            
networks:
    test_network:
        ipam:
            driver: default
            config:
                - subnet: 122.28.0.0/16 
      

1 Answers1

0

I have faced same issue on php:alpine image when command php -m returned that all php extensions were installed and enabled but when run composer show -p it's been seen that there were missing php extensions.

I followed answer to question How to install PHP composer inside a docker container and installed composer with next step in Dockerfile:

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

After that running composer show -p gave output with all installed php extensions.

Alexred
  • 176
  • 1
  • 9