Building a Docker Image for WebLogic MedRec app

This blog walks you through the steps I used to get WebLogic Server and the MedRec sample application installed into a Docker image. There are many well documented GitHub projects for the Oracle Docker Images. This blog is meant to simply narrow down exactly what I did to get this going in my environment. I was using Ubuntu 16.04, and already had Docker installed.

The overall flow I followed was as follows;

  1. Git clone the Oracle Docker project repository
  2. Download JRE and the binary files for Weblogic and the weblogic Supplemental apps.
  3. Edit files
    1. the Dockerfile to get the appropriate JRE version in the built image.
    2. the Dockerfile to build from the correct WebLogic Server image
  4. Build the docker image in the following stages
    1. OL7 + JRE
    2. OL7 + JRE + WLS
    3. OL7 + JRE + WLS + MedRec app

Detailed steps follow below.

Git Clone the Oracle Docker Project Repository

Open a browser and point to – you will see the link to Download repository. Copy the http link for the repository.

Then open a terminal window and copy down the Oracle Docker project repository from git hub into your local environment by using git clone. From within my /home/dmreid/myprojects folder I executed the following command;

git clone

Note this step pulls down all the projects and not just the WebLogic project. You will see that the git clone will have docker build files for weblogic, glassfish , tuxedo etc. Over my network connection the above step took around 10 minutes.

After the clone completed my file system looked like this;

Download required JRE AND WLS files

Point a browser to  – download the server jre for Linux 64 bit into docker-images/OracleJava/java-8

Now point a browser to – download the Quick Installer for Mac OSX, Windows and Linux file into ……../docker-images/OracleWebLogic/dockerfiles /

Note there is a reference to another WebLogic Server file that you could download but this is only required IF YOU DON’T WANT THE DEVELOPER (lighterweight) QuickStart WLS install.

The last download we need is the MedRec sample application. To find the required file, simply point a browser to and download
into  /home/dmreid/myprojects/docker-images/OracleWebLogic/samples/12212-medrec

Edit Dockerfile for JRE version

Next I edited the Dockerfile in /docker-images/OracleJava/java-8 directory .. It has a reference to

ENV JAVA_PKG=server-jre-8u*-linux-x64.tar.gz \


I changed it to reflect the actual java8 patchset u131 …

ENV JAVA_PKG=server-jre-8u131-linux-x64.tar.gz \


Save the changes made.

Edit the Dockerfile to reflect the target WebLogic Server Version developer build

I edited the Dockerfile in /docker-images/OracleWebLogic/samples/1211-domain to reflect the developer build and not the base 12.2.1

# Pull base image

# —————

# Changed by – dmr 24 April 2017

# was FROM oracle/weblogic:12.2.1-developer

FROM oracle/weblogic:

Build the first image ( OL7-slim + JRE)

In a terminal window cd to …./docker-images/OracleJava/java-8 directory

Now execute the following command;

sudo ./

Now you have to admit that was pretty easy. You have just pulled down the oraclelinux:7-slim docker image from docker hub and then installed the oracle 8u131 jre into into the OL7-slim image. When using the RUN command in a Dockerfile the result is a new Docker image.

Now execute the following to view the images you have in your local docker repository;

sudo docker images

Build the second image adding WebLogic Developer

Next we need to install weblogic on top of the image that contains OL7 + JRE 8U131

In a terminal window change directory to the dockerfiles directory under OracleWebLogic.

cd /home/dmreid/myprojects/docker-images/OracleWebLogic/dockerfiles

Next step is to build the docker image that will contain the WebLogic Server.

While in the same directory execute the following command in order to see what options are available for the build.


As per my cut and paste of the output of the more command below, the -v argument is where I specified the specific version of WebLogic Server I wanted.
The -d option means that I want the developer (lighterweight) version.
The other flags available are detailed in the script as per below if you are interested in exploring further.




# Since: October, 2014

# Author:

# Description: script to build a Docker image for WebLogic




# Copyright (c) 2014-2015 Oracle and/or its affiliates. All rights reserved.


