In this article, I will show how to run Oracle Database Express Edition using Docker.
On DockerHub you can find images for most of the common databases such as PostgreSQL or MariaDB. But when it comes to Oracle, all the good things come to an end.
Due to (I think) copyright reasons, Oracle doesn't provide images that can be pulled and run on a Docker instance.
But strangly, they provided an alternative solution.
Oracle made available a suite of Docker build scripts that help set up many of its product offerings, including Oracle Database. You can find these scripts in a GitHub repository.
We'll deploy the version 18.4.0-xe because it is the only version that doesn't requires pre-downloaded binaries. For any other version, you'll need to download the required binaries as described below.
Note: All the step marked as (Optional) can be skipped for the version 18.4.0-xe, but are required for any other version.
Go to Oracle Download page. and download the db version you require, for example
$ git clone https://github.com/oracle/docker-images.git
$ cp /path/to/file/oracle-database-xe-18c-1.0-1.x86_64.rpm /path/to/project/docker-images/OracleDatabase/SingleInstance/dockerfiles/18.4.0
$ cd docker-images/OracleDatabase/SingleInstance/dockerfiles $ ./buildContainerImage.sh -v 18.4.0 -x
WARNING: the script can take up to 30 minutes before finishing
List the docker images:
$ docker images
and check that there's an image tagged as
Pay attention to the size of the image: sometimes the installation does not complete completely but the script ends without reporting any problems. The image should be approximately 5.89GB in size
$ docker run --name oracle \ -d \ -p 51521:1521 \ -p 55500:5500 \ -e ORACLE_PWD=mysecurepassword \ -e ORACLE_CHARACTERSET=AL32UTF8 \ oracle/database:18.4.0-xe
--name: specifies the container name
-d: launch the container in detached mode
-p 55500:5500map a host to a container port.
-e ORACLE_CHARACTERSET=AL32UTF8set the environment variables. Here,
ORACLE_PWDsets the administrative password, and
ORACLE_CHARACTERSETsets the database’s character set.
You can check the container status via the
docker run command, looking the
$ d ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f7776a6dd664 oracle/database:18.4.0-xe "/bin/sh -c 'exec $O…" About a minute ago Up About a minute (health: starting) 0.0.0.0:51521->1521/tcp, :::51521->1521/tcp, 0.0.0.0:55500->5500/tcp, :::55500->5500/tcp oracle
In the example, the container is still starting (
health: starting). Once the container is started, the status will change in
Another way to check the container status is looking the container logs:
$ docker logs oracle ## Omitted for brevity ******************* Prepare for db operation 7% complete Copying database files 29% complete Creating and starting Oracle instance 30% complete 31% complete 34% complete 38% complete 41% complete 43% complete Completing Database Creation 47% complete 50% complete Creating Pluggable Databases 54% complete 71% complete Executing Post Configuration Actions 93% complete Running Custom Scripts 100% complete Database creation complete. For details check the logfiles at: /opt/oracle/cfgtoollogs/dbca/XE. Database Information: Global Database Name:XE System Identifier(SID):XE Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details. Connect to Oracle Database using one of the connect strings: Pluggable database: 2540b6bf28f7/XEPDB1 Multitenant container database: 2540b6bf28f7 Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE The Oracle base remains unchanged with value /opt/oracle ######################### DATABASE IS READY TO USE! #########################
Since every time you launch the container the database instance needs to be installed, the container takes several minutes before it is ready.
You can connect the database using any client you want. In the example I've used dbeaver:
Alternatively, create a bash session within the container, using the OS user
$ docker exec -it --user=oracle oracle bash
Set up the required Linux environment variables for Oracle Database:
bash-4.2# . oraenv ORACLE_SID = [XE] ? The Oracle base remains unchanged with value /opt/oracle
Then access SQL*Plus as you would on any Oracle Database system:
bash-4.2# sqlplus sys@XEPDB1 as sysdba SQL*Plus: Release 188.8.131.52.0 - Production on Mon Aug 23 19:49:33 2021 Version 184.108.40.206.0 Copyright (c) 1982, 2018, Oracle. All rights reserved. Enter password: Connected to: Oracle Database 18c Express Edition Release 220.127.116.11.0 - Production Version 18.104.22.168.0 SQL>
Currently the database is working, but running the container requires a lot of time. In next posts I'll show how to improve starting time using different methods.