Installing Oracle Database 19.3 in a Docker container on Ubuntu Server 18.04

First I installed Ubuntu Server 18.04 as a Hyper-V machine on Windows 10.

While creating the virtual machine I selected Generation 1, because Generation 2 resulted in some strange effects.

Then I created a separate user with sudo permission:

sudo useradd -d /home/singh -m --shell "/bin/bash" singh
sudo passwd singh
sudo usermod -aG sudo singh

The user can be deleted from sudo group with the command:

sudo deluser singh sudo

Downloaded Oracle Database 19.3 (file LINUX.X64_193000_db_home.zip) and built Docker image from https://github.com/oracle/docker-images/blob/master/OracleDatabase/SingleInstance/dockerfiles/19.3.0/Dockerfile with the following command:

sudo docker build -t oracle/database:19ee --build-arg DB_EDITION=EE .

Then I created user ‘oracle’ and a directory for Oracle data:

sudo useradd -d /home/oracle -m --uid 54321 --shell "/bin/bash" oracle
sudo su - oracle
mkdir oradata19ee

Now I start the container with this command:

sudo docker run -d -it --rm --name oracle19ee -v /home/oracle/oradata19ee:/opt/oracle/oradata -p 1521:1521 -p 5500:5500 oracle/database:19ee

or with mapped work directory:

sudo docker run -d -it --rm --name oracle19ee -v /home/oracle/oradata19ee:/opt/oracle/oradata -v /home/oracle/work:/home/oracle/work -p 1521:1521 -p 5500:5500 oracle/database:19ee

So the database connection parameters are margao:1521/ORCLPDB1, where margao is the host name.

The command to see logs:

sudo docker logs oracle19ee --tail 100

Connect as root to Docker container:

sudo docker exec -u root -it --workdir / oracle19ee /bin/bash

as ‘oracle‘ user:

sudo docker exec -ti oracle19ee /bin/sh

Finally I connected to the database and queried its version:

COL PRODUCT FORMAT A35
COL VERSION FORMAT A15
COL STATUS FORMAT A15 
SELECT * FROM PRODUCT_COMPONENT_VERSION;
Oracle Database 19c Enterprise Edition, 19.3.0.0.0

Leave a Reply

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