Skip to content
Menu
ChaoTic
  • Home
  • Python
  • APEX
  • PL/SQL
  • Oralce DB
  • Docker
  • OCI
  • Nginx
  • C#
  • Linux
  • JavaScript
  • Privacy Policy
ChaoTic

Docker learning notes: By Dockerise Oracle Database + APEX instance

Posted on November 25, 2022July 25, 2023

How to fix docker: Got permission denied while trying to connect to the Docker daemon socket. Read more here.

# To create the docker group and add your user:
sudo groupadd docker
# Add your user to the docker group
sudo usermod -aG docker ${USER}
#after, you most likely needs a reboot

Images

# to list all images
docker images
# to romve an image
docker image rm ${image id}
# to build an image with at current direct (the . at the end )
docker build -t ${tagname} . 

Volumes

# to create 
docker volume create MY_VOLUME
# to remove 
docker volume rm MY_VOLUME
# to list 
docker volume ls
# to inspect
docker volume inspect MY_VOLUME

Container

#list all container 
docker ps -a
#start bash from an running container 
docker exec -it ${container id} /bin/bash
#stop a container 
docker stop ${container id}

#start a container and run bash by adding bash at the end of the command
docker run -it -p 1521:1521 --name c01 with_data_pump:1.0.0 bash

Tab into a running container’s cli

docker attach ${container id}
docker exec -it ${container id} /bin/bash

Leave container Bash session without killing the container

Ctrl + P then Ctrl + Q

#its called escape sequence

Start a status ‘exited’ container and tab into the bash

docker start ${container id}
docker attach  ${container id}

start a container with port mapping

# start a container detached and map host port 80 to container port 8080, give the container a custom name with image id 
docker run -d -p 80:8080 --name ${container_name} ${image_id}

Create a new image with a running container where configuration are made

# list all containers
docker ps -a
# find the one you are in and do a commit on its name or id , here i use the container name !!! the commit process can take a bit depends on the size of your container 
docker commit practical_montalcini
# or docker commit ${container_id} ${tag}:${version}
docker commit 857338c4ccf4 operation_image:3.0.0

# after commit , find your newly created image and give it name 
docker images # to show all images
# tag to change the name 
docker tag 3e70341ac6d9 oracle18_apex22_2_ords22
# add tags to image
docker image tag oracle18_apex22_2_ords22:latest oracle18_apex22_2_ords22:1.0
# remove latest tag
docker image remove oracle18_apex22_2_ords22:latest

Create Oracle APEX Docker

– Dockerfile to take the oraclelinux7

– Copy files into linux or use wget in oracle linux 7

– apex , ords, xe18 , java11, xe preinstall

– install XE pre install

– write export ORACLE_DOCKER_INSTALL=true

– install XE

– Follow this official guide

– Remeber to run the following comands on user oralce, read more here

su - oracle 
export ORACLE_SID=XE 
export ORAENV_ASK=NO 
. /opt/oracle/product/18c/dbhomeXE/bin/oraenv

For 21xe, do a /etc/init.d/oracle-xe-21c start , this will trigger generate listener.ora and display its location. for 21xe , it is at /opt/oracle/homes/OraDBHome21cXE/network/admin/listener.ora

update with nano /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora

# listener.ora Network Configuration File: /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
# Generated by Oracle configuration tools.

DEFAULT_SERVICE_LISTENER = XE

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

update /opt/oracle/product/18c/dbhomeXE/network/admin/tnsnames.ora. Here are some explainations. Addtionally, here are two line of sql need to be remember

HOST = 0.0.0.0 # as well 
SQL> alter session set container=XEPDB1; # to switch pdb;
SQL> show con_name  # to check current pdb;

Database wallet for Make Rest Calls

  • see here create wallet folder and wallet and here for wallets (make sure you are using oracle user , when create /add certs into wallet)
  • write this to change ownership of the wallet folder
 chown -R oracle:oinstall wallet/

APEX installation, follow this Guide

my Dockerfile

FROM operation_image:2.0.0

