Tight integration between Oracle WebLogic Server and Oracle Database provide a strong infrastructure to develop, and test application with improved availability, better resource sharing, ease of configuration and automated management facilities. When both of these products are running in Docker containers we can take advantage of Docker’s benefits of container isolation, container portability, packaging, instant replay and reset to provide the ability to automate the development and testing of these applications.
On GitHub we provide the necessary Dockerfiles and scripts to run both an Oracle Database EE 12c and WebLogic Server 12c containers. We also provide samples that you can expand to deploy your own applications in this environment. I will describe how to containerize WebLogic Server which connects to a containerized Oracle DB, deploy a MedRec application which has its data persisted in the database.
For this article, I've used the following environment:
We will run the container using the docker run command. One important parameter is the -p for the mapping of ports inside the container to the outside world. This is of course required so that we can also connect to the database outside the Docker container. Another useful parameter is the --name parameter which allows us to give our newly created Docker container a name defined by us. By doing so we can refer to the container via that name rather than the automatically generated ID/name:
$ docker run --ipc=host \
--name my_db \
-p 1521:1521 \
-p 5500:5500 \
-e ORACLE_SID=ORCLCDB \
-e ORACLE_PDB=ORCLPDB1 \
On the very first startup of the container a new database is being created. Subsequent startups of the same container just start up the database again. For convenience purposes the container startup script also runs a tail -f on the Oracle Database alert.log file. This is done for convenience purposes only so that any potential issues can be easily spotted. Once you see the line DATABASE IS READY TO USE! in the output you can connect to the database. Note that the startup script also generated a password for the database admin accounts. You can find the password next to the line ORACLE AUTO GENERATED PASSWORD FOR SYS, SYSTEM, AND PDBAMIN in the output. You can either use that password going forward or you can reset it to a password of your choice. The container provides a script called setPassword.sh for resetting the password. In a new shell just execute the following command against the running container:
$ docker exec my_db ./setPassword.sh LetsDocker
We need to create the tables and populate them with data that the application will need. Run sqlplus to create and populate tables for WebLogic medrec application to run the ddl. Download and install sqlcl, a new command-line tool for connecting to the Oracle Database.
~/sqlcl/sqlcl/bin $ ./sql system/LetsDocker@xxx.xxx.x.xxx:1521/ORCLCDB
If you are into database development, you can find more Oracle Database examples on GitHub.
Make sure you have the store/oracle/weblogic image by doing a pull:
$ docker pull store/oracle/weblogic:220.127.116.11
The GitHub project that has the Dockerfiles and scripts to deploy the MedRec application are under ~/docker-images/OracleWebLogic/samples/12212-oradb-medrec. Clone the docker-images repository into your environment, open a terminal, and go into folder 12212-oradb-medrec.
$ git clone --depth 1 https://github.com/oracle/docker-images.git
$ cd docker-images/OracleWebLogic/samples/12212-oradb-medrec
The Dockerfile extends the WebLogic image, installs the WebLogic Supplemental Quick installer, and defines a command to invoke the shell script startSamples.sh at runtime.
Before continuing, make sure you download the WebLogic Server 18.104.22.168 Supplemental Quick Installer from OTN, and drop the zip file (without extracting it!) into folder 12212-oradb-medrec.
This sample has a file called startSample.sh that runs the following operations:
Edit the 12212-oradb-medrec/container-scripts/oracledatabase.properties, set the Oracle Thin XA driver, the Database URL, user and password to connect to the Oracle Database container we created before.
dstestquery=SELECT * FROM DUAL
Edit the Dockerfile and change the FROM line to:
Now we are ready to build the 12212-oradb-medrec image:
$ cd ~/docker-images/OracleWebLogic/samples/12212-oradb-medrec/
$ docker build -t 12212-oradb-medrec .
We have now built all necessary images to run this sample. Run the docker images command to see the following images available in your environment:
Create and run a MedRec Docker container
$ docker run -d -it -p 7011:7011 12212-oradb-medrec
$ docker logs -f <container id>
Navigate to the Data Source monitoring page
Services -> DataSources -> MedRecGlobalDataSourceXA -> Monitoring
You should now be able to access the MedRec application running on http://localhost:7011/medrec/. If everything worked fine, you should see this:
Oracle Database and WebLogic on Docker is all about automating development, test operations, and automating production operations. Developing your Java applications to this platform give you the perfect environment to develop and test with a rich set of features to configure, debug, and monitor. Once your application tests have passed, you will have the building blocks to move applications into production!
Oracle Cloud offers Container Cloud Service, and Application Container Cloud Service which manage these containers. Experiment with them by going to cloud.oracle.com/tryit. Oracle is offering $300 in free credits which will be added to new cloud accounts.
Monica Riccelli is product manager for Oracle's WebLogic server.