skip to Main Content

Hello I have a really simple dockerfile who is the following:

FROM php:8.2-fpm

ARG URL_INSTALL_CLIENT_BASIC='https://download.oracle.com/otn_software/linux/instantclient/2110000/instantclient-basic-linux.x64-21.10.0.0.0dbru.zip'
ARG URL_INSTALL_CLIENT_SDK='https://download.oracle.com/otn_software/linux/instantclient/2110000/instantclient-sdk-linux.x64-21.10.0.0.0dbru.zip'

RUN apt-get update

RUN apt install -y unzip curl

RUN mkdir /opt/oracle
RUN curl ${URL_INSTALL_CLIENT_BASIC} --output /opt/oracle/instantclient-basic-linux.zip
RUN curl ${URL_INSTALL_CLIENT_SDK} --output /opt/oracle/instantclient-sdk-linux.zip
RUN unzip '/opt/oracle/instantclient-basic-linux.zip' -d /opt/oracle
RUN unzip '/opt/oracle/instantclient-sdk-linux.zip' -d /opt/oracle
RUN rm /opt/oracle/instantclient-*.zip
RUN mv /opt/oracle/instantclient_* /opt/oracle/instantclient
RUN docker-php-ext-configure oci8 --with-oci8=instantclient,/opt/oracle/instantclient
RUN docker-php-ext-install oci8
RUN echo /opt/oracle/instantclient/ > /etc/ld.so.conf.d/oracle-insantclient.conf
RUN ldconfig

I have been through the documentation to see how install it. I followed it exactly.

When I build the docker image docker build . -t mytest no error

but when I check extensions OCI8 is missing docker run mytest:latest php -m.

