Learn how you can run an oracle database docker image in your Docker instance. This tutorial will use the image provided by Oracle in the Oracle Container Registry website.
Here’s an overview of the steps that we will follow in this article:
In order to use the Oracle Database image in Docker, you must have an account in Oracle. If you don’t have an account yet, please create first at Oracle to create an Oracle account.
After you have created or verified that you have an Oracle account, go to the Oracle Container Registry site. Under Browse Containers, click Database. Under the database page, select the repository that you want to use. For this tutorial, we will use the enterprise repository. Scroll to the bottom and you should see the available docker images that you can use.
Select the version that you want to use and take note of the docker pull command.
Next, we need to login to Oracle Container Registry from Docker. In your Docker instance, type the following command:
docker login container-registry.oracle.com
Type in your username (email) and password. You can verify that the auth configuration was saved by checking the ~/.docker/config.json file.
Now that we have set up our Docker, we can now pull and run the Oracle Image.
First, let’s check again the docker pull command that we select in the Oracle Container Registry. We need to get the registry URL and tag name. For example, in this tutorial, we selected the following:
docker pull container-registry.oracle.com/database/enterprise:18.104.22.168
The URL plus tag name is container-registry.oracle.com/database/enterprise:22.214.171.124. Now we can use this in our run command.
To run, issue the following command:
docker run -d --name oracle-21c -e ORACLE_PWD=sysPassword -p 1521:1521 -p 5500:5500 container-registry.oracle.com/database/enterprise:126.96.36.199
You can check the logs using the following command to check the status of your installation:
docker logs -f oracle-21c
Once installation is completed, you can now test the connection in your SQL Developer.
Create a new connection in your SQL Developer and add the following details:
CDB SYSDBA Connection Details:
username: sys password: password set in the docker run role: SYSDBA host: localhost or IP if in other machine port: 1521 SID: ORCLCDB
By default, Oracle will create 1 PDB (ORCLPDB1) that you can use. Below are the default details that you can try to connect as SYSDBA of your PDB:
sys user: username: sys password: password set in the docker run role: SYSDBA host: localhost or IP if in other machine port: 1521 service name: ORCLPDB1
And here’s a default user that you can use on your PDB which is actually just changing the role from SYSDBA to DEFAULT:
username: sys password: password set in the docker run role: default host: localhost or IP if in other machine port: 1521 service name: ORCLPDB1
You can change your password in case you forgot it. To change the password, you need to enter inside the container:
docker exec -it oracle-21c bash
You will be transferred to the home folder of the container where you can find the setPassword.sh. Run this script and follow on-screen instructions:
That’s it, you now have a working Oracle Database running in a Docker instance. Also, read how you can create a new Pluggable Database (PDB) in your Oracle Instance.