How to run Oracle DB on a Mac with Docker
By Pete Freitag
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 installing SQL Server on a Mac with 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
.
How to run Oracle DB on a Mac with Docker was first published on November 05, 2019.
If you like reading about docker, oracle, mac, or databases then you might also like:
- How to Run SQL Server on a Mac
- Running PostgreSQL in Docker for local dev
- Oracle's Free Database Server
- EnterpriseDB - PostgreSQL with Oracle Compatibility
Discuss / Follow me on Twitter ↯
Tweet Follow @pfreitagComments
From: https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance
IMPORTANT: You will have to provide the installation binaries of Oracle Database (except for Oracle Database 18c XE) and put them into the dockerfiles/<version> folder.
The file is fetched during docker build:
INSTALL_FILE_1="https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm"
@Venka & Jessica - thanks I fixed the indentation.
One doubt I have is, what url is using to connect to the database? I mean, what username, password or databasename is using...
Thank you!!
Sending build context to Docker daemon 633.2MB
Step 1/8 : FROM oraclelinux:7-slim
Get https://registry-1.docker.io/v2/library/oraclelinux/manifests/7-slim: unauthorized: incorrect username or password
ERROR: Oracle Database container image was NOT successfully created.
ERROR: Check the output and correct any reported problems with the build operation.
I need a special account in docker-hub?
Thanks
------
executor failed running [/bin/sh -c chmod ug+x $INSTALL_DIR/*.sh && sync && $INSTALL_DIR/$CHECK_SPACE_FILE && cd $INSTALL_DIR && yum -y install openssl oracle-database-preinstall-18c && sed -i -e 's/\(oracle\s\+hard\s\+nofile\)/# \1/' /etc/security/limits.d/oracle-database-preinstall-18c.conf && yum -y localinstall $INSTALL_FILE_1 && rm -rf /var/cache/yum && rm -rf /var/tmp/yum-* && mkdir -p $ORACLE_BASE/scripts/setup && mkdir $ORACLE_BASE/scripts/startup && ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && mkdir -p $ORACLE_BASE/oradata /home/oracle && chown -R oracle:oinstall $ORACLE_BASE /home/oracle && mv $INSTALL_DIR/$RUN_FILE $ORACLE_BASE/ && mv $INSTALL_DIR/$PWD_FILE $ORACLE_BASE/ && mv $INSTALL_DIR/$CHECK_DB_FILE $ORACLE_BASE/ && mv $INSTALL_DIR/$CONF_FILE /etc/sysconfig/ && ln -s $ORACLE_BASE/$PWD_FILE / && cd $HOME && rm -rf $INSTALL_DIR && chmod ug+x $ORACLE_BASE/*.sh]: exit code: 2
ERROR: Oracle Database container image was NOT successfully created.
ERROR: Check the output and correct any reported problems with the build operation.
It says this error any solution?
This error happens on a Mac M1
But I can't execute the sqlplus command from my terminal since it is not recognized... also I don't know how to open Oracle Net Manager.
Can anyone help me?
Thank you.
One small comment, for me i did not see
./buildDockerImage.sh script.
i used this buildContainerImage.sh and worked fine.
Thank you again.
This is my directory >
dockerfiles % ls
1.0.1 12.1.0.2 18.3.0 19.3.0 buildContainerImage.sh
11.2.0.2 12.2.0.1 18.4.0 21.3.0
I ran BuildContainer 21.3.0 (most recent version)
./buildContainerImage.sh -x -v 21.3.0
and then I got this prompt telling me the image was not created
ERROR: Oracle Database container image was NOT successfully created.
ERROR: Check the output and correct any reported problems with the build operation.