Under docker error Call to undefined function Intervention\Image\Gd\imagecreatefromjpeg - docker

I try to install my laravel 5.7.19 application under docker(version: '3.1', ) and running some pages I got error:
Call to undefined function Intervention\Image\Gd\imagecreatefromjpeg()
I include jpeg support in web/Dockerfile.yml:
FROM php:7.2-apache
RUN apt-get update -y && apt-get install -y libpng-dev libjpeg-dev libxpm-dev libfreetype6-dev nano \
&& docker-php-ext-configure gd \
--with-freetype-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
--with-xpm-dir=/usr/include/ \
--with-vpx-dir=/usr/include/
RUN docker-php-ext-install \
pdo_mysql \
&& a2enmod \
rewrite
RUN docker-php-ext-install gd
But I have the same error anyway. Is path “/usr/include/” valid and how to check it ?
My working OS is Kubuntu 18...
Thanks!

You need to add into Dockerfile.yml file including of gd and types format like :
FROM php:7.2-apache
RUN apt-get update && \
apt-get install -y \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
nano \
libgmp-dev \
libldap2-dev \
netcat \
sqlite3 \
libsqlite3-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
That must help.

Related

Visual studio code devcontainer error reading from server: EOF

I'm trying to do a devcontainer setup with vscode on linux (fedora 37) but I always get the error you can see in the image link below
failed to receive status: rpc error: code = Unavailable desc = error reading from server: EOF
These are my configuration files:
Dockerfile:
FROM php:7.4-apache
RUN apt-get update && apt-get install -y \
git \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
libicu-dev \
libc-client-dev \
libkrb5-dev \
libmagickwand-dev && \
docker-php-ext-configure gd --with-freetype --with-jpeg=/usr/include/ --enable-gd && \
docker-php-ext-install -j$(nproc) gd && \
docker-php-ext-configure intl && \
PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
docker-php-ext-install -j$(nproc) imap && \
docker-php-ext-install zip && \
docker-php-ext-install mysqli && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install intl && \
docker-php-ext-install calendar && \
docker-php-ext-install exif && \
docker-php-ext-install gettext && \
docker-php-ext-install sockets && \
yes '' | pecl install imagick && docker-php-ext-enable imagick && \
a2enmod rewrite && \
a2enmod headers && \
a2enmod cgi && \
a2enmod proxy_fcgi && \
apt-get remove -y libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
libicu-dev \
libc-client-dev \
libkrb5-dev \
libmagickwand-dev && \
apt-get clean -y
RUN sed -i -e '/.* rights="none".*pattern="PDF"/s/ rights="none"/ rights="read|write"/g' /etc/ImageMagick-6/policy.xml
COPY --from=composer:2.5 /usr/bin/composer /usr/bin/composer
devcontainer.json:
{
"name": "PHP",
"build": {
"context": ".",
"dockerfile": "Dockerfile"
},
"forwardPorts": [ "8000:80" ],
"customizations": {
"vscode": {
"extensions": [
"donjayamanne.git-extension-pack",
"waderyan.gitblame",
"ms-azuretools.vscode-docker",
"p1c2u.docker-compose",
"ms-vscode-remote.remote-ssh",
"TabNine.tabnine-vscode",
"DEVSENSE.phptools-vscode",
"xdebug.php-pack"
]
}
},
"workspaceMount":"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"workspaceFolder": "/workspace",
}
Thank you very much for the help
The information I found on the internet says that the problem is docker, but docker is fine.
I run my docker build and it finishes successfully, but devconteiner throws the error every time
This is most likely related to a bug in Docker stack, introduced in recent Docker 23 (check your version to make sure the below applies to you).
VSC issue: https://github.com/microsoft/vscode-remote-release/issues/7958. There you can find a workaround and links to upstream trackers that deal with the issue directly.
I can confirm the workaround of disabling BUILDKIT_INLINE_CACHE works, that is setting the following in .devcontainer.json allows for VSC to start:
{
"build": {
"args": {
"BUILDKIT_INLINE_CACHE": "0"
}
}
}
The issue itself is supposed to be fixed already, but may not have landed in your distribution yet.