COPY ./files/*.sh /root/

EXPOSE 1521 5500 8080

CMD chmod +x /root/*.sh && \
    bash /root/start_scripts.sh

my two file which is located in ./files folder

start_scripts.sh

#!/bin/bash
echo "#################################################" &&
echo "IN Oracle USER" &&
echo "#################################################" &&

sudo -i -u oracle bash << EOF
export PATH=/opt/oracle/jdk-11.0.16.1/bin:/opt/oracle/ords/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/oracle/product/18c/dbhomeXE/bin
#export _JAVA_OPTIONS="-Xms1024M -Xmx1024M"
export ORACLE_SID=XE
export ORAENV_ASK=NO
. /opt/oracle/product/18c/dbhomeXE/bin/oraenv
EOF

echo "#################################################" &&
echo "OUT Oracle User" &&
echo "Export Root Parameters" &&
echo "#################################################" &&

export PATH=/opt/oracle/jdk-11.0.16.1/bin:/opt/oracle/ords/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/oracle/product/18c/dbhomeXE/bin &&
export ORACLE_SID=XE &&
export ORAENV_ASK=NO &&
. /opt/oracle/product/18c/dbhomeXE/bin/oraenv &&

echo "#################################################" &&
echo "start DB" &&
echo "#################################################" &&

/etc/init.d/oracle-xe-18c start &&

echo "#################################################" &&
echo "Database started" &&
echo "#################################################" &&


echo "#################################################" &&
echo "Run SQL Scripts here if any" &&
echo "#################################################" &&


echo "#################################################" &&
echo "start ORDS" &&
echo "#################################################" &&
bash /root/start_ords.sh

start_ords.sh

cd /opt/oracle/config && ords serve

Kill Running container and spin a new one with Bash script

#!/bin/bash
#_RUNNING_ID = $(docker ps -a -q)
#echo $_RUNNING_ID &&

if [ ! -z "$(docker ps -a -q)" ]
then
 echo "#######################################################"&&
 echo "Running Container Found: $(docker ps -a -q)" &&
 echo "#######################################################"&&
 echo "Destroying $(docker ps -a -q)" &&
 docker stop $(docker ps -a -q) &&
 docker rm $(docker ps -a -q)
 echo "." &&
 echo "." &&
 echo "." &&
 echo "." &&
 echo "." &&
 echo "#######################################################"&&
 echo "Run Container with Latest Image" &&
 echo "#######################################################"&&
 docker run -d -p 1521:1521 -p 8080:8080 --name c01 operation_image:2.0.0
 echo "#######################################################"&&
 echo "PING APEX webserver to check if all online before release control to Jenkins"
 while [[ $(curl -Is localhost:8080 | head -1) != *"HTTP"* ]]
 do
   echo $(curl -Is localhost:8080 | head -1)
   echo "Server is not online, sleep for 5 seconds and try again"
   sleep 1
   echo "...."
   sleep 1
   echo "...."
   sleep 1
   echo "...."
   sleep 1
   echo "...."
   sleep 1
   echo "...."
 done
 echo "All services are ready, release control to Jenkins"
else
 echo "#######################################################"&&
 echo "NO Running / Exited Container Found" &&
 echo "#######################################################"&&
 echo "." &&
 echo "." &&
 echo "." &&
 echo "." &&
 echo "." &&
 echo "#######################################################"&&
 echo "Run Container with Latest Image" &&
 echo "#######################################################"&&
 docker run -d -p 1521:1521 -p 8080:8080 --name c01 operation_image:2.0.0
 while [[ $(curl -Is localhost:8080 | head -1) != *"HTTP"* ]]
 do
   echo $(curl -Is localhost:8080 | head -1)
   echo "Server is not online, sleep for 5 seconds and try again"
   sleep 1
   echo "...."
   sleep 1
   echo "...."
   sleep 1
   echo "...."
   sleep 1
   echo "...."
   sleep 1
   echo "...."
 done
 echo "All services are ready, release control to Jenkins"
fi

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • Oracle APEX cheat sheets (on going)
  • Second Take on React Native – ReadCast
  • Switch Between APEX builder Authentication schemes
  • Use BitBucket Pipelines to Automate Oracle APEX deployment
  • MARKDown TEST

Categories

  • APEX
  • C#
  • chatgpt
  • Docker
  • JavaScript
  • Linux
  • Nginx
  • OCI
  • Oracle APEX
  • Oralce DB
  • PL/SQL
  • Python
  • Uncategorized
©2025 ChaoTic | Powered by SuperbThemes
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT
Scroll Up