I have this nice warning

Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20220829/oci8.so (libaio.so.1: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20220829/oci8.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20220829/oci8.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[PHP Modules]
Core
ctype
...

do you have any idea what I missed ?

Thank you

PS @Paul W:
The following command docker run mytest:latest ls -la /opt/oracle/instantclient provide me this result. This is like the lib folder I guess:

total 245440
drwxr-xr-x 4 root root      4096 Oct 18 12:03 .
drwxr-xr-x 1 root root      4096 Oct 18 12:03 ..
-rw-r--r-- 1 root root      5780 Jun 28  2022 BASIC_LICENSE
-rw-r--r-- 1 root root      1631 Jun 28  2022 BASIC_README
-rw-r--r-- 1 root root      5780 Jun 28  2022 SDK_LICENSE
-rw-rw-r-- 1 root root      1625 Jun 28  2022 SDK_README
-rwxr-xr-x 1 root root     42160 Jun 28  2022 adrci
-rwxr-xr-x 1 root root     59536 Jun 28  2022 genezi
lrwxrwxrwx 1 root root        17 Oct 18 12:03 libclntsh.so -> libclntsh.so.21.1
lrwxrwxrwx 1 root root        17 Oct 18 12:03 libclntsh.so.10.1 -> libclntsh.so.21.1
lrwxrwxrwx 1 root root        17 Oct 18 12:03 libclntsh.so.11.1 -> libclntsh.so.21.1
...

PS2 @Paul W:
what is really weird is if I follow the warning, this file is missing /usr/local/lib/php/extensions/no-debug-non-zts-20220829/oci8.so but it’ exist and every body can read it ….

But it’s exist :

docker run mytest:latest ls -la /usr/local/lib/php/extensions/no-debug-non-zts-20220829/oci8.so
-rwxr-xr-x 1 root root 192664 Oct 18 12:03 /usr/local/lib/php/extensions/no-debug-non-zts-20220829/oci8.so

2

Answers


  1. Chosen as BEST ANSWER

    I did not see it into the doc, but apparently oracle has more dependencies ...

    If I install this the dockerfile now works without warning

    libaio1

    FROM php:8.2-fpm
    
    ARG URL_INSTALL_CLIENT_BASIC='https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basic-linux.x64-21.7.0.0.0dbru.zip'
    ARG URL_INSTALL_CLIENT_SDK='https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-sdk-linux.x64-21.7.0.0.0dbru.zip'
    
    RUN apt-get update
    
    RUN apt install -y unzip curl libaio1
    
    RUN mkdir /opt/oracle
    RUN curl ${URL_INSTALL_CLIENT_BASIC} --output /opt/oracle/instantclient-basic-linux.zip
    RUN curl ${URL_INSTALL_CLIENT_SDK} --output /opt/oracle/instantclient-sdk-linux.zip
    RUN unzip '/opt/oracle/instantclient-basic-linux.zip' -d /opt/oracle
    RUN unzip '/opt/oracle/instantclient-sdk-linux.zip' -d /opt/oracle
    RUN rm /opt/oracle/instantclient-*.zip
    RUN mv /opt/oracle/instantclient_* /opt/oracle/instantclient
    RUN docker-php-ext-configure oci8 --with-oci8=instantclient,/opt/oracle/instantclient
    RUN docker-php-ext-install oci8
    RUN echo /opt/oracle/instantclient/ > /etc/ld.so.conf.d/oracle-insantclient.conf
    RUN ldconfig
    

  2. I’m not very experienced at this but I have a similar setup that I managed to get working for me. If it helps, this is my build:

    FROM registry.access.redhat.com/rhscl/httpd-24-rhel7
    
    # Become root
    
    USER 0
    
    # Install Oracle InstantClient
    
    RUN yum -y localinstall 
    https://download.oracle.com/otn_software/linux/instantclient/oracle-instantclient-basic-linuxx64.rpm 
    https://download.oracle.com/otn_software/linux/instantclient/oracle-instantclient-sqlplus-linuxx64.rpm 
    https://download.oracle.com/otn_software/linux/instantclient/oracle-instantclient-devel-linuxx64.rpm
    
    # Install prerequisites
    
    RUN yum install gcc libtool httpd24-httpd-devel libxml2-devel sqlite-devel -y
    
    # Install PHP with OCI8 statically compiled
    
    RUN curl -O https://www.mirrorservice.org/sites/www.php.net/distributions/php-7.4.10.tar.gz && 
    tar -xvf php-7.4.10.tar.gz && 
    cd php-7.4.10 && 
    ./configure --with-zlib=/usr/include --with-apxs2=/opt/rh/httpd24/root/usr/bin/apxs --with-oci8=shared,instantclient,/usr/lib/oracle/19.9/client64/lib && 
    make && 
    make install
    

    Note particularly the line:

    --with-oci8=shared,instantclient,/usr/lib/oracle/19.9/client64/lib

    I suspect you may need the reference to the lib dir of the instant client software directory.

    I also have this to configure it further:

    # Configure PHP (php.ini)
    
    RUN 
    cd php-7.4.10 && 
    export PHPLOC=/usr/local/lib/php.ini && 
    cp php.ini-production $PHPLOC && 
    sed 's/;date.timezone.*$/date.timezone = America/Chicago/; 
         s/display_errors = Off/display_errors = On/; 
         s/display_startup_errors = Off/display_startup_errors = On/' < $PHPLOC > $PHPLOC.new && 
    mv $PHPLOC.new $PHPLOC && 
    echo $' n
    extension=oci8.so n
    extension_dir=/opt/app-root/src/php-7.4.10/modules' >> $PHPLOC
    

    Note the extension=oci8.so and extension_dir variables being set in php.ini. That may be worth looking at as well. And lastly, in my configuration of Apache, I have this just before starting up httpd:

    # Oracle environment
    
    ENV ORACLE_HOME=/usr/lib/oracle/19.8/client64 
        LD_LIBRARY_PATH=/usr/lib/oracle/19.8/client64/lib:/opt/rh/httpd24/root/usr/lib64:/lib
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search