Installing WLS 12.2.1.2 in a Docker Container

I started playing around with running WebLogic in docker containers to be able to easily spin up a WebLogic server for simple prototyping etc.

I'll try to sum up my procedure here. Please note there are probably better solution out there, including more official images from Oracle, but something like this works for my use case. Please note that this should only serve as a simple example of how you COULD do it.

Creating the necessary configuration files

Create Dockerfile

Start by creating a Dockerfile with something like the following contents.

FROM centos:7

MAINTAINER Jesper Fussing Mørk <jfm@moerks.dk>

#SET UP ENVIRONMENT
ENV FMW_PKG=fmw_12.2.1.2.0_wls.jar \
JDK_PKG=jdk-8u111-linux-x64.tar.gz \
ORACLE_HOME=/u01/oracle \
JAVA_HOME=/u01/jdk1.8.0_111

#COPY FILES
COPY $JDK_PKG /u01/
COPY $FMW_PKG /u01/
COPY install.file /u01/
COPY oraInst.loc /u01/
COPY template.jar /u01/
COPY create-domain.py /u01/
COPY imageStart.sh /u01/

#RUN INSTALLATIONS
RUN tar zxf /u01/$JDK_PKG -C /u01/

RUN chmod a+xr /u01 && \
useradd -b /u01 -M -s /bin/bash oracle && \
chown oracle:oracle -R /u01 && \
echo oracle:oracle | chpasswd

RUN su -c "$JAVA_HOME/bin/java -jar /u01/$FMW_PKG -silent -responseFile /u01/install.file -invPtrLoc /u01/oraInst.loc -jreLoc $JAVA_HOME -ignoreSysPrereqs -force -novalidation ORACLE_HOME=$ORACLE_HOME INSTALL_TYPE=\"WebLogic Server\"" - oracle

RUN rm /u01/$JDK_PKG /u01/$FMW_PKG /u01/oraInst.loc /u01/install.file

#Start WebLogic Server
WORKDIR $ORACLE_HOME
CMD su -c /u01/imageStart.sh - oracle

This will create a CentOS container and install the WebLogic Server software. It will also create a simple domain and start the WebLogic Server.

Create install.file

Create a text file in the same folder with the name install.file with the following contents:

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

#DO NOT CHANGE THIS.
Response File Version=1.0.0.0.0

[GENERIC]

DECLINE_SECURITY_UPDATES=true
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false

Create oraInst.loc

Create another text file with the following contents:

inventory_loc=/u01/oracle/.inventory
inst_group=oracle

Create imageStart.sh

To prepare and start the WebLogic server when we run the image we need a script that starts it. Something like the following should do it

#!/bin/sh

export MW_HOME=/u01/oracle

/u01/oracle/oracle_common/common/bin/wlst.sh /u01/create-domain.py

/u01/oracle/user_projects/domains/poc/startWebLogic.sh

Create create-domain.py

We also need a WLST script that will create our domain from a domain template. The following is a very simple example

MIDDLEWARE_HOME = os.getenv("MW_HOME")

readTemplate("/u01/template.jar")

cd('/Security/poc/User/weblogic')
cmo.setPassword('Manager1')

setOption('OverwriteDomain', 'true')
print MIDDLEWARE_HOME+'/user_projects/domains/poc'
writeDomain(MIDDLEWARE_HOME+'/user_projects/domains/poc')
closeTemplate()
exit()

Exactly how to create a domain template is out of scope for this little guide, But it is as simple as creating domain and running the config_builder tool.

Download the needed Software

Download the WebLogic generic server i and JDK 8  tar.gz file from OTN

Unzip the WebLogic Server zip file and copy the jar file and the JDK tar.gz file to the folder where you created your Dockerfile.

Build the Image

Run the following command in the folder where you created your Dockerfile

docker build -f Dockerfile -t oracle/wls:12.2.1.2 .

If everything goes well the Image should be build. You might have to adjust some of the environment variables to your specific downloaded files.

Running the image

To actually run the image, issue the following command

docker run -ti -p 7001:7001 oracle/wls:12.2.1.2

This should start everything up and the weblogic server should now be available on port 7001