How to create an Oracle Database Docker Image

In this post, I m going to present a way to create an Oracle Database docker image. Actually it’s a quite easy task since Oracle has already provided the source code for this kind of job. You can find the Oracle provided code along with the relevant documentation here.

Prerequisites

The only prerequisite for creating the Oracle Database docker image is the database instance binary file which can be downloaded from here. In order to download the software you are required to own an oracle account. Downloading from OTN files requires the acceptance of the license agreement. After downloading the binary the remaining steps can be easily automated ( shell scripts, maven etc ).You can additionally deploy the downloaded zip file in your maven remote repository ( nexus, artifactory ) and utilize the maven along with your CI system in order to provide specific oracle database docker images.

I’m going to create the docker image of a single instance for demo purposes. I chose Oracle Database version 12.2.0.1 ee. You can download the binary from the following oracle link:

https://download.oracle.com/otn/linux/oracle12c/122010/linuxx64_12201_database.zip.

Source code structure

I have separated the project in 3 folders. The first one named “base” creates the base image namely : oracle/database:12.2.0.1-ee.

The second folder named “extension” uses the base image in order to create a custom oracle image. Actually this is a good practice in order to avoid providing passwords and sid in docker run commands or inside compose files.

Finally, the compose-files folder contains a sample docker-compose.yml file demonstrating how the docker container is created. The container is going to create a volume. The startup is going to take some time. If you mount the volume the next run of the container will be significantly faster. The docker-compose file uses a named volume ( oradata ).

 

Changing Default Configurations

By default the Oracle docker image , is configured to make expired the user passwords after some months. This can be verified by executing the following statement as sys

select * from dba_profiles WHERE resource_name='PASSWORD_LIFE_TIME';

In order to change the default configuration you must execute the following statement as sys

ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

Source Code

I have pushed the scripts for creating the docker image in my github repo. You can find the code here :

https://github.com/sergouniotis/oracle-db-docker-image.git

Next Steps

You can include in the extended image further utilities for various tasks. Some examples are : jre , flyway , database utilities etc. Furthermore you can push your extended docker image to your docker registry and use it as a reference in your various projects.

Refererences

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