usage() {

cat << EOF

Usage: -v [version] [-d | -g | -i] [-s] [-c]

Builds a Docker Image for Oracle WebLogic.


   -v: version to build. Required.

       Choose one of: $(for i in $(ls -d */); do echo -n “${i%%/}  “; done)

   -d: creates image based on ‘developer’ distribution

   -g: creates image based on ‘generic’ distribution

   -i: creates image based on ‘infrastructure’ distribution

   -c: enables Docker image layer cache during build

   -s: skips the MD5 check of packages

* select one distribution only: -d, -g, or -i


Copyright (c) 2014-2015 Oracle and/or its affiliates. All rights reserved.


exit 0


Next execute the following command;

sudo ./ -v -d -c

You will now see output similar to the following;

dmreid@dmrDevEnv:~/myprojects/docker-images/OracleWebLogic/dockerfiles$ sudo ./ -v -d -c

Checking if required packages are present and valid… OK


Building image ‘oracle/weblogic:’ …

Sending build context to Docker daemon 219.2 MB

Step 1/13 : FROM oracle/serverjre:8

—> a969bb27b4ef

Step 2/13 : MAINTAINER Monica Riccelli <>

—> Running in 1348b2dd0a72

—> e8de0930a0d9

Removing intermediate container 1348b2dd0a72

Step 3/13 : ENV ORACLE_HOME /u01/oracle USER_MEM_ARGS “” PATH $PATH:/usr/java/default/bin:/u01/oracle/oracle_common/common/bin:/u01/oracle/wlserver/common/bin

—> Running in fa87a22b6fcb

—> f2177089e22c

Removing intermediate container fa87a22b6fcb

Step 4/13 : RUN mkdir -p /u01 &&     chmod a+xr /u01 &&     useradd -b /u01 -d /u01/oracle -m -s /bin/bash oracle &&     chown oracle:oracle -R /u01

—> Running in 272b7de2f801

—> 0bec44b1ece1

Removing intermediate container 272b7de2f801

Step 5/13 : COPY container-scripts/ container-scripts/ /u01/oracle/

—> 9dc4d66b20da

Removing intermediate container 44ab08cd2ab4

Step 6/13 : ENV SCRIPT_FILE /u01/oracle/ DOMAIN_NAME “${DOMAIN_NAME:-base_domain}” DOMAIN_HOME /u01/oracle/user_projects/domains/${DOMAIN_NAME:-base_domain} ADMIN_PORT “${ADMIN_PORT:-7001}”

—> Running in 51a8e5eb8a4b

—> 60459a2c60e7

Removing intermediate container 51a8e5eb8a4b


—> Running in 5ba8f12f2ba2

—> 7045a188e98e

Removing intermediate container 5ba8f12f2ba2

Step 8/13 : COPY $FMW_PKG install.file oraInst.loc /u01/

—> 58abe3ddc6d9

Removing intermediate container d782c1265268

Step 9/13 : RUN chmod +xr $SCRIPT_FILE

—> Running in 2cb9307bca8c

—> 70ba87d53366

Removing intermediate container 2cb9307bca8c

Step 10/13 : USER oracle

—> Running in 4d6736245ecb

—> b4e7b7448e96

Removing intermediate container 4d6736245ecb

Step 11/13 : RUN cd /u01 && $JAVA_HOME/bin/jar xf /u01/$FMW_PKG && cd – &&     $JAVA_HOME/bin/java -jar /u01/$FMW_JAR -invPtrLoc /u01/oraInst.loc -jreLoc $JAVA_HOME -ignoreSysPrereqs -force -novalidation ORACLE_HOME=$ORACLE_HOME &&     rm /u01/$FMW_JAR /u01/$FMW_PKG /u01/oraInst.loc /u01/install.file

—> Running in d3503cebeb70


Launcher log file is /tmp/OraInstall2017-04-24_10-33-06AM/launcher2017-04-24_10-33-06AM.log.

Extracting the installer . . . . . Done

Checking if CPU speed is above 300 MHz.   Actual 2208.004 MHz    Passed

Checking swap space: must be greater than 512 MB.   Actual 4093 MB    Passed

Checking if this platform requires a 64-bit JVM.   Actual 64    Passed (64-bit not required)

Checking temp space: must be greater than 300 MB.   Actual 5388 MB    Passed

Preparing to launch the Oracle Universal Installer from /tmp/OraInstall2017-04-24_10-33-06AM

Log: /tmp/OraInstall2017-04-24_10-33-06AM/install2017-04-24_10-33-06AM.log

Setting ORACLE_HOME to /u01/oracle


Distribution Name : Oracle Fusion Middleware 12c WebLogic and Coherence Developer

Distribution Version :

Oracle Inventory : /u01/oracle/.inventory

Oracle Home : /u01/oracle

Java Home : /usr/java/jdk1.8.0_131


Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.

Skipping Software Updates

Validations are enabled for this session.

Verifying data

Copying Files

Percent Complete : 10

Percent Complete : 20

Percent Complete : 30

Percent Complete : 40

Percent Complete : 50

Percent Complete : 60

Percent Complete : 70

Percent Complete : 80

Percent Complete : 90

Percent Complete : 100

The installation of Oracle Fusion Middleware 12c WebLogic and Coherence Developer completed successfully.

Logs successfully copied to /u01/oracle/cfgtoollogs/oui.

—> 3b15ddbb5d12

Removing intermediate container d3503cebeb70


—> 5ce528dc3f2f

Removing intermediate container 83c6eb0fea17

Step 13/13 : CMD /u01/oracle/

—> Running in e38fd1f7fb64

—> c635e85b3f1a

Removing intermediate container e38fd1f7fb64

Successfully built c635e85b3f1a

  WebLogic Docker Image for ‘developer’ version is ready to be extended:

    –> oracle/weblogic:

  Build completed in 562 seconds.


Build the third image adding the MedRec sample application

Now to install the medrec app on top of the weblogic image

Now in a terminal window change directory to /home/dmreid/myprojects/docker-images/OracleWebLogic/samples/12212-medrec .

Execute the following commands;

cd /home/dmreid/myprojects/docker-images/OracleWebLogic/samples/12212-medrec

sudo docker build -t 12212-medrec .

dmreid@dmrDevEnv:~/myprojects/docker-images/OracleWebLogic/samples/12212-medrec$ sudo docker build -t 12212-medrec .

Sending build context to Docker daemon 235.4 MB

Step 1/14 : FROM oracle/weblogic:

—> c635e85b3f1a

Step 2/14 : MAINTAINER Monica Riccelli <>

—> Using cache

—> fdadf1dc5135

Step 3/14 : ENV FMW_PKG “” FMW_JAR “fmw_12.” MW_HOME “$ORACLE_HOME” PATH “$ORACLE_HOME/wlserver/server/bin:$ORACLE_HOME/wlserver/../oracle_common/modules/org.apache.ant_1.9.2/bin:$JAVA_HOME/jre/bin:$JAVA_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$ORACLE_HOME/oracle_common/common/bin:$ORACLE_HOME/wlserver/common/bin:$ORACLE_HOME/user_projects/domains/medrec/bin:$ORACLE_HOME/wlserver/samples/server/medrec/:$ORACLE_HOME/wlserver/samples/server/:$ORACLE_HOME/wlserver/../oracle_common/modules/org.apache.maven_3.2.5/bin”

—> Using cache

—> 2a892c5b9b5f

Step 4/14 : COPY $FMW_PKG /u01/

—> Using cache

—> 8db586ec9712

Step 5/14 : USER root

—> Using cache

—> 0f3ac15b15d1

Step 6/14 : COPY /u01/oracle/

—> Using cache

—> 9deb4b29db55

Step 7/14 : RUN chmod +xr /u01/oracle/

—> Using cache

—> b3f689bb5673

Step 8/14 : USER oracle

—> Using cache

—> b918ed7b8fac

Step 9/14 : RUN cd /u01 && $JAVA_HOME/bin/jar xf /u01/$FMW_PKG && cd – &&     $JAVA_HOME/bin/java -jar /u01/$FMW_JAR  ORACLE_HOME=$ORACLE_HOME &&     echo $USER &&     mv /u01/oracle/ /u01/oracle/wlserver/samples/server/  &&     rm /u01/$FMW_PKG /u01/$FMW_JAR

—> Using cache

—> 238c6c5cf045

Step 10/14 : USER root

—> Using cache

—> fc73629ab361

Step 11/14 : RUN chmod +xr /u01/oracle/wlserver/samples/server/*.sh

—> Using cache

—> 7c66c26e8449

Step 12/14 : WORKDIR $ORACLE_HOME/wlserver/samples/server

—> Using cache

—> f312a50d2521

Step 13/14 : EXPOSE 7011

—> Using cache

—> 88bc4c08dea5

Step 14/14 : CMD

—> Using cache

—> 611bc3b60e1e

Successfully built 611bc3b60e1e

Now run the image using the following command;

sudo docker run 12212-medrec

dmreid@dmrDevEnv:~/myprojects/docker-images/OracleWebLogic/samples/12212-medrec$ sudo docker run 12212-medrec



Your environment has been set.

Buildfile: /u01/oracle/wlserver/samples/configure_samples.xml




Total time: 3 seconds

Initializing WebLogic Scripting Tool (WLST) …

Jython scans all the jar files it can find at first startup. Depending on the system, this process may take a few minutes to complete, and WLST may not return a prompt right away.

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Exiting WebLogic Scripting Tool.

wl_server domain created, you can go to /u01/oracle/wlserver/samples/domains/wl_server and use to start it

Initializing WebLogic Scripting Tool (WLST) …

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Exiting WebLogic Scripting Tool.

medrec domain created, you can go to /u01/oracle/wlserver/samples/domains/medrec and use to start it

Initializing WebLogic Scripting Tool (WLST) …

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Exiting WebLogic Scripting Tool.

medrec-spring domain created, you can go to /u01/oracle/wlserver/samples/domains/medrec-spring and use to start it



JAVA Memory arguments:







*  To start WebLogic Server, use a username and   *

*  password assigned to an admin-level user.  For *

*  server administration, use the WebLogic Server *

*  console at http://hostname:port/console        *


Starting WLS with line:

/usr/java/jdk1.8.0_131/bin/java -server -Dweblogic.Name=MedRecServer  -Xverify:none  -javaagent:/u01/oracle/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/u01/oracle/wlserver/server -Dweblogic.home=/u01/oracle/wlserver/server      weblogic.Server

<“ResourceManagement” is not enabled in this JVM. Enable “ResourceManagement” to use the WebLogic Server “Resource Consumption Management” feature. To enable “ResourceManagement”, you must specify the following JVM options in the WebLogic Server instance in which the JVM runs: -XX:+UnlockCommercialFeatures -XX:+ResourceManagement.>

Current log file=/u01/oracle/wlserver/samples/domains/medrec/servers/MedRecServer/logs/MedRecServer.log

Rotation dir=/u01/oracle/wlserver/samples/domains/medrec/servers/MedRecServer/logs

is opened. All server side log events will be written to this file.>

, application=SamplesSearchWebApp, contextPath=/docs, uri=/”.>


After the server has booted, your browser should automatically launch and point to the Avitek Medical Records Sample Application Introduction Page

running on this server. If your browser fails to launch, point your browser to the following URL: “;


<Channel “DefaultSecure[1]” is now listening on 0:0:0:0:0:0:0:1%lo:7012 for protocols iiops, t3s, ldaps, https.>

<Channel “Default[1]” is now listening on 0:0:0:0:0:0:0:1%lo:7011 for protocols iiop, t3, ldap, snmp, http.>

<Channel “Default” is now listening on for protocols iiop, t3, ldap, snmp, http.>

<Channel “DefaultSecure” is now listening on for protocols iiops, t3s, ldaps, https.>

<Channel “Default[2]” is now listening on for protocols iiop, t3, ldap, snmp, http.>

<Channel “DefaultSecure[2]” is now listening on for protocols iiops, t3s, ldaps, https.>

<Channel “DefaultSecure[1]” is now listening on 0:0:0:0:0:0:0:1%lo:7012 for protocols iiops, t3s, ldaps, https.>

<Channel “Default[1]” is now listening on 0:0:0:0:0:0:0:1%lo:7011 for protocols iiop, t3, ldap, snmp, http.>

<Channel “Default” is now listening on for protocols iiop, t3, ldap, snmp, http.>

<Channel “DefaultSecure” is now listening on for protocols iiops, t3s, ldaps, https.>

<Channel “Default[2]” is now listening on for protocols iiop, t3, ldap, snmp, http.>

<Channel “DefaultSecure[2]” is now listening on for protocols iiops, t3s, ldaps, https.>

Could not invoke browser:

No X11 DISPLAY variable was set, but this program performed an operation which requires it.

Run the dockerised MedRec app

With the image now built, in order to run the MedRec application, simply point a browser to . All in all, the process wasn’t difficult thanks to the well documented Git Hub projects provided by Oracle. The real drawback is that I have to download the WebLogic and JRE software to drop it into my environment, accepting the Terms and Conditions for each download.

Is there a better way I hear you ask? Well the good news is that Oracle has released a container registry for several Oracle products including WebLogic Server, JRE and the Oracle Database – refer . The pre-built image can then be pulled into your local docker environment from the Oracle registry. When you login you accept the terms and conditions once and it is valid for around 8 hours. One downside of this approach is that the images can be quite large so you really need to think about having a private registry on your premises.

Perhaps another logical improvement would be to utilise a private Docker registry hosted in the Oracle IaaS layer. The pull of docker images over the network is easier from Oracle cloud capabilities such as the Oracle Container Cloud Service (OCCS) as it is more of a ‘local’ pull. I plan to blog leveraging this OCCS based approach to achieve the same end result soon.

It would be great if Oracle offered a private Docker registry capability like this as a cloud service in the future.

A few additional Docker commands

Connect to Running Docker Container

sudo docker exec -it CONTAINER_ID /bin/bash

List Docker Images

dmreid@dmrDevEnv:~/myprojects/docker-images/OracleWebLogic/samples/1221-domain$ sudo docker images

REPOSITORY                                          TAG                  IMAGE ID            CREATED             SIZE

dmr-medrec                                          readytorun           1f59d9ee5b8e        18 seconds ago      1.61 GB

1221-domain                                         latest               fd8f3ad3ead7        About an hour ago   1.12 GB

12212-medrec                                        latest               611bc3b60e1e        2 hours ago         1.58 GB

oracle/weblogic                              c635e85b3f1a        2 hours ago         1.12 GB

oracle/serverjre                                    8                    a969bb27b4ef        3 hours ago         266 MB

                                                             8b37f43de2bf        3 hours ago         114 MB

                                                             4c08363b68f0        8 hours ago         1.01 GB

oraclelinux                                         7-slim               442ebf722584        3 days ago          114 MB

dre32722/hellofromnode                              latest               4a605a943ddb        2 weeks ago         422 MB

                                                             6e22d826f569        2 weeks ago         422 MB

                                                             dfa542232dbc        2 weeks ago         422 MB

                                                             7c2cf7621420        2 weeks ago         418 MB

                                                             1446fcddf640        2 weeks ago         418 MB

                                                             56d98a47b652        2 weeks ago         422 MB

                                                             3bbed3d7876a        2 weeks ago         418 MB

                                                             ebd2c7d7d48a        2 weeks ago         418 MB

                                                             87315a41bdc6        2 weeks ago         418 MB

                                                             bd831669b3a8        2 weeks ago         413 MB

                                                             6c949acafe4a        2 weeks ago         413 MB

                                                             cdb6ad7ed9aa        2 weeks ago         279 MB

                                                             47cea18f1e55        2 weeks ago         158 MB        6-slim               110a0f7b281d        3 weeks ago         120 MB

ubuntu                                              16.10                30b23364a716        7 weeks ago         104 MB

ubuntu                                              latest               0ef2e08ed3fa        7 weeks ago         130 MB

ubuntu                                              14.04.5              7c09e61e9035        7 weeks ago         188 MB         d2f16f60bbb4        2 months ago        1.01 GB

oraclelinux                                         7                    f6a4b5a3a7c7        2 months ago        225 MB

hello-world                                         latest               48b5124b2768        3 months ago        1.84 kB

Show Running Containers

dmreid@dmrDevEnv:~/myprojects/docker-images/OracleWebLogic/samples/1221-domain$ sudo docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

6a415e10c741        12212-medrec        “”    16 minutes ago      Up 16 minutes       7011/tcp            gifted_noyce

Stop Container

dmreid@dmrDevEnv:~/myprojects/docker-images/OracleWebLogic/samples/1221-domain$ sudo docker stop 6a415e10c741

Author: David Reid

PaaS - Middleware Solutions Consultant

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s