I am trying to install php7.2-ldap in Laradock and I've set
WORKSPACE_INSTALL_LDAP=true
and
PHP_FPM_INSTALL_LDAP=true
and then tries to build the image like
docker-compose build workspace
And I get this error message. Part of the log
The following NEW packages will be installed:
php7.2-ldap
0 upgraded, 1 newly installed, 0 to remove and 28 not upgraded.
Need to get 23.1 kB of archives.
After this operation, 101 kB of additional disk space will be used.
Err:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 php7.2-ldap amd64 7.2.4-1+ubuntu16.04.1+deb.sury.org+1
404 Not Found
E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/pool/main/p/php7.2/php7.2-ldap_7.2.4-1+ubuntu16.04.1+deb.sury.org+1_amd64.deb 404 Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
ERROR: Service 'workspace' failed to build: The command '/bin/sh -c if [ ${INSTALL_LDAP} = true ]; then apt-get install -y libldap2-dev && apt-get install -y php${PHP_VERSION}-ldap ;fi' returned a non-zero code: 100
What's happening here and why can't I install this?
I am answering my own question.
This was fixed by adding
apt-get update -yqq && \
before
apt-get install -y libldap2-dev && \
in workspace/Dockerfile and php-fpm\Dockerfile.
A complete block will look like this:
File: workspace\Dockerfile
###########################################################################
# LDAP:
###########################################################################
ARG INSTALL_LDAP=false
ARG PHP_VERSION=${PHP_VERSION}
RUN if [ ${INSTALL_LDAP} = true ]; then \
apt-get update -yqq && \
apt-get install -y libldap2-dev && \
apt-get install -y php${PHP_VERSION}-ldap \
;fi
Why did this happen?
A quote from Github issue:
What appears to be happening here is that there are a few apt-get
install commands for several packages are called while the local
package repo is out of sync with the remote. In an interactive
environment, this would be seen by the user and an appropriate apt-get
update would be run. However, the Dockerfile does not contain any
package repo update commands, as such the current layer has a
different package repo list than the remote. This is in general the
"problem" with dockers layers as they will be re-used if their command
didn't change (something I, too, had to learn the hard way).
By: Philipp Tempel
Related
I've getting started with Docker, using the LAMP repo from GitHub as my starting point. I need to add the libxslt lib. I've tried adding this to my Dockerfile:
RUN apt-get install libxslt-dev
RUN docker-php-ext-enable libxslt-dev
But keep getting error: E: Unable to locate package libxslt-dev
I've tried to search for the lib from the Docker container's command line apt-cache search libxslt but get no results.
Can anybody point me in the right direction to get this lib installed?
Thanks
Followed answer below (#vpalmerini) updating Dockerfile:
RUN apt update && apt-get install -y libxslt-dev
RUN docker-php-ext-enable libxslt-dev
Which I thought was working:
Step 9/13 : RUN apt update && apt-get install -y libxslt-dev
[...]
The following additional packages will be installed:
libxslt1.1
The following NEW packages will be installed:
libxslt1-dev libxslt1.1
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 756 kB of archives.
After this operation, 3001 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 libxslt1.1 amd64 1.1.32-2.2~deb10u1 [237 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 libxslt1-dev amd64 1.1.32-2.2~deb10u1 [519 kB]
Fetched 756 kB in 0s (4903 kB/s)
Selecting previously unselected package libxslt1.1:amd64.
(Reading database ... 21271 files and directories currently installed.)
Preparing to unpack .../libxslt1.1_1.1.32-2.2~deb10u1_amd64.deb ...
Unpacking libxslt1.1:amd64 (1.1.32-2.2~deb10u1) ...
Selecting previously unselected package libxslt1-dev:amd64.
Preparing to unpack .../libxslt1-dev_1.1.32-2.2~deb10u1_amd64.deb ...
Unpacking libxslt1-dev:amd64 (1.1.32-2.2~deb10u1) ...
Setting up libxslt1.1:amd64 (1.1.32-2.2~deb10u1) ...
Setting up libxslt1-dev:amd64 (1.1.32-2.2~deb10u1) ...
Processing triggers for libc-bin (2.28-10) ...
Removing intermediate container b62504aca3f9
---> b62b7af34467
Step 10/13 : RUN docker-php-ext-enable libxslt-dev
---> Running in 181191c74fe5
error: 'libxslt-dev' does not exist
Also tried changing RUN command to match package found: libxslt1-dev
RUN docker-php-ext-enable libxslt1-dev
Still unable to enable libxslt
Further info, output from:
dpkg --get-selections
includes:
libxml2-dev:amd64 install
libxrender-dev:amd64 install
libxrender1:amd64 install
libxslt1-dev:amd64 install
libxslt1.1:amd64 install
libxt-dev:amd64 install
But running RUN docker-php-ext-enable libxslt1-dev still gives
error: 'libxslt1-dev' does not exist
You are confusing the php extension called xsl with the system development package for libxslt (present on your base image Debian Linux distribution with the specific name libxslt1-dev) which is required to install that php extension.
Here is a basic Dockerfile to achieve your requirement. Note that, as a good practice, I made the install in a single run instruction with some extra cleanup at the end.
The apt-get remove line is optional but will reduce the layer size a bit more. Installing libxslt1-dev and all its dependencies (icu-devtools, libicu-dev, libicu63, libxml2, libxml2-dev, libxslt1.1) is mandatory for installing the extension. But once it is done, the dev packages can be removed.
FROM php:7.4.2-apache-buster
RUN apt-get update && \
apt-get install -y libxslt1-dev && \
docker-php-ext-install xsl && \
apt-get remove -y libxslt1-dev icu-devtools libicu-dev libxml2-dev && \
rm -rf /var/lib/apt/lists/*
The only thing missing is that you have to update the packages of your image, then you will be able to install libxslt-dev package:
RUN apt update && apt-get install -y libxslt-dev
I want to install php7.3. I use the following script.
apt-get update && apt-get upgrade && \
apt-get -y install software-properties-common && \
add-apt-repository ppa:ondrej/php && \
apt-get update && \
apt-get -y install php7.3 \
php7.3-mbstring
The error says:
W: The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu eoan Release' does not have a Release file.
E: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/dists/eoan/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
I am using:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
The guide I followed was How to install PHP (7, 7.2 or 7.3) on Ubuntu.
It looks like your system is trying to use eoan distribution of Ubuntu, which is not yet released, so it's no wonder that packages for that distribution do not exist on this PPA.
You can manually change eoan to bionic in the relevant file in /etc/apt/sources.list.d/ and run apt-get update && apt-get -y install php7.3 php7.3-mbstring again.
Why is your system using eoan instead of bionic, I cannot answer.
I have a simple docker file, as follows:
FROM php:7.2-apache
COPY src/ /var/www/html/
Normally to install drivers for Mongo or MySQL connectivity I would do so by adding something like the below to the dockerfile:
docker-php-ext-install mongo
On this occasion I want to connect my php application to a SQL Server database, and I understand the best way to do this for php 7.x is by using the PDO driver, however I am unfamiliar with how to do configure this in the dockerfile.
I've tried doing a pecl install, like adding:
RUN pecl install sqlsrv pdo_sqlsrv
However this fails with a combination of errors that do not seem to point me in the right direction.
I'm just looking for a simple way to get this done in a dockerfile or by using docker run.
For added info, here's the error I'm getting:
/tmp/pear/temp/sqlsrv/shared/xplat.h:30:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^
compilation terminated.
Makefile:194: recipe for target 'conn.lo' failed
make: *** [conn.lo] Error 1
ERROR: `make' failed
The command '/bin/sh -c pecl install sqlsrv pdo_sqlsrv && docker-php-ext-enable pdo_sqlsrv' returned a non-zero code: 1
Thanks all
I have created a docker file for this exact purpose:
FROM php:7.3-apache
ENV ACCEPT_EULA=Y
RUN apt-get update && apt-get install -y gnupg2
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv
COPY . /var/www/html/
Enjoy!
Did you get an answer to this? I got it working with the following steps. (The unixodbc-dev package should get you past the pecl install.)
in the Docker file:
RUN apt-get -y install unixodbc-dev
RUN pecl install sqlsrv pdo_sqlsrv
And then you have to add some changes to php.ini to enable sqlserver.
get a local copy of php.ini and add these lines:
extension=pdo_sqlsrv.so
extension=sqlsrv.so
Then copy your local php.ini into the docker image (my file is in a local "config" folder).
in the Docker file:
COPY config/php.ini /usr/local/etc/php/
My docker config:
###############
# MSSQL support
###############
RUN apt-get update \
&& apt-get install -y gpg unixodbc unixodbc-dev \
&& docker-php-ext-install pdo pdo_mysql \
&& pecl install sqlsrv pdo_sqlsrv
# ------------ Install MS SQL client deps ------------ #
# adding custom MS repository
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
# install SQL Server drivers and tools
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
RUN /bin/bash -c "source ~/.bashrc"
# Debian 9 msodbcsql : https://packages.microsoft.com/debian/9/prod/pool/main/m/msodbcsql17/
RUN wget https://packages.microsoft.com/debian/9/prod/pool/main/m/msodbcsql17/msodbcsql17_17.4.2.1-1_amd64.deb
RUN ACCEPT_EULA=Y dpkg -i msodbcsql17_17.4.2.1-1_amd64.deb
RUN apt-get -y install locales
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
RUN locale-gen
RUN echo "extension=sqlsrv.so" >> /usr/local/etc/php/conf.d/docker-php-ext-sqlsrv.ini
RUN echo "extension=pdo_sqlsrv.so" >> /usr/local/etc/php/conf.d/docker-php-ext-pdo-sqlsrv.ini
# -------------- END MSSQL -------------------------------- #
FROM php:7.4.0-apache
ENV ACCEPT_EULA=Y
RUN apt-get update && apt-get install -y gnupg2
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-relea`enter code here`se.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get -y --no-install-recommends install msodbcsql17 unixodbc-dev
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv
RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv pdo pdo_mysql
COPY index.php /var/www/html/
I am new to docker, needed to use it for a legacy project that requires php5. Here is my Dockerfile snippet:
FROM ubuntu:14.04.1
LABEL MAINTAINER Hasan
RUN apt-get update && \
apt-get install -y apache2 && \
apt-get install -y mysql-server php5-mysql && \
apt-get install -y php5 libapache2-mod-php5 php5-mcrypt
WORKDIR /var/www/html
COPY . /var/www/html
EXPOSE 80
CMD service apache2 start
Here is the command to build it:
docker build -t rakibtg/oldapp .
It gives few error including 'Hash Sum mismatch' and 'returned a non-zero code: 100'
Fetched 16.7 MB in 60s (274 kB/s)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/p/perl/perl-modules_5.18.2-2ubuntu1.4_all.deb Hash Sum mismatch
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get update && apt-get install -y apache2 && apt-get install -y mysql-server php5-mysql && apt-get install -y php5 libapache2-mod-php5 php5-mcrypt' returned a non-zero code: 100
What should i do to fix it?
Also, is the CMD is configured properly here? Any guide would be appreciated
I am using docker on mac
This error seems more linked to apt-get behavior rather than to Docker.
You can try:
FROM ubuntu:14.04.1
LABEL MAINTAINER Hasan
RUN apt-get clean && apt-get update && \
apt-get install -y apache2 && \
apt-get install -y mysql-server php5-mysql && \
apt-get install -y php5 libapache2-mod-php5 php5-mcrypt
WORKDIR /var/www/html
COPY . /var/www/html
EXPOSE 80
CMD apachectl -D FOREGROUND
or other solutions mentioned in Troube downloading packages list due to a hash sum mismatch error
By the way I changed your CMD statement. Indeed when using service the process will be detached from shell and Docker will stop the container (See How to start apache2 automatically in a ubuntu docker container? for associated explanations)
I have been unable to get soap to work with my php Docker setup.
I am using Docker CE for Windows Version 18.03.1-ce-win65 (17513). PHP version 7.2.3
I've tried running from inside the container apt-get install php-soap which results in
Reading package lists... Done
Building dependency tree
Reading state information... Done*
Package php-soap is a virtual package provided by:
* php7.0-soap 7.0.27-0+deb9u1 [Not candidate version]*
E: Package 'php-soap' has no installation candidate
Running docker-php-ext-install soap
results in the error configure: error: libxml2 not found. Please check your libxml2 installation.
However when looking at php info I see the following:
libxml2 Version => 2.9.4
You will need to install libxml2-dev as part of your dockerfile, the image is kept to a minimum and doesn't include all of the bits needed by every module. Although the image may have the main package, the -dev package includes the components needed to compile other modules which rely on it...
RUN apt-get update && \
apt-get install -y libxml2-dev
(From https://github.com/docker-library/php/issues/315)
Just to make it clear - the command
RUN docker-php-ext-install soap
will then run successfully to install the soap library.
For me, working with PHP 7.3.2, the other solutions didn't work.
Both "php-soap" and "php7.3-soap" got "phpXXX-soap has no installation candidate" error.
Alone "docker-php-ext-install soap" wanted the "libxml2-dev" so i just installed the necessities:
FROM php:7.3
RUN apt-get update -y \
&& apt-get install -y \
libxml2-dev \
&& apt-get clean -y \
&& docker-php-ext-install soap
... and it worked nicely.
The correct answer was done, but for me, I needed also to enable (docker-php-ext-enable soap) the soap module, so for If someone could be useful:
FROM php:7.4.24-apache
# your configurations ...
RUN apt-get update && \
apt-get install -y libxml2-dev
RUN docker-php-ext-install soap && docker-php-ext-enable soap
# other configurations ...
This is outside the scope of this repo.
You should get it via this approach:
RUN apt-get update -y \
&& apt-get install -y \
libxml2-dev \
php-soap \
&& apt-get clean -y \
&& docker-php-ext-install soap