Modern Developer | April 21, 2017

Test and Deploy WebLogic and Oracle Database Applications on Docker

By: Monica Riccelli


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. 

What you will need


For this article, I've used the following environment:

  • Oracle Linux 7.2 UEK 4 (and the Oracle Linux image for Docker)
  • Docker 1.10.3 
  • Oracle Database Enterprise Edition
  • Oracle WebLogic Server (quick installer and supplemental quick installer)
  • Oracle Java JDK 8u121
  • Oracle SQLcl 4.2

Run Oracle Database container

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 \

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.

Building MedRec Docker image

Make sure you have the store/oracle/weblogic image by doing a pull:

$ docker pull store/oracle/weblogic:

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 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:

  1. Calls run_samples.sh script which invokes WLST scripts to build the MedRec domain and deploy the MedRec application.
  2. Invokes medrec-ds-deploy.py to configure a Generic Data Source MedRecGlobalDataSourceXA with properties defined in oradatasource.properties, to connect to the Oracle Database running in a container as described above.  
  3. Finally the script starts the WebLogic Server.

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:

FROM store/oracle/weblogic:

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

Run the container from the image we built in the step before

$ docker run -d -it -p 7011:7011 12212-oradb-medrec

To look at the progress of the run and obtain the ip-address of the container

$ docker logs -f <container id> 

Now we are ready to test our deployed application and verify that the Data Source is actually connecting to our Oracle database container. Start the WebLogic Admin Console using localhost or the container ip-address noted above, weblogic/welcome1 as user name and password to log onto the console.


Navigate to the Data Source monitoring page

Services -> DataSources -> MedRecGlobalDataSourceXA -> Monitoring


Test the MedRec Application

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.

This is a syndicated post, view the original post here