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 
      
4
  • Try php7.4-gd instead of just gd and put it before docker-php-ext-configure Commented Feb 22, 2023 at 6:22
  • Already tried not working Commented Feb 22, 2023 at 6:37
  • Dockerfile seems ok to me. What does phpinfo say about gd? Commented Feb 22, 2023 at 6:50
  • @kopz phpinfo() is saying that GD is not installed. I have also checked with php-m to get the list of installed commands, and it also not listing GD Commented Feb 22, 2023 at 7:04

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.