Run Oracle 11g XE in Docker for Local Development

lqiang79
2 min readMar 9, 2021

We need Oracle Express database 11 for local development, So to use Oracle Database on MacOS, the best way is to start the Oracle Database in Docker.

At first, you need to install Docker Desktop on your machine and start it. The detailed install steps you can find in docker online documentation.

Now you are ready to build an Oracle database image and start it on your local machine. Follow the steps below.

Download Necessary Files

Use git clone to download the official oracle Docker imager repo from GitHub.

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

The image docker build script is OracleDatabase/SingleInstance/dockerfiles/buildContainerImage.sh. But before we can build the image, we have to download also the install package from oracle. For my case, I downloaded the package oracle-xe-11.2.0-1.0.x86_64.rpm.zip and put it into the path `OracleDatabase/SingleInstance/dockerfiles/11.2.0.2.

├── 11.2.0.2
│ ├── Checksum.xe
│ ├── Dockerfile.xe
│ ├── checkDBStatus.sh
│ ├── oracle-xe-11.2.0-1.0.x86_64.rpm.zip
│ ├── runOracle.sh
│ ├── setPassword.sh
│ └── xe.rsp

Build Image

Now we start the script buildContainerImage.sh to build our image:

$ ./buildContainerImage.sh -v 11.2.0.2 -x -i

The result you can see at the end of console

Oracle Database container image for 'xe' version 11.2.0.2 is ready to be extended: 
--> oracle/database:11.2.0.2-xe
Build completed in 42 seconds.

Start Image

Oracle 11.2.0.2-xe is now ready to be started. We start it with

docker run --name myoracle \
--shm-size=2g \
-p 1521:1521 -p 9090:8080 \f
-e ORACLE_PWD=mypass \
-v [<host mount point>:]/u01/app/oracle/oradata \
oracle/database:11.2.0.2-xe

We give the docker name myoracle and set the default password for SYS user mypass. The --shm-size=2g set default memory for this docker container with 2G RAM. To avoid oracle use 8080 default port on my host, we map it to port 9090.

When you see the console output

#########################
DATABASE IS READY TO USE!
#########################

your database is now ready.

To check you can correct access the database, you can use any oracle database client(sqlplus, SQL Developer, or IntelliJ Database tools) to connect it. We use sqlplus command in the terminal:

sqlplus sys/mypass@//localhost:1521/XE as sysdba

Conclusion

Oracle Database is still one of the most used RDMS. But the install and configuration a local development environment is hard as usual. But now with Docker it comes easy than before and also OS independent. I hope this small introduction can make your environment setup easier too. Enjoy!

--

--