We are using laravel based on php version 5.6, few days ago Debian removed jessie version (8) so we need to upgrade that to 9, but the issue is its hard to use Debian 9 without php5.6 as scripts like
docker-php-ext-install
does not seem to work there. i attach my section of the installation in the docker-file. Would appreciate if there is a solution to this
I have tried to install the pdo_mysql without the docker-php-ext-install
but it fails cannot locate that..
FROM debian:9.0
RUN apt-get update \
&& apt-get -y install \
apt-transport-https apt-utils \
lsb-release \
ca-certificates \
wget \
mcrypt \
libmcrypt-dev \
git-core \
unzip \
&& wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
&& apt-get update \
&& apt-get -y install gnupg2 php5.6-cli php5.6-fpm \
&& apt-get update \
&& docker-php-ext-install \
mbstring \
pdo_mysql \
mcrypt bcmath\
&& update-alternatives --install /usr/bin/php php /usr/bin/php5.6 90 \
&& update-alternatives --set php /usr/bin/php5.6
And this is the end of the build call :
Reading package lists...
/bin/sh: 1: docker-php-ext-install: not found
docker-php-ext-install is a command provided by official php images. You will find it only on those images or images based on those.
Official docker php images providing php 5.6 still exist on the docker hub:
wget -qO- https://registry.hub.docker.com/v1/repositories/php/tags | jq '.[].name' | grep -P '^"5\.6(?!\.)'
"5.6"
"5.6-alpine"
"5.6-alpine3.4"
"5.6-alpine3.7"
"5.6-alpine3.8"
"5.6-apache"
"5.6-apache-jessie"
"5.6-apache-stretch"
"5.6-cli"
"5.6-cli-alpine"
"5.6-cli-alpine3.4"
"5.6-cli-alpine3.7"
"5.6-cli-alpine3.8"
"5.6-cli-jessie"
"5.6-cli-stretch"
"5.6-fpm"
"5.6-fpm-alpine"
"5.6-fpm-alpine3.4"
"5.6-fpm-alpine3.7"
"5.6-fpm-alpine3.8"
"5.6-fpm-jessie"
"5.6-fpm-stretch"
"5.6-jessie"
"5.6-stretch"
"5.6-zts"
"5.6-zts-alpine"
"5.6-zts-alpine3.4"
"5.6-zts-alpine3.7"
"5.6-zts-alpine3.8"
"5.6-zts-jessie"
"5.6-zts-stretch"
Furthermore, those images are built on top of debian 9:
docker run --rm php:5.6 cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
and provide the docker-php-ext-install command:
docker run --rm php:5.6 which docker-php-ext-install
/usr/local/bin/docker-php-ext-install
I suggest you use one of those official image as the base for your Dockerfile.
FROM php:5.6-fpm
RUN apt-get update \
&& apt-get -y install \
libmcrypt-dev \
mcrypt \
&& docker-php-ext-install \
bcmath \
mbstring \
mcrypt \
pdo_mysql
Related
I need help, I can’t install pdo_mysql, ampq or opcache with docker-php-ext-install. I prepared a docker project on a local PC (Mac OSX). On the local PC after build docker image is the final PHP configuration right. When I deploy the project config to the remote Debian server after building it, I have a completely different PHP version (phpinfo). Missing extensions opcache, pdo_mysql, ampq.
I tried to configure it differently and deleted the docker cache on the server, but it didn’t help.
docker system prune -a
My PHP dockerfile:
FROM php:7.4-fpm
WORKDIR /var/www/symfony
RUN apt-get update \
&& docker-php-ext-install mysqli pdo pdo_mysql \
&& docker-php-ext-enable pdo_mysql
RUN apt update && apt-get udpate \
&& apt install -y zlib1g-dev g++ git libicu-dev zip libzip-dev zip libxslt1-dev\
&& docker-php-ext-install intl \
&& pecl install apcu \
&& docker-php-ext-enable apcu \
&& docker-php-ext-configure zip \
&& docker-php-ext-install zip \
&& docker-php-ext-install xsl
RUN apt-get update \
&& docker-php-ext-install opcache
RUN apt-get update \
&& apt-get install -y \
librabbitmq-dev \
libssh-dev \
&& pecl install amqp \
&& docker-php-ext-enable amqp
RUN apt-get update && \
apt-get install -y libxml2-dev \
&& docker-php-ext-install soap
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
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Node.js
RUN curl -sL https://deb.nodesource.com/setup_14.x -o node_setup.sh && \
bash node_setup.sh && \
apt-get install -y nodejs && \
npm install npm -g
# Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get install -y yarn
RUN apt-get update && apt-get install -y cron
ADD ./crontab /etc/cron.d/crontab
#
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/crontab
RUN crontab /etc/cron.d/crontab
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
RUN apt-get update && apt-get install -y supervisor
ADD ./supervisord.conf /etc/supervisor/
# Copy docker entrypoint file
COPY ./entrypoint.sh /entrypoint.sh
# Docker init
RUN ["chmod", "+x", "/entrypoint.sh"]
Not sure if it's a solution to your issue, but let's see.
From https://hub.docker.com/_/php:
If you are having difficulty figuring out which Debian or Alpine packages need to be installed before docker-php-ext-install, then have a look at the install-php-extensions project. This script builds upon the docker-php-ext-* scripts and simplifies the installation of PHP extensions by automatically adding and removing Debian (apt) and Alpine (apk) packages. For example, to install the GD extension you simply have to run install-php-extensions gd. This tool is contributed by community members and is not included in the images, please refer to their Git repository for installation, usage, and issues.
I had similar issues in the past and resolved it by using install-php-extensions. See this comment.
My problem: When i run command
docker build --no-cache -t php --progress=plain .
My container is building, but I get Error in my PHP-project:
Error Call to undefined function snmp2_real_walk()
Command install in Dockerfile is't work... I need help!!
My Dockerfile:
FROM php:7.4-apache
# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN if command -v a2enmod >/dev/null 2>&1; then \
a2enmod rewrite headers \
;fi
RUN apt-get update
# Install tools required for build stage
RUN apt-get install -fyqq \
bash curl wget rsync ca-certificates openssl ssh git tzdata openntpd \
libxrender1 fontconfig libc6 \
mariadb-client gnupg binutils-gold autoconf \
g++ gcc gnupg libgcc1 linux-headers-amd64 make python
#RUN apt install -y libsnmp-dev
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer \
&& chmod 755 /usr/bin/composer
# Install additional PHP libraries
RUN docker-php-ext-install bcmath pdo_mysql
RUN \
apt-get update && \
apt-get install libldap2-dev -y && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
docker-php-ext-install ldap
# Install libraries for compiling GD, then build it
RUN apt-get update && apt-get install -y \
libfreetype6 \
libfreetype6-dev \
libjpeg62-turbo \
libjpeg62-turbo-dev \
libsqlite3-dev \
libssl-dev \
libpng-dev \
libpng16-16 \
libcurl3-dev \
libxml2-dev \
libonig-dev \
libsnmp-dev \
snmp \
&& docker-php-ext-install mysqli xmlrpc \
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
&& docker-php-ext-install gd \
&& apt-get remove -fyqq libfreetype6-dev libpng-dev libjpeg62-turbo-dev
# -------------------- Installing PHP Extension: snmp --------------------
RUN docker-php-ext-configure snmp --with-snmp \
# Installation
&& docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) snmp \
&& true
RUN sed -i 's/;extension=snmp/extension=snmp/' php.ini-production
# Add ZIP archives support
RUN apt-get install -fyqq zip libzip-dev \
&& docker-php-ext-install zip \
&& apt-get remove -fyqq libzip-dev
# Install xdebug
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
# Enable XDebug
ADD xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
WORKDIR /app
I've tried a lot of options. Editing the
php.ini-production
file did not lead to the expected result. At the same time, the php.ini file also does not exist, but the command is present...
Trying to install imagick for php 8.1.1.
On image of my Dockerfile below composer install gives the following error :
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires PHP extension ext-imagick ^3.6 but it is missing from your system. Install or enable PHP's imagick extension.
To enable extensions, verify that they are enabled in your .ini files:
-
- /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
- /usr/local/etc/php/conf.d/docker-php-ext-calendar.ini
- /usr/local/etc/php/conf.d/docker-php-ext-gd.ini
- /usr/local/etc/php/conf.d/docker-php-ext-intl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
- /usr/local/etc/php/conf.d/docker-php-ext-xsl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
I tried various solutions
apt install php-imagick gives error:
Package php-imagick is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
apt install php8.1-imagick does not find any package
adding RUN docker-php-ext-install php-imagick or RUN docker-php-ext-install imagick at the end of my Dockerfile do not find any package
Dockerfile
FROM php:8.1.1-fpm
RUN apt-get clean && apt-get update \
&& apt-get install -y --no-install-recommends \
locales \
apt-utils \
git \
libicu-dev \
g++ \
libpng-dev \
libxml2-dev \
libzip-dev \
libonig-dev \
libxslt-dev \
unzip \
libpq-dev \
nodejs \
npm \
wget \
apt-transport-https \
lsb-release \
ca-certificates
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
RUN curl -sS https://getcomposer.org/installer | php -- \
&& mv composer.phar /usr/local/bin/composer
RUN curl -sS https://get.symfony.com/cli/installer | bash \
&& mv /root/.symfony/bin/symfony /usr/local/bin
RUN docker-php-ext-configure \
intl \
&& docker-php-ext-install \
pdo pdo_mysql pdo_pgsql opcache intl zip calendar dom mbstring gd xsl
RUN pecl install apcu && docker-php-ext-enable apcu
RUN npm install --global yarn
WORKDIR /var/www/app/
RUN apt-get install -y libmagickwand-dev
RUN apt-get install -y imagemagick
RUN pecl install imagick
COPY ./app/composer.json ./
COPY ./app/composer.lock ./
RUN apt-get update; \
# Imagick extension
apt-get install -y libmagickwand-dev; \
pecl install imagick; \
docker-php-ext-enable imagick; \
# Success
true
Trying to install imagick for php 8.1.1.
On image of my Dockerfile below composer install gives the following error :
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires PHP extension ext-imagick ^3.6 but it is missing from your system. Install or enable PHP's imagick extension.
To enable extensions, verify that they are enabled in your .ini files:
-
- /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
- /usr/local/etc/php/conf.d/docker-php-ext-calendar.ini
- /usr/local/etc/php/conf.d/docker-php-ext-gd.ini
- /usr/local/etc/php/conf.d/docker-php-ext-intl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
- /usr/local/etc/php/conf.d/docker-php-ext-xsl.ini
- /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
I tried various solutions
apt install php-imagick gives error:
Package php-imagick is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
apt install php8.1-imagick does not find any package
adding RUN docker-php-ext-install php-imagick or RUN docker-php-ext-install imagick at the end of my Dockerfile do not find any package
Dockerfile
FROM php:8.1.1-fpm
RUN apt-get clean && apt-get update \
&& apt-get install -y --no-install-recommends \
locales \
apt-utils \
git \
libicu-dev \
g++ \
libpng-dev \
libxml2-dev \
libzip-dev \
libonig-dev \
libxslt-dev \
unzip \
libpq-dev \
nodejs \
npm \
wget \
apt-transport-https \
lsb-release \
ca-certificates
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
RUN curl -sS https://getcomposer.org/installer | php -- \
&& mv composer.phar /usr/local/bin/composer
RUN curl -sS https://get.symfony.com/cli/installer | bash \
&& mv /root/.symfony/bin/symfony /usr/local/bin
RUN docker-php-ext-configure \
intl \
&& docker-php-ext-install \
pdo pdo_mysql pdo_pgsql opcache intl zip calendar dom mbstring gd xsl
RUN pecl install apcu && docker-php-ext-enable apcu
RUN npm install --global yarn
WORKDIR /var/www/app/
RUN apt-get install -y libmagickwand-dev
RUN apt-get install -y imagemagick
RUN pecl install imagick
COPY ./app/composer.json ./
COPY ./app/composer.lock ./
RUN apt-get update; \
# Imagick extension
apt-get install -y libmagickwand-dev; \
pecl install imagick; \
docker-php-ext-enable imagick; \
# Success
true
Following my previous post.
I managed to install oci8-2.2.0 via pecl.
Now I have a problem, I cannot launch the commands:
docker-php-ext- *
It always gives me an error:
/ bin / sh: 1: docker-php-ext-configure: not found
In my Dockerfile :
FROM ubuntu:latest
COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker
COPY --from=docker/compose:latest /usr/local/bin/docker-compose /usr/bin/docker-compose
I install my necessary packages:
RUN apt-get install -y \
apache2 \
libapache2-mod-php \
libldap2-dev \
vim \
curl \
git \
openssl \
bash \
mysql-client \
g++ \
gcc \
make \
libaio1 \
wget \
unzip \
libapache2-mod-php7.4 \
software-properties-common \
systemtap-sdt-dev \
build-essential \
libcurl4-gnutls-dev \
unixodbc-dev \
net-tools
I install the PHP dependencies:
RUN apt-add-repository -y ppa:ondrej/php
RUN apt-get update
RUN apt-get install -y \
php7.4 \
php7.4-fpm \
php7.4-xml \
php-common \
php7.4-gd \
php7.4-mbstring \
php7.4-gd \
php7.4-iconv \
php7.4-pdo \
php7.4-tokenizer \
php7.4-mysql \
php-ldap \
php7.4-ldap \
php7.4-fileinfo \
php7.4-simplexml \
php7.4-xmlwriter \
php7.4-zip \
php7.4-json \
php-dev \
php-pear
Finally, the commands are launched after installing Oracle Instant Client:
# Oracle instantclient
RUN export PHP_DTRACE=yes
ADD instantclient-basic-linux.x64-12.2.0.1.0.zip /tmp/
ADD instantclient-sdk-linux.x64-12.2.0.1.0.zip /tmp/
RUN unzip /tmp/instantclient-basic-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN unzip /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN mv /usr/local/instantclient_12_2 /usr/local/instantclient
RUN ln -s /usr/local/instantclient/libclntsh.so.12.1 /usr/local/instantclient/libclntsh.so
RUN ln -s /usr/local/instantclient/libocci.so.12.1 /usr/local/instantclient/libocci.so
ENV LD_LIBRARY_PATH=/usr/local/instantclient
RUN echo "instantclient,/usr/local/instantclient"| pecl install oci8-2.2.0
RUN docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/usr/local/instantclient
RUN docker-php-ext-install pdo_oci
RUN docker-php-ext-enable oci8-2.2.0
Any idea for Docker to find docker-php-ext- commands?
BR
Commands docker-php-ext- * are helper scripts provided by PHP images. But you are using ubuntu:latest image, which is doesn't contain them.
You can use scripts from php image for example that one. But I think it is easier to use php docker images.