Oracle Database with Docker

Running an Oracle database with Docker is a fairly simple task but I thought it would be useful to document the steps required for reference as I will likely need to refer to then in the future and to help others starting out on this path on how to run Oracle Database with Docker.

Oracle Database with Docker

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 licence and login to MOS.

Firstly 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 but for this article its all we are concerned with, move to the OracleDatabase folder, then the SingleInstance folder and finally the 19.3.0 directory.

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

With your downloaded Oracle Database install .zip copy in 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

. oraenv

sqlplus / as sysdba

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"

And that’s all there is to it, it’s not a hard process and once you have been through it once or twice it becomes second nature. I’ve found great benefit running Oracle database with Docker, previously I had multiple Virtual machines with each database version on then now I just have Oracle database docker images that I can have running and access when I need them. If you enjoyed this article about Oracle database with Docker, please read my follow up on patching oracle database docker images here.

2 responses to “Oracle Database with Docker”

  1. Ferv avatar
    Ferv

    I have this error: on fedora 37 x86_64 this error ocurred after this command

    ./buildDockerImage.sh -v 19.3.0 -e

    but i can’t use this command without sudo, a use this:

    sudo ./buildDockerImage.sh -v 19.3.0 -e

    — error show

    Step 19/24 : RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && $ORACLE_HOME/root.sh
    —> Running in f31fd09e92f2
    /bin/sh: /opt/oracle/oraInventory/orainstRoot.sh: No such file or directory
    Removing intermediate container f31fd09e92f2
    The command ‘/bin/sh -c $ORACLE_BASE/oraInventory/orainstRoot.sh && $ORACLE_HOME/root.sh’ returned a non-zero code: 127

    ERROR: Oracle Database container image was NOT successfully created.
    ERROR: Check the output and correct any reported problems with the build operation.

    REPOSITORY TAG IMAGE ID CREATED SIZE
    6ab1487eb6ff 3 minutes ago 7.17GB
    ba0848374df6 4 minutes ago 10.2GB
    01c60dd01ed5 3 hours ago 135MB
    oraclelinux 7-slim 779edc935fbd 5 days ago 135MB

    1. PazyP avatar

      Do you have the install files, looks like its been unable to copy orainstRoot.sh to your container.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.