Docker Container exited with Error: /init.sh: not found

After creating my image and build the containers, my web container give's me that Error:
none
/usr/local/bin/docker-php-entrypoint: 9: exec: /init.sh: not found
Thats my Dockerfile:
FROM php:7.1-apache
RUN apt-get update && apt-get install -y \
libpq-dev \
libzip-dev \
libicu-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libwebp-dev \
git \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
--with-png-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install pdo \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install intl \
&& docker-php-ext-install zip \
&& rm -rf /var/lib/apt/lists/*
# apache
RUN a2enmod rewrite
# Volume
VOLUME ["/var/www/html"]
# Clean Up
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/www/html/.git
# Init
COPY /init.sh /init.sh
RUN chmod +x /init.sh
CMD ["/init.sh"]
What am i doing wrong ?

Freetype-config not found error when we install gd in php7.2-apache in Docker

I am trying to install the image php:7.2-apache from a Dockerfile,
but I have problem in gd configuration.
I have installed the latest version of docker toolbox 18.09.3 from the page https://github.com/docker/toolbox/releases/tag/v18.09.3 because I have Windows Home 10
The content of the Dockerfile is the following
FROM php:7.2-apache
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
I have this error configure: error: freetype-config not found. during the construction of the image
checking for the location of libwebp... no
checking for the location of libjpeg... /usr/include/
checking for the location of libpng... no
checking for the location of libz... no
checking for the location of libXpm... no
checking for FreeType 2... /usr/include/
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
checking for png_write_image in -lpng... yes
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.
Service 'apache_php' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install -j$(nproc) gd' returned a non-zero code: 1
Any solution ?
Referring to the reply from https://github.com/docker-library/php/issues/865#issuecomment-511163936
firstly you have to patch and fix the php bug (https://bugs.php.net/bug.php?id=76324)
RUN apt-get update && apt-get install -y pkg-config patch
ADD https://git.archlinux.org/svntogit/packages.git/plain/trunk/freetype.patch?h=packages/php /tmp/freetype.patch
RUN docker-php-source extract; \
cd /usr/src/php; \
patch -p1 -i /tmp/freetype.patch; \
rm /tmp/freetype.patch
then using the following cmd :
RUN docker-php-ext-configure gd --with-freetype-dir --with-jpeg-dir=/usr/include/
I have verified it's working for php7.2-fpm
This issue is extensively clarified in the related GitHub issue, see in particular this comment.
In brief, the whole issue is related to a change in the default Debian version. Rather than applying patches or taking more complex routes, all that is needed is to add reference to stretch in the FROM line at the beginning of the Dockerfile. In this case, the first line should read:
FROM: php:7.2-apache-stretch
All else should work as expected.
this is work for me :
FROM php:7.2-fpm
RUN apt-get update && apt-get install -y \
libicu-dev \
&& docker-php-ext-install \
intl \
opcache \
&& docker-php-ext-enable \
intl \
opcache \
&& docker-php-ext-install pdo pdo_mysql \
&& docker-php-ext-install mysqli
RUN apt-get install -y zip unzip zlib1g-dev libpng-dev
RUN docker-php-ext-install gd

How to fix Docker "/usr/src/php/ext/mcrypt does not exist" build error?

I try to install mcrypt in my docker image based on php:7.2-apache. Therefore I use the RUN-Command from the documentation and also answerd here but I receive this error. I think maybe while setup may be missing.
This is my app.docker file.
FROM php:7-fpm
# Install any custom system requirements here
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
curl \
vim \
cron \
procps \
zlib1g-dev \
zip
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install zip \
&& docker-php-ext-install bcmath \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /var/www
report error in when build docker.
> error: /usr/src/php/ext/mcrypt does not exist
>
> usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
> ie: /usr/local/bin/docker-php-ext-install gd mysqli
> /usr/local/bin/docker-php-ext-install pdo pdo_mysql
> /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop
>
> if custom ./configure arguments are necessary, see docker-php-ext-configure
>
> Possible values for ext-name:
> bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap
> mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird
> pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix
> pspell readline recode reflection session shmop simplexml snmp soap
> sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer
> wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip
>
> Some of the above modules are already compiled into PHP; please check
> the output of "php -i" to see which modules are already loaded.
> ERROR: Service 'app' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libmcrypt-dev mysql-client &&
> docker-php-ext-install pdo_mysql && docker-php-ext-install
> -j$(nproc) iconv mcrypt && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install -j$(nproc) gd && docker-php-ext-install zip
> && docker-php-ext-install bcmath && curl -sS
> https://getcomposer.org/installer | php --
> --install-dir=/usr/local/bin --filename=composer' returned a non-zero code: 1
Even though the path to the is specified in Dockerfile, it says not found
Anyone know why?
This is because mcrypt is deprecated after php:7.1. You can use a base image which still supports mcrypt eg php:5.6-cli or use an alternative to mcrypt.
This worked for me, copied from here:
RUN apt-get update && apt-get install -y libmcrypt-dev \
&& pecl install mcrypt-1.0.2 \
&& docker-php-ext-enable mcrypt

Install PHP7 fpm and memcached with Docker

I have an app with Docker, and I am trying to install memcached with php7-fpm.
According to official docker documentation I have in my Dockerfile:
# PHP Version
FROM php:7.0-fpm
...
# Install Memcached
RUN apt-get install -y libmemcached-dev && \
pecl install memcached && \
docker-php-ext-enable memcached
But I got this error:
pecl/memcached requires PHP (version >= 5.2.0, version <= 6.0.0, excluded versions: 6.0.0), installed version is 7.0.9
I don't want to switch to PHP 5.6. Any ideas?
We build the memcache extension from scratch when building our php7 container. Maybe our approached helps you or points you to the right direction. The documentation in the Dockerhub really seems to be faulty, tried pecl and it didn't work here either.
So this is how it looks in our Dockerfile:
RUN apt-get update && apt-get install -y
libmemcached11 \
libmemcachedutil2 \
libmemcached-dev \
libz-dev \
git \
&& cd /root \
&& git clone -b php7 https://github.com/php-memcached-dev/php-memcached \
&& cd php-memcached \
&& phpize \
&& ./configure \
&& make \
&& make install \
&& cd .. \
&& rm -rf php-memcached \
&& echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini \
&& apt-get remove -y build-essential libmemcached-dev libz-dev \
&& apt-get remove -y libmemcached-dev libz-dev \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
It seems that the memcached is incompatible with php7 and need another way to install it.
After a quick lock at Laradock repo I solved in this manner, I post the code:
# PHP Version
FROM php:7.0-fpm
# Install the PHP extensions we need
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
libmemcached-dev \
libz-dev \
libpq-dev \
libjpeg-dev \
libpng12-dev \
libfreetype6-dev \
libicu-dev \
libssl-dev \
libmcrypt-dev && \
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr && \
docker-php-ext-install gd mysqli opcache intl
.....
# Install Memcached
RUN curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached- dev/php-memcached/archive/php7.tar.gz" && \
mkdir -p memcached && \
tar -C memcached -zxvf /tmp/memcached.tar.gz --strip 1 && \
( \
cd memcached && \
phpize && \
./configure && \
make -j$(nproc) && \
make install \
) && \
rm -r memcached && \
rm /tmp/memcached.tar.gz && \
docker-php-ext-enable memcached
one more solution
FROM php:7.2-fpm
# ...
# INSTALL memcached
RUN apt-get upgrade -y
RUN apt-get install -y memcached
RUN apt-get install -y libmemcached-dev zlib1g-dev libicu-dev
RUN git clone -b php7 https://github.com/php-memcached-dev/php-memcached
/usr/src/php/ext/memcached \
&& docker-php-ext-configure /usr/src/php/ext/memcached \
--disable-memcached-sasl \
&& docker-php-ext-install /usr/src/php/ext/memcached \
&& rm -rf /usr/src/php/ext/memcached

Resources