Libresolv dependency for Alpine linux

Viewed 4818

I have Alpine v3.7 Docker image and to put things short, I am installing OCI8 extension for PHP.

When doing the php -v I get the following error:

PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so (Error loading shared library libresolv.so.2: No such file or directory (needed by /usr/local/instantclient/libclntsh.so.18.1)), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so.so: No such file or directory)) in Unknown on line 0

I can't seem to find what package do I have to install in order to make this work. I have seen that there is a libresolv.a (I have also searched here and see there is no libresolv.so.* file in Alpine by defaut) file in my /usr/lib/ folder so I tried sym-linking it back to Oracle folder, however that does nothing, I am still getting the same error.

These are the packages I am installing on Docker container create:

RUN apk add --update \
    autoconf gcc g++ make libaio-dev libnsl gettext-dev automake libtool libc6-compat;
1 Answers

The problem is that you are using instaclient 18.

Using Oracle instaclient 11 you only have to add

FROM alpine3.11

# Setup LD lib path 
ENV LD_LIBRARY_PATH=/usr/local/instantclient_11_2

# Install Apline dependencies
RUN apk add gcc libnsl libaio curl unzip openssl-dev autoconf musl-dev

RUN curl -k -o /tmp/basic.zip https://raw.githubusercontent.com/wilo087/Oracle-Instaclient_11_2/master/instantclient-basic-linux.x64-11.2.0.4.0.zip

# Unzip downloaded library
RUN unzip -d /usr/local/ /tmp/basic.zip

# Link Libs
RUN ln -sf ${LD_LIBRARY_PATH}/libclntsh.so.19.1 ${LD_LIBRARY_PATH}/libclntsh.so; \
  ln -s ${ORACLE_HOME}/libocci.so.* ${ORACLE_HOME}/libocci.so; \

# The libnsl version installed by Alpine is the number two, and instaclient use the number 1 so, create symbolic link for number one
RUN ln -sf /usr/lib/libnsl.so.2.0.0  /usr/lib/libnsl.so.1
Related