Oracle puts out a Windows and Linux binary for their Oracle Database servers, but what if you want to run it on a Mac? The solution for a while was to use a VM and boot up the linux version. Nowadays using Docker is a little bit easier.
I will say that running Oracle DB on docker is not quite as easy as running SQL Server on Docker, but it is also not too difficult.
Download the Oracle Database Linux Binary
Your first step is to download the Download the Oracle Express Edition version 18c (xe) Linux rpm from oracle.com. Oracle's docker files do support other editions, but the Express Edition is sufficient for getting started.
Clone the Oracle Dockerfile Repo
Oracle has a GitHub repo with all its Dockerfiles, you can clone it (download it) by running:
git clone https://github.com/oracle/docker-images.git
Copy Binary to Dockerfiles dir
Within the git repository you just cloned, go to the OracleDatabase dockerfiles folder:
cd ./OracleDatabase/SingleInstance/dockerfiles
Copy the binary you downloaded in step 1 to the 18.4.0 folder within the dockerfiles folder:
cp ~/Downloads/oracle-database-xe-18c-1.0-1.x86\_64.rpm ./18.4.0
Build a Docker Image
Run the script:
./buildDockerImage.sh -x -v 18.4.0
The -x
tells the script that you are installing the express edition, and the -v 18.4.0
tells it which version you are installing.
This step will take a few minutes.
Look for local docker image
You should now have a docker image named oracle/database:18.4.0-xe
which you can start using docker. Run docker images
from Terminal to look for it and make sure it is there. The total size of the image will be around 8-9GB.
Start an Oracle Database Using docker-compose
Finally we'll create a docker-compose.yml file so we can easily startup the db whenever we need it:
version: "3"
services:
oracle:
image: oracle/database:18.4.0-xe
ports:
- "11521:1521"
environment:
- ORACLE\_PWD=testing12345
Now we can start up our container by running:
docker-compose up
If you omit the ORACLE_PWD
environment variable it will just generate a presumably random password and output it during startup. The startup takes a few minutes to initialize.
After it starts up you will have an oracle database that is accessible on your local machine on port 11521
.
Top comments (1)
Hi, I know it has been a while since you posted this. Hope you don't mind me asking you something regarding connecting to the db.
I followed your instruction and trying to use SQLplus to connect. The command I have tried are:
The errors are consistent:
Wondering do you mind pointing out what I did wrong here? It is obviously something about my credential.
Thank you for your time.
===========
UPDATE JULY 25TH, 2020==============Just in case someone else found this post and followed along. Here's what I did in the end.Looks like I followed this post somewhere wrong while using the YAML file setting the default password. Although I can findORACLE\_PWD testing12345
was set in my docker Environment, the default password of the db is still getting automatically generated each time starting the instance.SOLUTIONDo search in docker log (Dashboard) of the container with keyword "PASSWORD" and you should see:Hope this helps and happy coding :)=========== UPDATE JULY 28TH, 2020 ==============
IMPORTANT FOLLOWUP
In the end, I realize that I terminated the initialization process accidentally while it was finishing up. Looks like the final container should not be showing up in the docker dashboard at all. I guess my early termination might cause the password issue.
Please ignore my previous solution and move on with the original guide.