php7.2-openssl Alpine Docker install error

  alpine, composer-php, docker, php, php-openssl

I’m building a Docker image with Alpine, php7.2-fpm and Composer.

The problem happens while trying to install Composer, which uses https to download the installer via php.

I added the repository to be able to install php7.2 (which is used to install composer) and its packages:

RUN wget -O /etc/apk/keys/phpearth.rsa.pub https://repos.php.earth/alpine/phpearth.rsa.pub && 
    echo "https://repos.php.earth/alpine/v3.7" >> /etc/apk/repositories && 
    apk update

The following error occurs when I try to download composer:

/ # php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
PHP Warning:  PHP Startup: Unable to load dynamic library 'openssl' (tried: /usr/lib/php/7.2/modules/openssl (Error loading shared library /usr/lib/php/7.2/modules/openssl: No such file or directory), /usr/lib/php/7.2/modules/openssl.so (Error loading shared library /usr/lib/php/7.2/modules/openssl.so: No such file or directory)) in Unknown on line 0
PHP Warning:  copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP   2. copy() Command line code:1
PHP Warning:  copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP   2. copy() Command line code:1
PHP Warning:  copy(https://getcomposer.org/installer): failed to open stream: No such file or directory in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
PHP   2. copy() Command line code:1

Searching about this error, all I found was related do the openssl php extension.

When trying to install the php7.2-openssl extensions, I get the following error message:

/ # apk add php7.2-openssl
ERROR: unable to select packages:
  php7.2-igbinary (no such package):
    required by: world[php7.2-igbinary]
  php7.2-msgpack (no such package):
    required by: world[php7.2-msgpack]
  php7.2-readline (no such package):
    required by: world[php7.2-readline]
  so:libcrypto.so.42 (no such package):
    required by: php7.2-openssl-7.2.16-r0[so:libcrypto.so.42]
  so:libssl.so.44 (no such package):
    required by: php7.2-openssl-7.2.16-r0[so:libssl.so.44]

If I force the installation with "-f", it looks like it installed, but not really. The apk list php* --installed command does not show the openssl extension and the https request still returning the same https error.

Another way to install Composer would not be the best thing for me. Eventually I will need to use https through php anyway.

I’m using the last Alpine Docker base image version to date. Which is "3.14.2".

I wonder if it has something to do with the added repository version (3.7) compared to the image version (3.14.2).

I’d love to understand what is happening.

Source: Docker Questions

LEAVE A COMMENT