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