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.
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)