Oracle Database Enterprise Edition on Docker (Windows) with Docker-compose file

Jeevankumar R
DeveloperNeeds
Published in
4 min readJul 25, 2024

This article explains how to set up and run Oracle Database Enterprise Edition in a Docker container on Windows using Docker Desktop and Docker Compose.

Introduction:

One of our client was using Oracle Database in a Linux environment, and we needed to test our application in a similar setup before delivering it. Since we lacked a Linux environment, I leveraged Docker to quickly and efficiently create a similar environment.

In this article, I will demonstrate how I set up Oracle Database Enterprise Edition on a Windows machine using Docker and how simple it was with docker compose file. Note that this setup is intended for development and testing purposes only, not for production use.

What is Docker compose?

Docker Compose is a tool that helps you manage applications made up of containers. It makes easy to manage application by simplifying the setup and control of multiple containers. Docker Compose lets you start and stop services, check status, and view logs of all the container with one command.

Why we Use Docker Compose?

Docker Compose provides several key advantages that make working with containerized applications easier:

Simplified Setup: Define all your application components in a single YAML file, making it easier to configure and deploy.

Efficient Management: Start, stop, and manage all your containers with simple commands.

Rapid Application Development: Docker Compose speeds up your development process by re-using containers. When service restarts and that hasn’t changed, Docker Compose re-uses the existing containers instead of creating new ones from scratch.

Install Docker Desktop:

Before proceeding further, ensure that Docker Desktop is installed on your Windows machine. Docker Desktop provides Docker Engine and Docker Compose. It is available for download with the installation instruction on the Docker website.

Creating and Logging into Docker Hub:

A Docker Hub account is necessary for downloading Docker images. If you haven’t already created an account, create one from Docker Hub website

With the following command, you can log into your Docker Hub account using your username and password

docker login

Docker Compose Configuration for Oracle Enterprise Database:

If you want to use latest version of oracle DB you can replace with the image container-registry.oracle.com/database/enterprise:latest

For more details, please check Oracle Container Registry

services:
oracle-db:
image: container-registry.oracle.com/database/enterprise:21.3.0.0
container_name: oracle-db
ports:
- "1521:1521"
environment:
- ORACLE_PWD=admin
volumes:
- oracle-data:/opt/oracle/oradata

volumes:
oracle-data:

The default name for a Docker Compose file is compose.yaml or compose.yml, and it should be placed in the working directory. For backward compatibility, Docker Compose also supports docker-compose.yaml and docker-compose.yml. If both naming conventions are present, Docker Compose will prioritize the canonical compose.yaml.

In the Docker Compose file provided, the ORACLE_PWD environment variable and volume configurations are optional but recommended. Additional details about environment variables and volumes will be covered in the following sections.

Start the Oracle Database container

Run the following command to start the container, It will pull the image from the registry, create and run the container.

docker-compose up -d

You can also monitor the container on Docker Desktop

We can test the connection using SQL Developer or other similar tools.

Connection test using SQL developer tool

Environment Variables:

The environment variables set in the Docker Compose file configure the Oracle Database instance with specific parameters for example:

  • ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDBADMIN password. (Default: auto-generated)
  • ORACLE_SID: The Oracle Database SID that should be used.(Default:ORCLCDB)
  • ORACLE_PDB: The Oracle Database PDB name that should be used. (Default: ORCLPDB1)

Please refer Oracle official document for more Docker configuration options.

The volumes:

The volumes section defines named volumes that can be shared among services. The oracle-data volume is defined here, providing persistent storage for the Oracle Database service., this means that

On the Host System: Docker will create a volume named oracle-data in Docker’s volume storage area on your Windows machine and make sure data is not lost during container restarts. This is managed by Docker and typically located in Docker’s data storage directory. An example location on windows when we used wsl2 during Docker installation will be \\wsl.localhost\docker-desktop-data\data\docker\volumes

Sample Screenshot of Docker Volumes Storage Area

In the Container: The path /opt/oracle/oradata inside the Oracle Database container will be mapped to the oracle-data volume. This is where the Oracle Database stores its data files.

That’s it! You’ve successfully set up Oracle Database with Docker Compose. Happy coding!

Thank you for taking the time to read this article. I hope you found this tutorial helpful! If you encountered any challenges or have suggestions for improvement, please leave a comment below. Your feedback is valuable to me. If you enjoyed this tutorial, please support me by giving it a Clap 👏 and sharing it with others. Thank you!

--

--

Jeevankumar R
DeveloperNeeds

Experienced Java programmer, love to read books, and finance and investment enthusiast.