Install oracle client in docker container
Asked Answered
P

5

14

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?

Pilfer answered 26/4, 2019 at 0:29 Comment(1)
For the record, recent Instant Clients can be downloaded without login or clickthrough.Honeysucker
K
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
    
Kirstinkirstyn answered 3/10, 2019 at 11:10 Comment(0)
R
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}"
Ratal answered 12/8, 2020 at 13:45 Comment(1)
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)Honeysucker
A
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

Appendicectomy answered 22/2, 2022 at 5:59 Comment(0)
H
1

You don't want to use Alpine Linux, since you will need to hack it and it could become unstable. See https://mcmap.net/q/829092/-oracle-on-alpine-linux 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
Honeysucker answered 4/6, 2019 at 6:26 Comment(8)
docker pull container-registry.oracle.com/database/instantclient:latest not working. Please update it.Brumbaugh
Use the Dockerfiles and customize to your needs.Honeysucker
There are now pre-built images with Instant Client at github.com/oracle/docker-images/pkgs/container/… and similar for Oracle Linux 7. You can pull with docker pull ghcr.io/oracle/oraclelinux8-instantclient:21Honeysucker
Is ghcr.io/oracle available, I get a 404?Westminster
Checking the links like github.com/oracle/docker-images/pkgs/container/… shows the commands are correct.Honeysucker
So, how do i use this image in my dockerfile instead of pulling it? I guess i am asking a very basic question about using dockerfile but any help on this is appreciated. I am trying to use instantclient on a python app that is going to run in a container. I used to have the syntax of dockerfile starting as FROM python:3, which i think is now implicit on Oraclelinux:8, but should i use from oraclelinux8-instantclient:21 instead?Sibelle
@Sibelle see Docker for Oracle Database Applications in Node.js and Python. Note that with python-oracledb, which is the most recent Python driver for Oracle DB, most people don't need to install Instant Client at all.Honeysucker
This really solved by switching to "oracledb" library instead of "cx_oracle" and i completely ignored the instant client installation in my docker and it works like charm. This is purely my case where i am going with light weight oracledb, where i need to READ data and using sqlalchemy > 2.0.0 to support oracledb.Sibelle
C
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

Crider answered 5/3, 2023 at 10:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.