I'm trying to create a Docker image based on Alpine Linux which will run PHP 7.1 (apk add php7=7.1.9-r0
) with some modules installed (memcached
, mongodb
, oauth
, openssl
and redis
).
I install the modules through PECL like this:
RUN yes | pecl install \
igbinary \
redis-3.1.4 \
oauth-2.0.2 \
memcached-3.0.4 \
mongodb-1.3.3
Then add each of them to php.ini
.
RUN for EXT in \
igbinary \
memcached \
mongodb \
oauth \
openssl \
redis; \
do \
echo "extension=${EXT}.so" >> /etc/php7/php.ini; \
done
Most modules install correctly, but memcached
and redis
don't want to play along:
# php -v
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php7/modules/memcached.so' - Error relocating /usr/lib/php7/modules/memcached.so: php_session_create_id: symbol not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php7/modules/redis.so' - Error relocating /usr/lib/php7/modules/redis.so: php_session_register_module: symbol not found in Unknown on line 0
PHP Warning: Module 'openssl' already loaded in Unknown on line 0
PHP Warning: Cannot load module 'mongodb' because required module 'json' is not loaded in Unknown on line 0
PHP 7.1.9 (cli) (built: Oct 2 2017 20:51:54) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
I've also tried from source:
RUN git clone https://github.com/php-memcached-dev/php-memcached
RUN cd php-memcached \
&& git checkout php7 \
&& git pull \
&& /usr/bin/phpize \
&& ./configure --with-php-config=/usr/bin/php-config \
&& make \
&& make install
This however gives me the same result. I've done some searching and apparently there might be some related problem of glibc
on Alpine (example thread) but I'm not quite sure this is the same issue as the error output is a bit confusing.
Is there anything I'm overlooking as to how these modules should be installed to work with PHP 7.1 on Alpine Linux?