This article will show how to run an Oracle Database on a Docker host using the prebaked images on Oracle Continer Registry. It is my expectation that it takes me very little manual effort to run the full 22.214.171.124 Oracle Enterprise Database – just pull and run the Docker image. Once it is running, I get the usual Docker benefits such as clean environment management, linking from other containers, quick stop and start, running scripts inside the container etc.
The minimum requirements for the container is 8GB of disk space and 2GB of memory. There is a slim alternative that requires less resources: The slim (
126.96.36.199-slim) version of EE does not have support for Analytics, Oracle R, Oracle Label Security, Oracle Text, Oracle Application Express and Oracle DataVault. I am not sure yet how much that shaves of the resource requirements.
My recent article Quick introduction to Oracle Container Registry–running one of Oracle’s prebaked images explained the first steps for getting started with Oracle Container Registry, including how to sign up and accept terms and conditions for individual images.
Once that is out of the way, we can get going with running the database.
The steps are:
- start docker
- login to Oracle Container Registry
- pull image for Oracle Database – I will use the enterprise edition database image in this article
- run a docker container based on that image
- start interacting with the database, for example from SQLcl or SQL Developer.
In terms of work, it will take less than two minutes of your time. The time before the database is running is mainly determined by the time it takes to download the image. After that, running the container takes just a few dozens of seconds.
The Oracle Database images are published on the website for the Container Registry:
Copy the docker pull command in the upper right hand corner to the clipboard. It is also worth remembering the docker run command for running the database image.
Note that this webpage contains more useful information:
- how to run SQL scripts from within the container
- how to expose the database [port] outside the container
- how to specify SID (default ORCLCDB), PDB (default is ORCLPDB1), DOMAIN (default is localdomain) and allocated MEMORY (default is 2 GB)
- how to change SYS password (default is Oradoc_db1)
- how to make use of a volume external to the database container for storing data files, redo logs, audit logs, alert logs and trace files
- how to run a database server image against an existing set of database files
Let’s run a database
After starting Docker (on my laptop I am using the Docker Quick Start Terminal in the Docker Toolbox), login to the container registry using your Oracle account.
Then pull the database image, using the command
docker pull container-registry.oracle.com/database/enterprise
07:09 Start Pull
10:28 Start Extracting
10.30 Image is available, ready run containers off
The download took over three and a half hours. I was doing stuff over that time – so no time lost.
Once the pull was finished, the image was added to the local cache of Docker images. I can now run the database.
docker run -d -it –-name ORA12201_1 –P container-registry.oracle.com/database/enterprise:188.8.131.52
The value ORA12201_1 is the self-picked name for the container.
Here -P indicates that the ports can be chosen by docker. The mapped port can be discovered by executing
docker port ORA12201_1
In a few minutes – I am not sure exactly how long it took – the container status is healthy:
The Database server can be connected to – when the container status is Healthy – by executing sqlplus from within the container as
docker exec -it ORA12201_1 bash -c “source /home/oracle/.bashrc; sqlplus /nolog”
In addition to connecting to the database from within the container – we can also just consider the container running the database as a back box that exposes the database’s internal port 1521 at port 32769. And using any tool capable of communicating to a database can be used in a regular way – provided we also have the IP address for the Docker Host if the connect is not made from that machine itself:
Creating a database connection in SQL Developer is done like this:
Using SYS/Oradoc_db1 as the credentials, the Docker Host IP address for the hostname and the port mapped by Docker to port 1521 in the container, 32769 in this case. The Service Name is composed of the PDB name and the domain name: ORCLPDB1.localdomain.
A sample query:Connecting with SQLcl is similar:
sql sys/Oradoc_db1@192.168.99.100:32769/ORCLPDB1.localdomain as sysdba
To stop the container – and the database:
docker stop 62eb
It takes a few seconds to stop cleanly.
Restarting takes about 1 minute before the database is up and running:
Note: with this basic approach, all database files are created in the container’s file system. And are not available elsewhere nor will they survive the removal of the container. A better way of handling these files is through the mounting of a host folder for storing files or through a Docker Volume.
Note: when running on Windows using Docker Toolbox, this may be convenient for increasing the size of memory and disk of the default VM: https://github.com/crops/docker-win-mac-docs/wiki/Windows-Instructions-(Docker-Toolbox)
11 thoughts on “Run Oracle Database in Docker using prebaked image from Oracle Container Registry–a two minute guide”
Great article. I had a question about defaults from the oracle image. How did you know where is the default SID, DOMAIN and SYS password specified? I couldn’t find it anywhere in the documentation.
To be honest – I do not remember how I found out about that. Perhaps lucky searching, GitHub scrolling,… I have forgotten.
Just a follow up from my last one, this is another error when trying to connect internally
PS C:\Users\Administrator> docker exec -it lxoracledb bash -c “source /home/oracle/.bashrc; sqlplus /nolog”
SQL*Plus: Release 184.108.40.206.0 Production on Sun May 12 21:40:10 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
SQL> connect sys / as sysdba
ORA-12546: TNS:permission denied
Password: Oradoc_db1, as per instructions
Really struggling, any given help will be very much appreciated
Try “docker exec -it lxoracledb bash -c “source /home/oracle/.bashrc; sqlplus”
Then oracle will ask you to provide the user and the password.
I am having the same issue with both images the docker hub and Oracle Registry
The pull is done without issues, but any time I try to connect I have always the same respond
PS E:\docker\dockerfiles> docker exec -it lxoracledb bash -c “source /home/oracle/.bashrc; sqlplus /nolog”
SQL*Plus: Release 220.127.116.11.0 Production on Sun May 12 21:23:57 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
SQL> connect sys/Oradoc_db1@ORCLCDB as sysdba
ORA-12541: TNS:no listener
I know this article is over a year old now, but I just wanted to say thanks for posting the default password for the container’s database!
It’s not working for me Chris
Sorry when i did according to your guide why still reported error?
[root@dipc k8s]# docker login -u email@example.com -p xxxxxxxxxxx container-registry.oracle.com
[root@dipc k8s]# docker pull container-registry.oracle.com/database/enterprise
Using default tag: latest
Trying to pull repository container-registry.oracle.com/database/enterprise …
unauthorized: authentication required
BTW, i had logined the website https://container-registry.oracle.com/pls/apex/f?p=113:4:107174275676982
and accept Oracle Standard Terms and Restrictions. (You last accepted the Oracle Standard Terms and Restrictions on 10/18/2018 at 02:03 AM Coordinated Universal Time (UTC).)
If I connect using Oracle SQL Developer, I get a message when entering ‘sys’ as the user name that:
Status: Failure – Test failed: ORA28009: connection as SYS should be as SYSDBA or SYSOPER
How do I “login to the Oracle registry”? When I try the pull command I get an unauthorized response?
First use: docker login
Comments are closed.