Dockerfile php-fpm unmet dependencies - php

I have a Dockerfile in which to build a container for php-fpm. I pulled in my base ubuntu image and it gets to work but then exits when trying to install php-fpm and php5-intl due to unmet dependencies.
Can anyone check over my file and spot anything obvious please :)
FROM phalcon/ubuntu
MAINTAINER bob <bob#bob.com>
RUN echo "deb http://archive.ubuntu.com/ubuntu/ vivid universe" >> /etc/apt/sources.list
# Install software requirements
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:ondrej/php5 && \
add-apt-repository -y ppa:nginx/stable && \
apt-get update -y --force-yes && \
apt-get upgrade -y --force-yes && \
BUILD_PACKAGES="supervisor php5-fpm git php5-mysql php5-curl php5-gd php5-intl php5-mcrypt php5-memcache php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-pgsql php5-mongo php5-dev pwgen" && \
apt-get -y --force-yes install $BUILD_PACKAGES && \
apt-get remove --purge -y software-properties-common && \
apt-get autoremove -y && \
apt-get clean && \
apt-get autoclean
# Add PHP config.
ADD php-fpm.conf /etc/php-fpm.conf
# Define mountable directories.
VOLUME ["/etc/php-fpm.d", "/var/log/php-fpm", "/srv/http"]
# Define entrypoint.
ENTRYPOINT ["php-fpm"]
# Expose ports.
EXPOSE 9000

Probably some issue regarding the use of the source image phalcon/ubuntu from what I can see.
There's actually no reason to build your own PHP-FPM image, as official ones are supplied: https://hub.docker.com/_/php/ This way you can select the exact PHP version you want to use.
Just for kicks, here is the repository from which the image is built (PHP 5.6): https://github.com/docker-library/php/tree/master/5.6/fpm

Related

Uncaught Exception. could not find driver in docker container using sql server and base image php:7.3-apache

My docker file which is building successfully but in the time of login, getting this error "Uncaught Exception. could not find driver".
Application is using PDO extension for php to connect sql server.
FROM php:7.3-apache
# Env variables
ENV ACCEPT_EULA=y
# Install selected extensions and other stuff
RUN apt-get update \
&& apt-get -y --no-install-recommends install apt-utils libxml2-dev gnupg apt-transport-https \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
# Install git
RUN apt-get update \
&& apt-get -y install git \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
#Install ODBC Driver
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update
# Install sqlsrv
RUN apt-get update
RUN apt-get install -y wget
RUN wget http://ftp.br.debian.org/debian/pool/main/g/glibc/multiarch-support_2.24-11+deb9u4_amd64.deb && \
dpkg -i multiarch-support_2.24-11+deb9u4_amd64.deb
RUN apt-get -y install msodbcsql17 unixodbc-dev
RUN pecl install sqlsrv pdo_sqlsrv
# Install webapp extension
RUN apt-get update && \
apt-get install -y \
git libzip-dev libicu-dev\
&& docker-php-ext-install zip
RUN docker-php-ext-install intl mysqli pdo pdo_mysql
RUN a2enmod rewrite
COPY php.ini /usr/local/etc/php
COPY . /var/www/html/
EXPOSE 80/tcp
#EXPOSE 443/tcp
I have also added pdo extension entries for sqlsrv in my php.ini file
extension=pdo_sqlsrv.so
extension=sqlsrv.so

Docker PHP7 CLI Debian Buster how to install package php-imagick?

I have a PHP-CLI Docker image of Debian Buster and would like to install php-imagick package but with command:
Dockerfile:
RUN apt-get install -y php-imagick
I get an 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
E: Package 'php-imagick' has no installation candidate
running before:
RUN apt-get update -y && apt-get upgrade -y
did not help.
how come there is no package candidate for php-imagick?
how to install and enable imagick extension for this PHP Docker image?
Dockerfile to replicate issue:
FROM php:7.3-buster
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y php-imagick
build command
docker build --tag testimage .
Unless you have a good reason not to, using the packages from https://deb.sury.org/ is probably a good idea. The following appears to work:
FROM debian:buster-slim
USER root
# Get Debian up-to-date
RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y git \
mariadb-client wget curl \
ca-certificates lsb-release apt-transport-https gnupg bsdmainutils
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee -a /etc/apt/sources.list.d/php.list \
&& curl https://packages.sury.org/php/apt.gpg | apt-key add - \
&& apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y php7.3 php7.3-common php7.3-cli \
php7.3-mysql php7.3-curl php7.3-xml php7.3-mbstring \
php7.3-intl php7.3-redis php7.3-zip \
php7.3-imagick supervisor

Creating a custom docker container to match my server

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)

Installing ldap extension Docker

Hey all I am trying to instal ldap extension on a Docker php:5.6-fm images I need ldap for my project.
I have tired to install the extension through Dockerfile like so:
RUN apt-get install php5-ldap -y
get this error:
The LDAP PHP extension is not enabled.
I have also found some 'suggestion' online like so:
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
get this error:
An exception occurred in driver: could not find driver
am I doing something wrong...? How do I install ldap in a docker image so that I can use it in my project...?
Here is what I did... and it's working. I had other modules configured, but I don't think they interfere with anything.
FROM php:5.6-apache
RUN apt-get update -y \
&& apt-get install -y libcurl4-openssl-dev pkg-config libssl-dev vim
# Configure MongoDB.
RUN pecl install mongodb \
&& docker-php-ext-enable mongodb
# Configure MySQL.
RUN docker-php-ext-install mysqli
# Configure LDAP.
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
RUN a2enmod rewrite && service apache2 restart
# Python 2.7 and modules
RUN apt install python2.7 python-pip -y \
&& python2.7 -m pip install pymysql pymongo redis
# We must reconfigure here the CMD directive.
CMD apache2-foreground

phpbrew Bash init failure

I am at the initial stages of preparing for multiphp nginx following a complete install of Ubuntu and the git page
http://phpbrew.github.io/phpbrew/
I have duplicated steps followed here for clarity and re-installed Ubuntu and followed exactly what is below in case my error correction attempts were causing issues
https://docs.google.com/spreadsheets/d/1KbfqW5PqFejlCMV9yEUHgEr5FdCh5P6Ufv-HRQH3u9g/edit?usp=sharing
but fails with /usr/bin/env: php: No such file or directory.
Please check out our wiki and install the requirements
https://github.com/phpbrew/phpbrew/wiki/Requirement
apt-get build-dep php5
apt-get install -y php5 php5-dev php-pear autoconf automake curl libcurl3-openssl-dev build-essential libxslt1-dev re2c libxml2 libxml2-dev php5-cli bison libbz2-dev libreadline-dev
apt-get install -y libfreetype6 libfreetype6-dev libpng12-0 libpng12-dev libjpeg-dev libjpeg8-dev libjpeg8 libgd-dev libgd3 libxpm4 libltdl7 libltdl-dev
apt-get install -y libssl-dev openssl
apt-get install -y gettext libgettextpo-dev libgettextpo0
apt-get install -y libicu-dev
apt-get install -y libmhash-dev libmhash2
apt-get install -y libmcrypt-dev libmcrypt4
I did not post this without much effort trying to resolve first - about a day and many visited links.
Anyway the issue lay with thinking php was installed with Ubuntu +/ updates.
Note that phpbrew has php as one of its dependencies.
I guess a fresh OS install went against me on this occasion.
sudo apt-get install php5

Categories