install and enable OCI8 extension for php:8.1-fpm in Dockerfile


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 \
&& wget \
&& wget \
&& unzip -d /opt/oracle \
&& unzip -d /opt/oracle \
&& unzip -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 \

full dockerfile is here

docker-compose build: Successfully built with this warning:

Warning: PHP Startup: Unable to load dynamic library '' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20210902/ (Error loading shared library No such file or directory (needed by /usr/local/instantclient_21_6/, /usr/local/lib/php/extensions/no-debug-non-zts-20210902/ (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20210902/ 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?


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 No such file or directory

also this command shows what is exactly the missing libraries for

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

output: (0x00007ffe4017a000) => /opt/oracle/instantclient/ (0x00007fd247169000) => /lib/x86_64-linux-gnu/ (0x00007fd246fa0000) => /opt/oracle/instantclient/ (0x00007fd24692b000) => /lib/x86_64-linux-gnu/ (0x00007fd246925000) => /lib/x86_64-linux-gnu/ (0x00007fd2467e1000) => /lib/x86_64-linux-gnu/ (0x00007fd2467bf000) => /lib/x86_64-linux-gnu/ (0x00007fd2467b2000) => not found => /lib/x86_64-linux-gnu/ (0x00007fd246798000)
        /lib64/ (0x00007fd24b57f000) => /opt/oracle/instantclient/ (0x00007fd2461e8000) => not found

as the output says: is missing.

I solved it by Installing these packages:

RUN apt-get install libaio1 libaio-dev

Answered By – Al-Shahhoud Baraa

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published