1. Download Oracle XE Database
Select download based on your OS from here https://www.oracle.com/database/technologies/xe-downloads.html . You will need an Oracle account, but those are free to create. Oracle XE is a free database so you will not be charged for using it.
2. Create Base Docker Container
Create a container based on the Oracle Linux image. The code below also exposes the default Oracle DB port, 1521, so that you may connect to the database from outside the container. It also mounts a directory from the host, in this case listed as “directoryonhostpctosharewith_docker”, to the /mnt directory on the container. This is the location where your oracle database download should be placed on the host.
docker run -dit --name oracle -p 1521:1521 -v /directory_on_host_pc_to_share_with_docker/:/mnt/ -e ORACLE_DOCKER_INSTALL=true oraclelinux
After the container is created, open a BASH session into it:
docker exec -it oracle
3. Install Database
#Install preinstall dependencies for 18C database: yum update -y yum install -y oracle-database-preinstall-18c #Copy oracle db file into container: cp /mnt/oracle* ~ #Go into folder where download is located: cd ~ #Install database: yum -y localinstall oracle-database*18c*
4. Configure Database
Run the setup script provided by the install. It will request a password to use for your admin accounts on the database.
#Run oracle db setup process: /etc/init.d/oracle-xe-18c configure
5. Append to PATH and Enjoy
The Oracle binaries are located in the /opt/oracle/product/18c/dbhomeXE/bin/ directory. The commands below will add this path to your .bashrc (so they are visible in your terminal), and set ORACLE_HOME location.
echo "PATH=/opt/oracle/product/18c/dbhomeXE/bin/:$PATH" >> ~/.bashrc echo "export ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE/" >> ~/.bashrc source ~/.bashrc
You can now connect to the database:
Since we’ve exposed port 1521 to the container’s host, you should now also be able to connect to the database from your PC.