13

I am using alpine linux as a base image, and I need to install an oracle client native library. I believe you can download from here:

https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

  1. it looks like I have to login to download, does anyone know how to download a zip file of the client lib without login?

  2. does anyone know how to install the client library properly in a bash script or dockerfile?

5 Answers5

12

I have figure out some different way to install Oracle instant client in ubuntu Docker, it might help others

Follow these simple steps:

  1. Download oracle instant client (.rpm file) from oracle official download center

  2. Convert into .deb (you can use apt-get install alien ) and move somewhere in your working directory.

  3. Now Update your Dockerfile and make build

    RUN apt-get update
    WORKDIR /opt
    ADD ./ORACLE-INSTANT-CLIENT.deb  /opt
    #if libaio also required
    RUN apt-get install libaio1 
    RUN dpkg -i oracle-instantclient.deb
    
Mohammad Sayeed
  • 2,025
  • 1
  • 16
  • 27
7

Here is a working solution for the official PHP-FPM images based on Debian 10 (Buster). The following Dockerfile installs the Oracle Instant Client 18.5 (basiclite and devel) using the RPM packges and alien.

As Christopher Jones wrote the files can currently be downloaded without an Oracle account.

FROM php:7.2.32-fpm

# see https://help.ubuntu.com/community/Oracle%20Instant%20Client
RUN apt-get update && apt-get install -y --no-install-recommends alien libaio1 wget && \
    wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-basiclite-18.5.0.0.0-3.x86_64.rpm && \
    wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm && \
    alien -i oracle-instantclient18.5-basiclite-18.5.0.0.0-3.x86_64.rpm && \
    alien -i oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm
ENV LD_LIBRARY_PATH="/usr/lib/oracle/18.5/client64/lib:${LD_LIBRARY_PATH}"
Marcel Pfeiffer
  • 1,018
  • 11
  • 12
  • I thought alien converted the RPM package's ldconfig postinstall script. If it does convert it, then you don't need to set LD_LIBRARY_PATH (Adn you can get 19.8 now, which connects to the same DB versions as 18) – Christopher Jones Aug 12 '20 at 22:39
3

If you want to download oracle at runtime then you can run the below commands

FROM ruby:3.0


ENV LD_LIBRARY_PATH=/opt/oracle/instantclient_21_4

RUN apt-get update && \
    apt-get install -y libpq-dev zlib1g-dev build-essential shared-mime-info libaio1 libaio-dev unzip wget --no-install-recommends && \
    wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip && \
    wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
    wget https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip && \
    mkdir -p /opt/oracle && \
    cp instantclient-* /opt/oracle/ && \
    cd /opt/oracle/ && \
    unzip instantclient-basic-linux.x64-21.4.0.0.0dbru.zip && \
    unzip instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip && \
    unzip instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
    rm -rf /var/lib/apt/lists/* instantclient-basic-linux.x64-21.4.0.0.0dbru.zip instantclient-sdk-linux.x64-21.4.0.0.0dbru.zip instantclient-sqlplus-linux.x64-21.4.0.0.0dbru.zip && \
    apt -y clean && \
    apt -y remove wget unzip && \
    apt -y autoremove && \
    rm -rf /var/cache/apt

You can download the specific version of instantclient by specifying the version above

These two packages are require for ruby-oci if you are using ruby on rails application

libaio1

libaio-dev

Aniket Tiwari
  • 3,561
  • 4
  • 21
  • 61
1

You don't want to use Alpine Linux, since you will need to hack it and it could become unstable. See https://stackoverflow.com/a/53291026/4799035 for more comments.

Also see https://github.com/oracle/docker-images/blob/master/OracleInstantClient/dockerfiles/19/Dockerfile which doesn't need any login.

In summary, on Oracle Linux 7:

yum -y install oracle-release-el7
yum -y install oracle-instantclient19.3-basic && rm -rf /var/cache/yum

Update: Oracle has Docker images at https://github.com/oracle/docker-images/pkgs/container/oraclelinux7-instantclient and https://github.com/oracle/docker-images/pkgs/container/oraclelinux8-instantclient which can be pulled like:

docker pull ghcr.io/oracle/oraclelinux7-instantclient:21

and

docker pull ghcr.io/oracle/oraclelinux8-instantclient:21
Christopher Jones
  • 9,449
  • 3
  • 24
  • 48
1

As Oracle official state: Instant Client is available for Docker Dockerfiles are available on GitHub. Pre-built images are available from the GitHub Container Registry. Here: https://www.oracle.com/database/technologies/instant-client.html

user2015398
  • 536
  • 4
  • 10