Installing Oracle Database 21c on Docker

Installing Oracle Database 21c on Docker

Oracle Database 21c Standard Edition (SE) provides a lightweight and easy way to run Oracle Database in a Docker container. Follow these steps to install Oracle Database 21c SE using Docker.

Step 1: Prerequisites

Before you begin, make sure you have Docker installed on your system. You can download and install Docker from the official website: Docker.

Step 2: Clone Oracle Docker Images

Oracle hosts its supported Docker images on GitHub. Create a directory (e.g., /var/docker/) on Ubuntu and clone the repository:

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

This downloads all necessary images into the /var/docker folder.

Step 3: Download Oracle 21c Zip

Download the Oracle 21c zip file (Linux x86–64) from Oracle's website. Copy the downloaded file to the docker-images directory:

cp <path-to-download>/LINUX.X64_213000_db_home.zip /var/docker/docker-images/OracleDatabase/SingleInstance/dockerfiles/21.3.0/

Step 4: Build Docker Image

Navigate to the dockerfiles directory and execute the build script:

cd /var/docker/docker-images/OracleDatabase/SingleInstance/dockerfiles 
./buildContainerImage.sh -v 21.3.0 -s

Wait for the process to complete. Once done, verify the image creation with:

docker images

You should see an image tagged as 21.3.0-se

Step 5: Run Oracle Database

Create a directory (/u01/oracle) where Oracle data will be stored:

mkdir /u01/oracle
sudo chown 54321:54322 /u01/oracle

(In the container, user oracle is UID 54321 and group dba is GID 54322.)

Run the Docker image:

docker run --name oracle21c \ 
-p 1521:1521 -p 5500:5500 \
--network host \
-v /u01/oracle:/opt/oracle \
--ulimit nofile=1024:65536 --ulimit nproc=2047:16384 --ulimit stack=10485760:33554432 --ulimit memlock=3221225472 \
oracle/database:21.3.0-se

The password will be displayed in the output. Note it down.

ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: Zx502K!I]1`&~#"%

Once you see "DATABASE IS READY TO USE" and "XDB initialized", stop the process with ctrl + c.

Check the image with:

docker ps -a

Start the Oracle database:

docker start oracle21c

Access Oracle Enterprise Manager Database Express at https://localhost:5500/em/shell.

  • Username: system
  • Password: [Use the password from the previous step]

To change the password, use:

docker exec oracle21c ./setPassword.sh <new-password>

Connect to the database from the Docker terminal:

docker exec -ti oracle21c sqlplus system/[password]@orclpdb1

There you have it!