Sharing my Experience with setting up Docker on Mac. I have chosen this approach with docker is because there is no proper installable available for Oracle 12c on Mac. It seems Official support was dropped from 10g onwards. I was left with either docker or using a VM which is more cumbersome.
Install and Run Docker for Mac
https://docs.docker.com/docker-for-mac/install/
Get the Docker image for Oracle
Get the docker image from https://hub.docker.com/
https://hub.docker.com/r/sath89/oracle-12c/ (This is an already available docker image with Oracle Standard Edition 12c Release 1 on Ubuntu )
docker pull <imagename>
My-MacBook-Pro:tmp user$ docker pull sath89/oracle-12c Using default tag: latest latest: Pulling from sath89/oracle-12c 863735b9fd15: Pull complete 4fbaa2f403df: Pull complete 44be94a95984: Pull complete a3ed95caeb02: Pull complete b8bc6e8767ee: Pull complete c918da326197: Pull complete 448e1619a038: Pull complete faadd00cf98e: Pull complete 48a252b66251: Pull complete 0be1ba285f23: Pull complete Digest: sha256:0d075905ca2243f0c60397e49eaae6edd62afcce43528df77768f346ece7c49b Status: Downloaded newer image for sath89/oracle-12c:latest
docker images (to list the images)
My-MacBook-Pro:tmp user$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest 1815c82652c0 3 weeks ago 1.84kB sath89/oracle-12c latest 7508a4d8d54f 4 weeks ago 5.7GB
docker run
Run with 8080 and 1521 ports opened:
If -d option is present, we won’t see the errors if any, as the process runs in the background
My-MacBook-Pro:tmp user$ docker run -p 8080:8080 -p 1521:1521 sath89/oracle-12c Database not initialized. Initializing database. Starting tnslsnr Copying database files 1% complete 3% complete 11% complete 18% complete 37% complete Creating and starting Oracle instance 40% complete 45% complete 50% complete 55% complete 56% complete 60% complete 62% complete Completing Database Creation 66% complete 70% complete 73% complete 85% complete 96% complete 100% complete Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/xe/xe.log" for further details. Configuring Apex console Database initialized. Please visit http://#containeer:8080/em http://#containeer:8080/apex for extra configuration if needed Starting web management console PL/SQL procedure successfully completed. Starting import from '/docker-entrypoint-initdb.d': found file /docker-entrypoint-initdb.d//docker-entrypoint-initdb.d/* [IMPORT] /entrypoint.sh: ignoring /docker-entrypoint-initdb.d/* Import finished Database ready to use. Enjoy! 😉
Connect database with following setting:
hostname: localhost port: 1521 sid: xe service name: xe.oracle.docker username: system password: oracle
Install SQLPLUS (Oracle Instant client)
Follow the steps mentioned here
Issues while connecting to Oracle from sqlplus
If you want to connect remotely to the oracle in the container, use the following arguments to docker run command
-e ORACLE_ALLOW_REMOTE=true
docker run -p 8080:8080 -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true sath89/oracle-12c
If you get the following error, while connecting to the database,
ERROR: ORA-21561: OID generation failed
Edit /etc/hosts as per the following answer
https://stackoverflow.com/questions/31338916/sqlplus-remote-connection-giving-ora-21561
With this addition in the /etc/host file and the ORACLE_ALLOW_REMOTE=true setting, you should be able to access the Database externally (from sqlplus or from your application)
Import Data
As impdp utility is not part of Oracle instant client, you cannot use that option external to the docker container. So get into the container
The docker exec command runs a new command in a running container.
docker exec -it <container_name> bash
If container-name is not specified during rum, container id can be used in the above command. To get the container id, use docker ps command.
docker ps -a
Both Impdp and sqlplus are available inside the container. You need to have the data dump file also available inside the container. The easier approach is to mount the dump file location in the local to any location in the container.
To mount location use the -v argument
docker run -v /work/MyProject/Oracledump:/mnt/dumpdir -p 8080:8080
-p 1521:1521 -e ORACLE_ALLOW_REMOTE=true sath89/oracle-12c
When I did this first time, I got the following error
The path /work/MyProject/Oracledump is not shared from OS X and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing.
As mentioned, add the location to the shared location
Finally run the docker instance as follows
docker run -v /work/MyProject/Oracledump:/mnt/dumpdir -p 8080:8080
-p 1521:1521 -e ORACLE_ALLOW_REMOTE=true sath89/oracle-12c
Create a new image from a container’s changes
It can be useful to commit a container’s file changes or settings into a new image.
docker commit d8ae665b2d01 dockeroracle
If you do a docker images now, you can see the new image also listed
Finally run the new mage
docker run --name=dockeroracle -v /work/My/Oracledump:/mnt/dumpdir -p 9090:8080 -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true dockeroracle
docker exec -it dockeroracle bash
docker start dockeroracle