How to run Oracle DB on a Mac with Docker
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:
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
-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:
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
Like this? Follow me ↯Tweet Follow @pfreitag
You might also like:
- How to Run SQL Server on a Mac - September 27, 2019
- Running PostgreSQL in Docker for local dev - December 17, 2019
- Oracle's Free Database Server - October 31, 2005
- EnterpriseDB - PostgreSQL with Oracle Compatibility - September 14, 2005
- SQL to Select a random row from a database table - September 14, 2005
- SQL Reserved Key Words Checker Tool - March 28, 2005