You should add the libpng-dev package to your Dockerfile:
FROM php:5.6-apache
RUN docker-php-ext-install mysql mysqli
RUN apt-get update -y && apt-get install -y sendmail libpng-dev
RUN apt-get update && \
apt-get install -y \
zlib1g-dev
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install zip
RUN docker-php-ext-install gd
Then go to directory with Dockerfile and run:
docker build -t sitename .
It worked in my case:
Removing intermediate container f03522715567
Successfully built 9d69212196a2
Let me know if you get any errors.
EDIT:
You should see something like this:
REPOSITORY TAG IMAGE ID CREATED SIZE
sitename latest 9d69212196a2 19 minutes ago 414 MB
<none> <none> b6c69576a359 25 minutes ago 412.3 MB
EDIT2:
Just to double check everything:
Please run the docker build command this way:
docker build -t sitename:1.0 .
(adding :1.0 should not change anything, I added it just to have additional row in docker images output)
Then start the container:
docker run --name sitename_test -p 80:80 sitename:1.0
It should work just fine.
I assumed that apache is using standard port (80) - maybe you need to adjust that. If you have other services/containers listening on port 80 you can make your container listening on other port:
docker run --name sitename_test -p 8080:80 sitename:1.0
That will redirect the traffic from port 8080 to port 80 "inside" the container.
Normally you run container in the background. To do this add the -d option to the docker run command (but for testing purposes you can omit -d to see output in the console).
If you decide to run container in the background you can check logs using docker logs sitename_test. To follow the logs (and see updates in logs) use -f option:
docker logs -f sitename_test
You should add the libpng-dev package to your Dockerfile:
FROM php:5.6-apache
RUN docker-php-ext-install mysql mysqli
RUN apt-get update -y && apt-get install -y sendmail libpng-dev
RUN apt-get update && \
apt-get install -y \
zlib1g-dev
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install zip
RUN docker-php-ext-install gd
Then go to directory with Dockerfile and run:
docker build -t sitename .
It worked in my case:
Removing intermediate container f03522715567
Successfully built 9d69212196a2
Let me know if you get any errors.
EDIT:
You should see something like this:
REPOSITORY TAG IMAGE ID CREATED SIZE
sitename latest 9d69212196a2 19 minutes ago 414 MB
<none> <none> b6c69576a359 25 minutes ago 412.3 MB
EDIT2:
Just to double check everything:
Please run the docker build command this way:
docker build -t sitename:1.0 .
(adding :1.0 should not change anything, I added it just to have additional row in docker images output)
Then start the container:
docker run --name sitename_test -p 80:80 sitename:1.0
It should work just fine.
I assumed that apache is using standard port (80) - maybe you need to adjust that. If you have other services/containers listening on port 80 you can make your container listening on other port:
docker run --name sitename_test -p 8080:80 sitename:1.0
That will redirect the traffic from port 8080 to port 80 "inside" the container.
Normally you run container in the background. To do this add the -d option to the docker run command (but for testing purposes you can omit -d to see output in the console).
If you decide to run container in the background you can check logs using docker logs sitename_test. To follow the logs (and see updates in logs) use -f option:
docker logs -f sitename_test
This answer is too late, but it will help.
RUN apt-get update && \
apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && \
docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ && \
docker-php-ext-install gd
docker-php-ext-enable gd - cannot create directory
Issue with installing php extension gd
How to Enable PHP extensions via Dockerfile?
docker - How to add php gd extension to Dockerfile - Stack Overflow
Hi, I'm new to Docker, so please forgive me if this question is stupid.
I'm trying to build a custom image via a Dockerfile. This is the file:
FROM php:7.4-fpm
# Install Composer
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Install unzip utility and libs needed by zip PHP extension
RUN apt-get update && apt-get install -y \
zlib1g-dev \
libzip-dev \
unzip
RUN docker-php-ext-install zipThis is my docker-compose.yml
version: "3.7"
services:
web:
image: nginx
ports:
- 80:80
php:
build: .Now, I go to the "php" container and create a terminal. (I guess this is correct?)
Now, I'm trying to install Magento 2 via composer:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2
Unfortunately I'm getting this error message:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires magento/product-community-edition 2.4.3 -> satisfiable by magento/product-community-edition[2.4.3].
- magento/product-community-edition 2.4.3 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension.
Problem 2
- magento/magento2-functional-testing-framework[3.0.0, ..., 3.7.0] require ext-intl * -> it is missing from your system. Install or enable PHP's intl extension.
- Root composer.json requires magento/magento2-functional-testing-framework ^3.0 -> satisfiable by magento/magento2-functional-testing-framework[3.0.0, ..., 3.7.0].
To enable extensions, verify that they are enabled in your .ini files:
-
- /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
- /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.If I understand it correctly I need to enable these two extensions? But how would I do this?
Thank you very much in advance.
Here's how I do it but on php image, not alpine. Maybe you can just "finetune" it to work on alpine:
RUN apt-get update && \
apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd
It's help for me:
RUN apk update
RUN apk add libpng libpng-dev libjpeg-turbo-dev libwebp-dev zlib-dev libxpm-dev gd && docker-php-ext-install gd
You can add these settings in your Dockerfile:
FROM php:7.4-fpm
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
Official documentation.
In my docker using PHP8.0 I got GD working for jpg,png and webp by adding the following lines to my php.dockerfile:
FROM php:8.0-fpm-alpine
# Install dependencies for GD and install GD with support for jpeg, png webp and freetype
# Info about installing GD in PHP https://www.php.net/manual/en/image.installation.php
RUN apk add --no-cache \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
freetype-dev
# As of PHP 7.4 we don't need to add --with-png
RUN docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype
RUN docker-php-ext-install gd
following this answer install gd from dockerfile
RUN docker-php-ext-install gd
https://github.com/rhamdeew/docker-php-8-fpm-alpine/blob/master/Dockerfile
I faced error with GD extension installation. The Alpine version of PHP requires some additional packages to be installed before you can successfully configure and install GD extension.
Here's how I ensured that the GD extension installs correctly:
# Install system dependencies
RUN apk add --no-cache --update \
curl \
openssl \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libzip-dev \
unzip
# Install the GD extension
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && docker-php-ext-install gd