How to use Oracle Database Docker images with Kubernetes

In this Blog I am going to show how we can use the Oracle provided Docker build scripts, and Oracle database zip files to create database image files for use with Kubernetes.

Please note all the Oracle Docker database build scripts (except Oracle Express Edition) require you to manually download the database zip files from OTN in advance. Therefore before you start you will need an valid OTN account and appropriate licences in place.

Ok, let’s start by cloning the Oracle maintained Docker files from GitHub.

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

Navigate to the SingleInstance dockerfiles directory e.g.

$ cd docker-images/OracleDatabase/SingleInstance/dockerfiles

Copy the downloaded database zip file into the version database version directory e.g. LINUX.X64_193000_db_home.zip into the 19.3.0 sub-directory.

And build the image with

$ ./buildDockerImage.sh -v 19.3.0 -e

The script installs the Oracle Database software, but it does not create and configure a database. When the build has been complete, you can verify the image has been created by listing the available Docker images.

$ docker images
REPOSITORY        TAG             IMAGE ID         CREATED             SIZE
oracle/database   19.3.0-ee       4f71dcdbe91e     21 minutes ago      6.51GB
oraclelinux       7-slim          f23503228fa1     3 weeks ago         120MB

The Oracle Database image we created is understood by Docker. However, our Kubernetes cluster is not aware of the newly built image.

However we can export the Oracle 19c image from the local Docker daemon using docker save

$ docker save oracle/database > oracle19c.tar
$ ls -lh
-rw-rw-r-- 1 pureuser pureuser 6.1G May  7 12:29 oracle19c.tar

And import into our MicroK8s Kubernetes cluster with microk8s ctr image import

$ microk8s ctr image import oracle19c.tar
unpacking docker.io/oracle/database:19.3.0-ee (sha256:8b5423b7329e1880c606b322898c320ff16b75eb4b16145ac41d9aa90e16557e)...done

We can list images available to MicroK8s with microk8s ctr image list

$ microk8s ctr image list | grep database:19
docker.io/oracle/database:19.3.0-ee                                                                                 application/vnd.oci.image.manifest.v1+json                sha256:8b5423b7329e1880c606b322898c320ff16b75eb4b16145ac41d9aa90e16557e 6.1 GiB   linux/amd64                                                                 io.cri-containerd.image=managed 

Alternatively, if you have a Kubernetes registry configured you could use docker tag

 $ docker tag 4f71dcdbe91e registry:32000/oracledb:19.3.0-ee

And now push into registry

$ docker push registry:32000/oracledb:19.3.0-ee
The push refers to repository [registry:32000/oracledb]
19a37326de4c: Pushed 
52609f251959: Pushed 
26625c19e268: Pushed 
cebf607d7c18: Pushed 
6f29b238b8e1: Pushed 
bc198e3a2f79: Layer already exists 
19.3.0-ee: digest: sha256:86f2f7e81bdf4565d69e0aaeccce856f3fb0ee3502a6e3ecdb005dc297004de8 size: 1581

We can use CURL to check our new 19c image is available.

$ curl -X GET http://registry:32000/v2/oracledb/tags/list
{"name":"oracledb","tags":["19.3.0-ee","18.4.0-xe"]}

Before you move on, if you’re tight for space you may want to remove the newly created Docker image with docker rmi <docker id>

You can use the below to review detailed information about the image, including ORACLE_BASE, ORACLE_HOME, mount points, directory structures and scripts used with the image.

$ curl  http://registry:32000/v2/oracledb/manifests/19.3.0-ee

Now, we have a new Oracle 19c image registered within our Kubernetes cluster ready to create a 19c database.

If your interested in the next step, you can see read more here.

[twitter-follow screen_name=’RonEkins’ show_count=’yes’]

Leave a Reply

Create a website or blog at WordPress.com

Up ↑

Discover more from Ron Ekins' - Oracle Technology, DevOps and Kubernetes Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading