The default php:7.0.33-fpm image is missing a lot of modules, so building it directly using Dockerfile would be a bit of a hassle, and it’s also quite large. So I went directly into the container and installed it, and finally generated an image of my own tmaize/php7-fpm based on the container. I’ll record the steps here, maybe I’ll use them later

Description

The original image already has the following source code built in, but it is only compressed to reduce the size, not compiled and installed, so use docker-php-ext-install to install it yourself

1
2
3
4
5
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

Installation

Enter the container

1
2
docker run --name temp -d php:7.0.33-fpm
docker exec -it temp /bin/bash

Installation Module

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
docker-php-ext-install bcmath

apt-get update
apt-get install -y libbz2-dev
docker-php-ext-install bz2

docker-php-ext-install calendar

docker-php-ext-install exif

apt-get install -y libjpeg-dev libjpeg62-turbo-dev libwebp-dev libpng-dev libfreetype6-dev libxpm-dev
docker-php-ext-configure gd --with-webp-dir=/usr/include --with-png-dir=/usr/include \
--with-jpeg-dir=/usr/include --with-freetype-dir=/usr/include --with-xpm-dir=/usr/include
docker-php-ext-install gd
# php -r "var_dump(gd_info());"

docker-php-ext-install gettext

curl -O https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz
xz -d gmp-6.2.1.tar.xz
tar -xvf gmp-6.2.1.tar
cd gmp-6.2.1
./configure
make
make install
docker-php-ext-install gmp

docker-php-ext-install mysqli

docker-php-ext-install pcntl

docker-php-ext-install pdo_mysql

docker-php-ext-install shmop

docker-php-ext-install sockets

docker-php-ext-install zip

docker-php-ext-install opcache

cd ..
rm -rf ./*
apt-get clean
apt-get autoclean

# 使用生产配置
cd $PHP_INI_DIR
cp php.ini-production php.ini
history -c
exit

Push Mirror

1
2
3
4
5
docker container stop temp
docker commit -m "install modules" temp docker.io/tmaize/php7-fpm:1.0.0
docker login -u tmaize # 生成新的Access Tokens登录,不要使用密码
docker push docker.io/tmaize/php7-fpm:1.0.0
docker rm temp

php -m

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Reference

Php - Official Image