I created a Dockerfile like below
FROM ubuntu:14.04
RUN apt-get update -y && apt-get install -y software-properties-common language-pack-en-base
RUN LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
RUN apt-get -y update && apt-get install -y \
php7.0 \
php7.0-pgsql \
php-pear \
php7.0-curl \
php7.0-sqlite3 \
php7.0-xml \
php7.0-bcmath \
php7.0-zip \
php7.0-mbstring \
php-xdebug \
php-ast
WORKDIR /var/www/html/code
When i run docker-compose build container_name
And docker-compose run --rm container_name php -m
It seems like not all the php modules were installed during the build of the container. As the result shows below.
[PHP Modules]
ast
calendar
Core
ctype
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xdebug
Zend OPcache
zlib
[Zend Modules]
Xdebug
Zend OPcache
I did not get the php modules that i exepected to see like pdo_pgsql
, xml
, xmlreader
and etc.
I would use the official PHP image from Dockerhub. It has a utility script built in for installing and enabling PHP extensions. A revised Dockerfile for your needs could be something like this:
FROM php:7
RUN docker-php-ext-install <YOUR-EXTENSIONS>
WORKDIR /var/www/html/code
where YOUR-EXTENSIONS is possible values from this list:
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 mcrypt
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 spl standard
sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc
xmlwriter xsl zip
There are other tags for other versions on the image on Dockerhub - Check the docs there
Hope this helps
Dylan
Instead of...
docker-compose run --rm container_name php -m
...type:
docker-compose run --rm container_name php7.0 -m
OR
In the Dockerfile, just before ...
WORKDIR /var/www/html/code
...add:
RUN update-alternatives --set php /usr/bin/php7.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With