paint-brush
The Oracle Database Docker Image Can Supercharge Your DevOps Learningby@pazyp
654 reads
654 reads

The Oracle Database Docker Image Can Supercharge Your DevOps Learning

by Andrew PazikasFebruary 11th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

This is a tutorial on how to install, use, and patch the Oracle Database Docker Image. Docker is a PaaS that delivers software in packages called containers.

Company Mentioned

Mention Thumbnail
featured image - The Oracle Database Docker Image Can Supercharge Your DevOps Learning
Andrew Pazikas HackerNoon profile picture

What is Docker?

Docker is a set of Platform As A Service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. Because all of the containers share the services of a single operating system kernel, they use fewer resources than virtual machines.

I previously wrote these two blog posts about installing Oracle Database Docker Image, as well as patching an Oracle Database Docker Image. Today a slight cop-out of an article but I am combining both posts into a one-stop-shop for creating and patching an Oracle Database Docker Image.

Note – You will need to have a My Oracle Support login and valid support agreement to download Oracle Database patches if you don’t have one of these your not going to get very far. Further, if you have chosen to use a “slim” Oracle database docker image you will likely run into problems, during the “sliming” down process folders, are removed from the docker image that means when it comes to patching opatch will throw an error since some folders and directories don’t exist.

Useful Docker Commands

## Stop Docker Image
docker container stop oracle19.3 
##Start docker container
docker container start oracle19.3 
## Show running Docker containers
docker ps 
## List All Docker Images
docker images 
## Delete Docker Image
docker image rm "image_id_here"

Oracle Database Docker Image

Firstly, Oracle only has 12c available via Docker Hub they had some legal grievances with each other a few years ago which means Oracle no longer updates the Docker Hub images but instead stores them here on GitHub.

Another note is while the information on GitHub is great you still need to download the Oracle Database install .zip files from Oracle’s website yourself further if you plan on patching the Oracle database with docker you will need to have a valid Oracle Support license and login to MOS.

First, clone the Oracle Docker images to your local machine with Git.

git clone https://github.com/oracle/docker-images.git

After you have cloned the repo, you will see there is a lot more available than just Oracle Database images. For this article, that's all we are concerned with. Move to the OracleDatabase folder, then the SingleInstance folder, and finally to the 19.3.0 directory.

cd ~/docker-images/OracleDatabase/SingleInstance/19.3.0

With your downloaded Oracle Database, install .zip copy into your current 19.3.0 directory.

cp $HOME/Downloads/LINUX.X64_193000_db_home.zip .

If you plan on patching this Oracle Database with Docker in the future the default scripts remove some key directories within $ORACLE_HOME to reduce image size that will cause you to run into issues when trying to patch in the future, the fix is simple by default we choose to install the “SLIM” option we just need to update the Dockerfile within the 19.3.0 directory to read false.

ARG SLIMMING=false

Move back to the parent directory and run buildDockerImage.sh with a -v to specify database version in this case 19.3.0 and -e to indicate we want to use enterprise edition.

cd ~/docker-images/OracleDatabase/SingleInstance./buildDockerImage.sh -v 19.3.0 -e

Depending on the resources you have on your machine will depend on how quickly the next part goes, I would say on average it will take 20-30min so go have coffee; you should come back to a Build Complete message. We have not successfully created an Oracle database image.

To run the image use the following;

docker run --name "oracle19.3" -p 1521:1521 -p 5500:5500 -e ORACLE_PDB=orapdb1 -e ORACLE_PWD=topsecretpass -e ORACLE_MEM=3000 -v /opt/oracle/oradata -d oracle/database:19.3.0-ee

Where –name is the name of the docker image, ORACLE_PDB is the PDB name, ORACLE_PWD is the database password and ORACLE_MEM is the memory allocated to the DB. This first run of the docker image will go away and create the database so expect it to take some time during its first run.

You can use sqldeveloper to connect to your PDB or connect to sqlplus via docker by logging directly into the docker image as per below;

docker exec -it oracle19.3 /bin/bash
ps -ef |grep pmon. oraenvsqlplus / as sysdba

Patching Oracle Database Docker Image

Running an Oracle 19c database in docker you are not able to patch the
database in a traditional sense, you cannot hop into the container and patch it with opatch you need to create a “patched” image, thankfully Oracle on their GitHub (here) provides some shell scripts to make this task easier.

Clone the Oracle Docker images to your local machine with git (if you don’t already have them)

git clone https://github.com/oracle/docker-images.git

patches: The working directory for patch installation.

001: The directory containing the patch zip file.

00N: The second, third, … directory containing the second, third, … patch zip file. This is useful if you want to install multiple patches at once. The script will go into each of these directories in the numbered order and apply the patches.

Important: It is up to the user to guarantee the patch order if any.

Below is a working example where p31771877 is the latest 19c Critical Patch Update at the time of writing (Oct 2020) and p6880880 is the latest version of OPatch.

With the patches in place, we can now run buildPatchedDockerImage.sh to create the “new” patched docker image

./buildPatchedDockerImage.sh -e -v 19.3.0 -p Oct2020

It will take some time to patch the Oracle database with the patches as
rebuild the docker image so go make yourself a coffee and come back in
25-30min. Once you return all going well you should be able to start your new patched docker image with the following command:

docker run --name "oracle19.9" -p 1521:1521 -p 5500:5500 -e ORACLE_PDB=orapdb1 -e ORACLE_PWD=topsecretpass -e ORACLE_MEM=3000 -v /opt/oracle/oradata -d oracle/database:19.3.0-ee-Oct2020

You can now login to your patched Oracle Database docker image using the below commands;

docker exec -it oracle19.9 /bin/bash
ps -ef | grep pmon
. oraenv
sqlplus / as sysdba

Conclusions

I’ve been using Oracle Database Docker Images for a little while now, they are very convenient for quick development or if you need to check out a certain database parameter.

If you have any questions about running Oracle Database in Docker or the Oracle Database Docker Image, the process of creating or patching an image, and having problems please get in touch and I can help.

Previously published at https://pazikas.com/how-to-use-oracle-database-docker-image/