Oracle Database Express Edition (XE) is a free version of the popular Oracle Database, designed for developers, students, and enthusiasts who want to experiment with Oracle Database features without having to invest in expensive licenses. Docker is a containerization platform that simplifies the process of deploying applications, including databases. In this article, we will explore how to quickly start Oracle XE using Docker.
Prerequisites
Before getting started, make sure you have Docker installed on your system. You can download Docker from the official website and follow the installation instructions specific to your operating system. If you are looking for a free alternative solution to Docker Desktop you can install Rancher Desktop which also includes the docker engine in its installer and provides a simple and user-friendly graphical interface.
Once docker has been installed on your computer or server, you can check its correct configuration by running the command in the console:
docker --help
Start Oracle XE on Docker
The first step is to download the latest version of the Oracle XE Docker image from the Oracle image repository. To do this, simply execute the following command:
docker pull container-registry.oracle.com/database/express:latest
The image weighs approximately 3 GB so you will need to wait for the download to complete. Once done, you can proceed with starting the DB:
docker run --name <container-name> \
-p <db-host-port>:1521 \
-e ORACLE_PWD=<your-database-password> \
container-registry.oracle.com/database/express:latest
We have highlighted the variables to be replaced within the command in bold:
- container-name = The name we want to give to the container. If not specified it is set by default by the system.
- db-host-port = Port on which to expose the database connection.
- your-database-password = Password for the default users (SYS, SYSTEM and PDB_ADMIN).
Below is an example of a command already evaluated:
docker run --name oracle-xe \
-p 1521:1521 \
-e ORACLE_PWD=testpwd \
container-registry.oracle.com/database/express:latest
If the database has started correctly you will see a message like this in the console:
#########################
DATABASE IS READY TO USE!
#########################
Note per installazione su Apple Silicon
If you use a machine with an Apple M1 processor, you may experience errors starting the docker container similar to the following:
#####################################
########### E R R O R ###############
DATABASE SETUP WAS NOT SUCCESSFUL!
Please check output for further info!
########### E R R O R ###############
#####################################
The following output is now a tail of the alert.log:
Oracle instance running with ODM in SGA: FSDirect ODM Library Version 1.0
Broadcast on commit is enabled and is using Message mode.
Starting background process PMON
Process PMON died, see its trace file
USER (ospid: 70): terminating the instance due to ORA error 443
2024-04-25T19:44:15.979745+00:00
Instance terminated by USER, pid = 70
This is because Oracle XE is not currently compatible with ARM processors. The only way to solve the problem is to use Colima. This is virtualization software that emulates Intel processors.
It is possible to install it and then start it by running two commands in sequence:
brew install colima
colima start --memory 4 --arch x86_64
After starting Colima you can run the docker run command without getting errors.
Other Oracle XE configuration parameters
The command launched previously is minimal but it is possible to add other input configuration parameters. Below are some of the most useful:
Exposure Express Database Administration
Express Database Administration is a very useful tool for monitoring DB performance. To use it you need to expose port 5500:
-p <host-port>:5500
Charset setting
The default charset used by Oracle XE is AL32UTF8. It can be changed using the following parameter:
-e ORACLE_CHARACTERSET=<your character set>
Mount external volume
If you want the data saved in the DB to persist even after the container is shut down, you need to mount an external volume using the command:
-v <host mount point>:/opt/oracle/oradata
Connect to the Oracle XE database
The final step of our tutorial has finally arrived. That is, we need to connect to the database we just created!
To connect to the database you can use a client of your choice. In our example we will use Oracle SQLDeveloper. Below are the configurations to set in the tool to create the connection:
The password to use is the one previously set on the ORACLE_PWD parameter. Note that this parameter is optional and if not specified Oracle XE will generate random passwords that you can change later using the following command:
docker exec oracle-xe ./setPassword.sh <your_password>
With its powerful features and ease of use, Oracle XE is a popular choice for those who want to experiment with Oracle Database without having to invest in expensive licenses. If you are interested in developing applications or learning more about Oracle Database, Oracle XE may be a great fit for you.