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
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
:output:
as the output says:
libaio.so.1
is missing.I solved it by Installing these packages:
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: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.