user5047085
user5047085

Reputation:

Install oracle client in docker container

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?

Upvotes: 14

Views: 49929

Answers (5)

user2015398
user2015398

Reputation: 604

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

Upvotes: 0

Christopher Jones
Christopher Jones

Reputation: 10496

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

Upvotes: 1

Aniket Tiwari
Aniket Tiwari

Reputation: 3998

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

Upvotes: 3

Marcel Pfeiffer
Marcel Pfeiffer

Reputation: 1068

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}"

Upvotes: 7

Mohammad Sayeed
Mohammad Sayeed

Reputation: 2135

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
    

Upvotes: 12

Related Questions