This is a journey how I can finally run Oracle database (Xpress Edition) on Openshift.
Download oracle-xe-11.2.0-1.0.x86_64.rpm.zip
from oracle website
git clone https://github.com/ejlp12/docker-oracle-xe.git
cd docker-oracle-xe
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
mv Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm rpm/
Start docker-machine, build the image and push to public docker registry
docker-machine start
eval $(docker-machine env)
docker login -u ejlp12 registry.hub.docker.com
docker build -t "ejlp12/docker-oracle-xe" .
docker tag docker-oracle-xe ejlp12/docker-oracle-xe
docker push ejlp12/docker-oracle-xe
Stop docker-machine then start the minishift
Login as system:admin then import Oracle docker image
oc login -u system:admin
oc policy add-role-to-group \
system:image-puller \
system:serviceaccounts:myproject \
-n openshift
oc import-image docker-oracle-xe --confirm --from=registry.hub.docker.com/ejlp12/docker-oracle-xe
Login as developer
oc login -u developer -p developer
oc new-app docker-oracle-xe
Error due to pull images take a long time:
--> Waiting up to 10m0s for pods in rc docker-oracle-xe-1 to become ready
error: update acceptor rejected docker-oracle-xe-1: pods for rc "docker-oracle-xe-1" took longer than 600 seconds to become ready
Then I tried to do manual pull first:
eval $(minishift docker-env)
docker pull registry.hub.docker.com/ejlp12/docker-oracle-xe
Re-deploy docker-oracle-xe
from minishift web console.
Container successfully started but Oracle service is not getting problem somehow.
It might because of Oracle DB need to run as root, so we need to give access (recreate the container after this):
oc adm policy add-scc-to-group anyuid system:authenticated
oc adm policy add-scc-to-user anyuid -z default
Still no luck.
Oracle service still cannot be accessible, but the container is running
Try to set SELinux to permissive (not enforcing)
$ minishift ssh sudo setenforce 0
Try build the container using Docker daemon on Minishift
$ docker build -t "ejlp12/docker-oracle-xe" .
Yeay.. now docker build is successful, then tag it and push to Minishift registry
$ docker tag ejlp12/docker-oracle-xe $(minishift openshift registry)/openshift/docker-oracle-xe
$ docker push $(minishift openshift registry)/openshift/docker-oracle-xe
Check that docker image is already
$ oc login -u developer -p developer
$ oc get is -n openshift
NAME DOCKER REPO TAGS UPDATED
docker-oracle-xe 172.30.1.1:5000/openshift/docker-oracle-xe latest 10 hours ago
Deploy a new pod from ImageStream
$ oc new-app docker-oracle-xe
Check that oracle pod is running
$ oc get pods
NAME READY STATUS RESTARTS AGE
docker-oracle-xe-1-zq6r3 1/1 Running 0 10h
Check that oracle container is running
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
680b8e1c45f5 172.30.1.1:5000/openshift/docker-oracle-xe "/start.sh " 8 hours ago Up 25 minutes
Test Oracle database from inside the container (testing inside container is easy since it already has sqlplus command)
$ docker exec -it 680b8e1c45f5 bash
[root@docker-oracle-xe-1-zq6r3 /]# sqlplus -s system/oracle@localhost:1521/XE <<< "select 1 from dual;"
1
----------
1
Side note:
oc new-app registry.hub.docker.com/sath89/oracle-xe-11g
oc get all --selector app=appname
oc delete all --selector app=appname