skip to Main Content

I’m trying to install and enable OCI8 in dockerfile for php:8.1-fpm
image to ..

This is a part of my Dockerfile:

RUN mkdir /opt/oracle
# Install Oracle Instantclient
RUN wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip 
&& wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-sdk-linux.x64-21.6.0.0.0dbru.zip 
&& wget https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-sqlplus-linux.x64-21.6.0.0.0dbru.zip 
&& unzip instantclient-basic-linux.x64-21.6.0.0.0dbru.zip -d /opt/oracle 
&& unzip instantclient-sdk-linux.x64-21.6.0.0.0dbru.zip -d /opt/oracle 
&& unzip instantclient-sqlplus-linux.x64-21.6.0.0.0dbru.zip -d /opt/oracle 
&& rm -rf *.zip 
&& mv /opt/oracle/instantclient_21_6 /opt/oracle/instantclient

#add oracle instantclient path to environment
ENV LD_LIBRARY_PATH /opt/oracle/instantclient/
RUN ldconfig

# Install Oracle extensions
RUN docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/opt/oracle/instantclient,21.1 
&& echo 'instantclient,/opt/oracle/instantclient/' | pecl install oci8 
&& docker-php-ext-install 
        pdo_oci 
&& docker-php-ext-enable 
        oci8

full dockerfile is here

docker-compose build: Successfully built with this warning:

Warning: PHP Startup: Unable to load dynamic library 'pdo_oci.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_oci.so (Error loading shared library libaio.so.1: No such file or directory (needed by /usr/local/instantclient_21_6/libclntsh.so.21.1)), /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_oci.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20210902/pdo_oci.so.so: No such file or directory)) in Unknown on line 0

when I checked for the exited extensions using RUN php -m just after the installation is done with warnings, I have found out that oci8 is not installed.

So how to fix it?

2

Answers


  1. Chosen as BEST ANSWER

    At first I thought it was a path issue, but the real error which was clear in part of the warning message:

    Error loading shared library libaio.so.1: No such file or directory

    also this command shows what is exactly the missing libraries for oci8.so:

    RUN ldd /usr/local/lib/php/extensions/no-debug-non-zts-20210902/oci8.so
    

    output:

            linux-vdso.so.1 (0x00007ffe4017a000)
            libclntsh.so.21.1 => /opt/oracle/instantclient/libclntsh.so.21.1 (0x00007fd247169000)
            libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd246fa0000)
            libnnz21.so => /opt/oracle/instantclient/libnnz21.so (0x00007fd24692b000)
            libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd246925000)
            libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd2467e1000)
            libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd2467bf000)
            librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fd2467b2000)
            libaio.so.1 => not found
            libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fd246798000)
            /lib64/ld-linux-x86-64.so.2 (0x00007fd24b57f000)
            libclntshcore.so.21.1 => /opt/oracle/instantclient/libclntshcore.so.21.1 (0x00007fd2461e8000)
            libaio.so.1 => not found
    

    as the output says: libaio.so.1 is missing.

    I solved it by Installing these packages:

    RUN apt-get install libaio1 libaio-dev
    

  2. Set the system library search path to contain the Instant Client libraries before installing the PHP extensions. The best way is to use ldconfig as recommended in the Instant Client installation instructions. In your case it would be:

    RUN echo /opt/oracle/instantclient_21_6/ > /etc/ld.so.conf.d/oic.conf && 
        ldconfig
    

    This would also mean you can remove LD_LIBRARY_PATH from the step RUN LD_LIBRARY_PATH=/usr/local/instantclient_21_6/ php. In fact, that whole line isn’t useful.

    You may find some of the Instant Client tips in Docker for Oracle Database Applications in Node.js and Python useful.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search