Create Oracle 19.9.0.0 Docker Image using Oracle RPMs

[oracle@dockerhost dockerOracle19c]$ docker images | grep database
oracle/database 19.3.0.0-ee-Patch 8483e0c56971 6 days ago 13.8GB
oracle/database 19.3.0-ee-original 7649f5068eee 6 days ago 7.75GB
oracle/database 19.3.0-ee e042121022bf 7 days ago 9.3GB
[oracle@dockerhost withrpms]$ tree
.
├── 19.3.0
│ ├── applypatches
│ │ ├── Dockerfile
│ │ └── Dockerfile.save
│ ├── checkDBStatus.sh
│ ├── checkSpace.sh
│ ├── Checksum.ee
│ ├── Checksum.se2
│ ├── compat-libcap1-1.10-7.el7.x86_64.rpm
│ ├── compat-libcap1-1.10-7.el7.x86_64.rpm.download
│ ├── compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
│ ├── compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm.download
│ ├── createDB.sh
│ ├── dbca.rsp.tmpl
│ ├── db_inst.rsp
│ ├── Dockerfile
│ ├── installDBBinaries.sh
│ ├── oracle19c.tar.gz
│ ├── oracle-database-ee-19c-1.0-1.x86_64.rpm
│ ├── oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
│ ├── oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm.download
│ ├── relinkOracleBinary.sh
│ ├── runOracle.sh
│ ├── runUserScripts.sh
│ ├── setPassword.sh
│ ├── setupLinuxEnv.sh
│ ├── startDB.sh
│ └── wallet
├── buildDockerImage.sh
[oracle@dockerhost opt]$ pwd
/opt
[oracle@dockerhost opt]$ ls
containerd dockerOracle19c oracle ORCLfmap
[oracle@dockerhost opt]$
[oracle@dockerhost opt]$ tar -cvzf /opt/dockerOracle19c/withrpms/19.3.0/oracle19c.tar.gz oracle
[oracle@dockerhost ~]$ cat /etc/group
...
...
oinstall:x:54321:oracle
dba:x:54322:oracle
oper:x:54323:oracle
backupdba:x:54324:oracle
dgdba:x:54325:oracle
kmdba:x:54326:oracle
racdba:x:54327:oracle

[oracle@dockerhost ~]$ cat /etc/passwd
...
...
oracle:x:54321:54321::/home/oracle:/bin/bash
[oracle@dockerhost 19.3.0]$ cat Dockerfile
# LICENSE UPL 1.0
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Database 19c
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# (1) db_home.zip
# Download Oracle Database 19c Enterprise Edition or Standard Edition 2 for Linux x64
# from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run:
# $ docker build -t oracle/database:19.3.0-${EDITION} .
#
# Pull base image
# ---------------
FROM oraclelinux:7-slim as base


# Labels
# ------
LABEL "provider"="Oracle" \
"issues"="https://github.com/oracle/docker-images/issues" \
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"


# Argument to control removal of components not needed after db software installation
ARG SLIMMING=false


# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORACLE_BASE=/opt/oracle \
ORACLE_HOME=/opt/oracle/product/19c/dbhome_1 \
INSTALL_DIR=/opt/install \
INSTALL_FILE_1="LINUX.X64_193000_db_home.zip" \
INSTALL_RSP="db_inst.rsp" \
CONFIG_RSP="dbca.rsp.tmpl" \
PWD_FILE="setPassword.sh" \
RUN_FILE="runOracle.sh" \
START_FILE="startDB.sh" \
CREATE_DB_FILE="createDB.sh" \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
USER_SCRIPTS_FILE="runUserScripts.sh" \
INSTALL_DB_BINARIES_FILE="installDBBinaries.sh" \
RELINK_BINARY_FILE="relinkOracleBinary.sh" \
SLIMMING=$SLIMMING


# Use second ENV so that variable get substituted
ENV PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH \
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib \
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib


# Copy files needed during both installation and runtime
# -------------
COPY $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DIR/
COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $USER_SCRIPTS_FILE $RELINK_BINARY_FILE $ORACLE_BASE/

# RAVI VERMA - I add the RPM files to make my approach work.
RUN mkdir -p /opt/
ADD compat-libcap1-1.10-7.el7.x86_64.rpm /opt/
ADD compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm /opt/
ADD oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm /opt/


RUN yum -y localinstall /opt/compat-libcap1-1.10-7.el7.x86_64.rpm && \
yum -y localinstall /opt/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm && \
yum -y localinstall /opt/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm && \
yum -y clean all && \
rm -f /opt/*.rpm
RUN chown -R oracle:oinstall /opt/oracle
USER oracle
# RAVI VERMA - I add to the image the zipped file of Oracle's patched installation.
ADD oracle19c.tar.gz /opt/
COPY --chown=oracle:oinstall wallet /opt/oracle/wallet
#RUN chown -R oracle:oinstall /opt/oracle/
CMD exec $ORACLE_BASE/$RUN_FILE
[oracle@dockerhost withrpms]$ ./buildDockerImage.sh -v 19.3.0 -e
[oracle@dockerhost withrpms]$ docker run -it oracle/database:19.3.0-ee sqlplus 
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jan 11 00:12:26 2021
Version 19.9.0.0.0 Copyright (c) 1982, 2020, Oracle. All rights reserved. Enter user-name:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store