Monday Feb 15, 2016

WebLogic on Docker Containers Series, Part 3: Creating a Domain Image

You already know how to quickly get started with WebLogic on Docker. You also learned with more details how to build an installation Docker image of WebLogic and Oracle JDK. This time, you will learn how to create a WebLogic Domain Image for Docker Containers.

We are pushing some interesting samples of Docker images on GitHub so this way WebLogic customers and users can have a good idea of what is possible (although not everything in there may be officially supported as of this moment, like multihost), but to experiment and learn more about Docker itself. This blog post focuses on the 1221-domain sample, but make sure to subscribe to this blog or follow me on Twitter for future posts that will look into the other samples.

I will also assume that you have the docker-images repository checked out and updated in your computer (with commit 4c36ef9f99c98), and of course you have Docker installed and properly working. Now moving on. 

WebLogic Domains

WebLogic uses a Domain concept for its infrastructure. This is the first thing a developer or administrator must create in order to be able to run a WebLogic Server. There are many ways to create a WebLogic Server Domain: using the Configuration Wizard, using WLST, or even bootstrapping the weblogic.Server class. Since we are using Docker and we want to automate everything, we create the domain with WLST.

TL;DR; Building the Domain Image in 1221-domain sample

First things first, make sure you have image oracle/weblogic:12.2.1-developer already created. If not, check Part 2 of this series to learn how. 

Now go into folder samples/1221-domain and run the following command:

$ pwd
$ docker build -t 1221-domain --build-arg ADMIN_PASSWORD=welcome1 .
$ docker images
REPOSITORY              TAG                     IMAGE ID            CREATED             SIZE
1221-domain             latest                  327a95a2fbc8        2 days ago          1.195 GB
oracle/weblogic         12.2.1-developer        b793273b4c9b        2 days ago          1.194 GB
oraclelinux             latest                  4d457431af34        10 weeks ago        205.9 MB

This is what you will end up having in your environment. 

Understanding the sample WLST domain creation script

Customers and users are always welcome to come up with their own scripts and automation process to create WebLogic domains (either for Docker or not), but we shared some examples here to make things easier for them.

The 1221-domain sample has a subfolder named container-scripts that holds a set of handy scripts to create and run a domain image. The most important script though is the WLST script. This file is executed when docker build is called, as you can see in the Dockerfile. In this sample, you learn how to read variables in script with default values, that may be defined in the Dockerfile.

The script defined in this sample requires a set of information in order to create a domain. Mainly, you need to provide:

  • Domain name: by default 'base_domain'
  • Admin port (although WLS has 7001 by default when installed, this script defaults to 8001 if nothing is provided)
  • Admin password: no default. Must inform during build with --build-arg ADMIN_PASSWORD=<your password>
  •  Cluster Name: defaults to 'DockerCluster' 

Note about About Clustering

This sample shows how to define a cluster named with whatever is in $CLUSTER_NAME (defaults to DockerCluster) to demonstrate scalability of WebLogic on Docker containers. You can see how the Cluster is created in the WLST file.

Back to the domain creation

How to read variables in WLST with default values? Pretty simple:

domain_name = os.environ.get("DOMAIN_NAME", "base_domain")
admin_port = int(os.environ.get("ADMIN_PORT", "8001"))
admin_pass = os.environ.get("ADMIN_PASSWORD")
cluster_name = os.environ.get("CLUSTER_NAME", "DockerCluster")

These variables can be defined as part of your Dockerfile, or even passed as arguments during build if you are using Docker 1.10 with the new ARG command, as the ADMIN_PASSWORD example shows.

ENV DOMAIN_NAME="base_domain" \
ADMIN_PORT="8001" \
ADMIN_HOST="wlsadmin" \
NM_PORT="5556" \
MS_PORT="7001" \
CLUSTER_NAME="DockerCluster" \

Other variables are defined here (NM_PORT, MS_PORT, ADMIN_HOST), but I'll explain them later on a future post. Meanwhile, let's continue.

The next step as part of a domain image creation, is that you may want to reuse some Domain Template. In the sample script, we used the default template for new domains wlst.jar, but agan if you are working on your own set of domains feel free to use any template you may already have.

Next we tell WLST to configure the AdminServer to listen on all addresses that will be available (in the container), and to listen on port as in $ADMIN_PORT.

The 'weblogic' admin user needs a password that you had to provide with --build-arg (or defined directly inside Dockerfile) in $ADMIN_PASSWORD, and then we set that in the script.

For the sake of providing some examples, we also define a JMS Server in the script, but we only target it to the AdminServer. If you want to target to the Cluster, you will have to tweak your own script. 

The script is configured to set this domain in Production Mode too. 

We set some Node Manager options, since we will be using NM as Per Domain (see docs for more details). Remember that each instance of this image (a container) has the same "filesystem", so it is as if you had copied the domain to different servers. If you are an experienced WebLogic administrator, you will quickly understand. If not, please comment and I'll share some links. This is important to be able to run Managed Servers inside containers based on this image. I'll get back to this in the future on running a Clustered WebLogic environment on Docker containers.

There are a couple of other things we could've done in this script, such as:

  • Create and define a Data Source
  • Create, define, and deploy applications (this is demonstrated as part of the 1221-appdeploy sample)
  • And anything else you can do with WLST in Offline mode (remember that domain does not exist and thus is not running)

But sure you will quickly find out how to do these for your own domains.

Now that you have a domain Docker image 1221-domain, you are able to start it with:


$ docker run -ti 1221-domain


Now have some fun with tweaking your own WLST scripts for domain creation in Docker.

Wednesday Jan 06, 2016

WebLogic on Docker Containers Series, Part 2

On my previous post, the first part of this series, I've shown to you how to quickly get started with WebLogic on Docker. You've learned how to create a base Docker image with WebLogic and Oracle JDK installed, and then how to create a second image that contains a configured WebLogic domain. Today's post will break down and explain what happens behind the scenes of that process

Note: for the sake of history and keep this blog post useful in the future, I will refer to the commit 7741161 from the docker-images GitHub project, and version 12.2.1 of WebLogic.

Walking through the build process of a WebLogic base image

A base image of WebLogic means an image that contains only the software installed with minimum configuration, to further be extended and customized. It may be based on a Red Hat base Docker image, but preferably, we recommend you to use the Oracle Linux base image.

Samples for how to build a base image are presented in the dockerfiles folder. Files for WebLogic versions 12.1.3 and 12.2.1 are maintained there, as well for two kinds of distributions: Developer, and Generic. Other versions and distributions may be added in the future.

Differences between Developer and Generic distributions

There aren't many differences between them, except these (extracted from the README.txt file inside the Quick Installer for Developer):


- Native JNI libraries for unsupported platforms.
- Samples, non-english console help (can be added by using the WLS supplemental Quick Install)
- Oracle Configuration Manager (OCM) is not included in the Quick installer
- SCA is not included in the Quick Installer

Also, the Quick Installer for Developers is compressed using pack200, an optimized compression tool for Java classes and JAR files, to reduce the download size of the installer. Besides these differences, the two distributions work perfectly fine for Java EE development and deployment.

Building the Developer distribution base image

Although we provide a handy shell script to help you in this process, what really matters relies inside 12.2.1 folder and the Dockerfile.developer file. That recipe does a COPY of two packages, the RPM of JDK, and the WebLogic Quick Installer. These files must be present. We've put these .download files as placeholders to remind you of the need to download them. This same approach will apply for the Generic distribution.

The installation of JDK uses rpm tool, which enables us to run Java inside the base image. A very obvious requirement. After JDK is installed, we proceed with the installation of WebLogic by simply calling "java -jar", and later we clean up yum.

An important observation is the use of /dev/urandom in the Dockerfile. WebLogic requires some level of entropy for random bits that are generated during install, and as well domain creation. It is up to customers to decide whether they want to use /dev/random or /dev/urandom. Please configure this as desired.

You can build this image in two ways:

  1. Using script. Indicate you want developer distribution [-d], and version 12.2.1 [-v 12.2.1].

    $ pwd
    $ sh -d -v 12.2.1

  2. Manually calling docker build:

    $ cd 12.2.1
    $ docker build -t oracle/weblogic:12.2.1-dev -f Dockerfile.developer .

Either of these calls result in the following:

REPOSITORY          TAG            IMAGE ID         CREATED          VIRTUAL SIZE
oracle/weblogic     12.2.1-dev     99a470dd2110     15 secs ago      1.748 GB
oraclelinux         7              bea04efc3319     5 weeks ago      206 MB
oraclelinux         latest         bea04efc3319     5 weeks ago      206 MB

As you may have know by now, this image contains only WebLogic and JDK installed, and thus does not serve to be executed, only to be extended.

Building the Generic distribution base image

Most of what you've learned from above applies to the Generic distribution. The differences are that you must download, obviously, the Generic installer. The installation process is a little bit different, since it uses the silent install mode, with environment definition coming from install.file and oraInst.loc.

To build this image you either do by:

  1. Call script. Indicate you want Generic distribution [-g], and version 12.2.1 [-v 12.2.1].

    $ pwd
    $ sh -g -v 12.2.1

  2. Manually calling docker build:

    $ cd 12.2.1
    $ docker build -t oracle/weblogic:12.2.1 -f Dockerfile.generic .

Now you have two images you can extend from, either the Developer, or the Generic base image:

REPOSITORY          TAG            IMAGE ID         CREATED          VIRTUAL SIZE
oracle/weblogic     12.2.1         ea03630ee95d     18 secs ago      3.289 GB
oracle/weblogic     12.2.1-dev     99a470dd2110     2 mins ago       1.748 GB
oraclelinux         7              bea04efc3319     5 weeks ago      206 MB
oraclelinux         latest         bea04efc3319     5 weeks ago      206 MB

Note how the Generic image is larger than the developer image. That's because the Developer distribution contains less stuff inside, as described earlier. It will be up to Dev and Ops teams to decide which one to use. And how to build them.

In the next post, I will walk you through the process of building the 1221-domain sample image.

If you have any questions, feel free to comment, or tweet.

Monday Jan 04, 2016

WebLogic on Docker Containers Series, Part 1

WebLogic 12.2.1 is certified to run Java EE 7 applications, supports Java SE 8 (since 12.1.3), and can be deployed on top of Docker containers. It also supports Multitenancy through the use of Partitions in the domain, enabling you to add another level of density to your environment. Undeniably, WebLogic is so much of a great option for Java EE based deployments that both developers and operations will benefit from. Even Adam Bien, Java EE Rockstar, has agreed with that.

But you are here to play with WebLogic and Docker, so first, check these links about the certification and support:

Understanding WebLogic on Docker

We recommend our customers and users to build their own image containing WebLogic and Oracle JDK installed without any domain configured. Perhaps a second image containing a basic domain. This is to guarantee easier reuse between DevOps teams. Let me describe an example: Ops would provide a base WebLogic image to Dev team, either with or without a pre-configured domain with a set of predefined shell scripts, and Devs would perform domain configuration and application deployment. Then Ops get a new image back and just run containers out of that image. It is a good approach, but certainly customers are free to think out of the box here and figure out what works best for them.


Alright, alright... Do the following:

1 - Download docker-images' file repository directly and drop somewhere.

$ unzip && mv docker-images-master docker-images

2 - Download WebLogic 12.2.1 for Developers and Oracle JDK 8 specific versions as indicated in Checksum.developer. Put them inside dockerfiles/12.2.1 folder. You will see placeholders there (*.download files).

3 - Build the installation image

$ cd docker-images/OracleWebLogic/dockerfiles

$ sh -d -v 12.2.1

4. Build the WebLogic Domain image

$ cd ../samples/1221-domain

$ docker build -t 1221-domain .

5. Run WebLogic from a Docker container

$ docker run -d -p 8001:8001 1221-domain

6. Access Admin Console from your browser: http://localhost:8001/console

Note that these steps are for your first image build only. Customers are encouraged to run a Docker Registry at their internal network, and store these images there just as they probably already do with Oracle software installers at some intranet FTP server. Important! Do not share binaries (either packed as a Docker image or not).

* follow this series if you want to learn more of WebLogic on Docker. But please do read the entire post... :-)

Creating your first WebLogic Docker Image

The very first step to get started, is to checkout the docker-images project on GitHub:

$ git checkout --depth=1

If you don't have or don't want to install the Git client, you can download the ZIP file containing the repository and extract it. Use your browser, or some CLI tool.

Another thing to know before building your image, is that WebLogic comes in two flavors: one is the Developer distribution, smaller, and the other is the Generic distribution, for use in any environment. For the developer distribution, you have to download two files indicated inside Checksum.developer. If you want to build the Generic distribution instead of the Developer, see file Checksum.generic for further instructions, but tl;dr; you need two files again (or one if you have downloaded JDK already). The same instructions apply.

Next step is to go to the terminal again and use the handy shell script, which will do some checks (like checksum) and select the proper Dockerfile (either .developer or .generic) for the specific version you want, although I do recommend you start with 12.2.1 from now on.

$ cd docker-images/OracleWebLogic/dockerfiles
$ sh -d -v 12.2.1

You may notice that it takes some time to copy files during the installation process. That's because WebLogic for Developers is compressed with pack200 to be a small download. But after you build this image, you can easily create any domain image on top of it, and you can also share your customized image using docker save/load. Next step is to create a WebLogic Domain.

Creating the WebLogic Domain Image

So far you have an image that is based on Oracle Linux 7 and has WebLogic 12.2.1 for Developers, and Oracle JDK installed. To run WebLogic, you must have a domain. Luckily WebLogic is mature enough to be very handy for DevOps operations, and has support for a scripting tool called WLST (you guessed: WebLogic Scripting Tool), based on Jython (Python for Java) that allows you to script any task that you'd perform through a wizard or the web interface, from installation to configuration to management to monitoring. I've shared some samples on the GitHub project and I'll cover a couple of them in this series of WebLogic on Docker, but for now, let's just create the basic, empty WebLogic Domain.

Go to the samples folder and access folder 1221-domain. When there, just simply perform:

$ cd docker-images/OracleWebLogic/samples/1221-domain
$ docker build -t 1221-domain .

This process is very fast, at least for this sample. Time may vary if your WLST for creating a domain performs more tasks. See the sample to have some ideas.

Starting WebLogic on Docker

You now have the image 1221-domain ready to be used. All you need to do is to call:

$ docker run -ti -p 8001:8001 1221-domain

And now you can access the Admin Console on http://localhost:8001/console.

Frequently Asked Questions, Part 1

- Can I write my own Dockerfiles and WLST scripts to install and create WebLogic?

A: absolutely! That is the entire idea of sharing these scripts. These are excellent pointers on what can be done, and how. But customers and users are free to come up with their own files. And if you have some interesting approach to share, please send to me at bruno dot borges at oracle dot com.

- Why is WebLogic Admin on port 8001 instead of default 7001?

A: Well, it is a sample. It is to show what configurations you can do. The environment variable ADMIN_PORT, as well other configurations in the samples/1221-domain/Dockerfile are picked up by the script while creating the domain. The WLST script will even use some defaults if these variables are not defined. Again, it's a sample.

- What if I need to patch the WebLogic install?

A: you do that by defining a new Dockerfile and apply the patch as part of the build process, to create a new base image version. Then you recreate your domain image that extends the new patched base image. You may also want to simply extend your existing domain image, apply the patch, and use that one, or you can also modify your image by applying the patch in some existing container, then committing the container to a new image. There are different ways to do that, but for sure applying the patch to a live container is not one of them, since it is a good idea to keep containers as disposable as possible, and you should also have an image from where you can create new patched containers.

- What if I want a WebLogic cluster with Node Manager and Manged Servers?

A: that works too. I'll cover that in this series.

- Can I build a Docker image with a deployed artifact?

A: yes. More on that in upcoming blog posts of this series.

- Can I have a Load Balancer in front of a Swarm of Docker containers?

A: yes. That will also be covered as part of this series.

I hope you are excited to learn more about WebLogic on Docker.
So please follow this blog and my Twitter account for upcoming posts.

Friday Nov 28, 2014

Oracle Linux Docker Base Image on Ubuntu 14.10

Oracle Linux team has been working hard to provide Docker support. You will be glad to see that they, since August, are releasing Docker binaries in Oracle Linux YUM repositories. Now recently they are also publishing the Oracle Linux Docker Base Images for OL6 and OL7! The documentation of Oracle Linux (OL6 and OL7) and Docker is also well advanced and explanatory. Keep track of everything about Docker and Oracle Linux from this yum page.

And why is this important you may ask? Well because it's definitely a required step if at some point the Fusion Middleware product teams move forward in certifying their products, such as WebLogic, on Docker as well. So if you want to work with Oracle products on Docker right now, although yet not certified nor supported, make sure you use the OL base images.

As a developer, I like to use Ubuntu Linux on my laptop. To use the OL7 Docker Base Image for example, I had to follow the following very short and easy steps:

  1. Make sure you have Docker installed on your Ubuntu environment

  2. Download the OL7 Base Image.

  3. Uncompress the file first with xz. You may find an issue where docker can't find the xz binary.
    $ sudo docker load -i oraclelinux-7.0.tar.xz
    2014/11/28 18:36:08 Error: Untar exit status 1 exec: "xz": executable file not found in $PATH

    $ unxz oraclelinux-7.0.tar.xz

  4. Load the image in your local Docker repository, as root, after extracting with xz (but keeping tar)
    $ sudo docker load -i oraclelinux-7.0.tar

  5. Check installation
    $ sudo docker images
    oraclelinux    7.0  5f1be1559ccf   2 weeks ago    265.2 MB

  6. Create and run a container based on this image
    $ sudo docker run -t -i oraclelinux:7.0 bash
Now have fun with Docker and Oracle Linux, and let me know if you create something cool with Fusion Middleware products!

Monday Jun 30, 2014

Docker, Java EE 7, and Maven with WebLogic 12.1.3

UPDATE January 2016 - We now officially certify and support WebLogic 12.1.3 and WebLogic 12.2.1 on Docker Containers! For more information see this blog post and this whitepaper on OTN. The Docker configuration files are also now maintained on the official Oracle GitHub Docker repository. WebLogic 12.2.1 is also Java EE 7 and JDK 8 certified. Links in the Docker section of this article have also been updated to reflect the latest updates and changes.

For more up to date information on Docker scripts and support, check the Oracle GitHub project docker-images.

WebLogic 12.1.3 was released and with it the support for perhaps the most important Java EE 7 APIs for database-backed Web Applications development. These are the specifications supported in this release:
As you can see above, WebLogic is bundled with the same implementations used by GlassFish 4.0, which gives you a compatible application server if you have already started developing Java EE 7 applications (well, of course limited to these APIs) and now seek for a commercially supported environment.

There are also some improvements in the Apache Maven Plugin, which makes developers' life much easier, allows for much better automated testing (Arquillian!), Continuous Integration and Delivery. IDEs that support Maven-based projects also benefit from this.

Does this makes WebLogic the best Java EE application server to run modern web HTML5/Javascript applications with RESTful and WebSockets services? Sure yes! So to give you a great way to test WebLogic, I created a Dockerfile for you to in order to create a WebLogic domain on your development environment to test it as you wish. Go to the OracleWebLogic for the Developer ZIP Distro Dockerfile on the Official Oracle GitHub repository for Docker images.

Getting started with WebLogic 12.1.3, Java EE 7, Maven, and Docker

Now let's get it started. First go to and download WebLogic 12.1.3 ZIP Distro for Developers. Save that file for later use.

Installing WebLogic 12.1.3 without Docker (easy)
WebLogic ZIP is very easy to install:
  1. Extract the content in a folder where you want to hold the wls12130 directory that comes inside the ZIP file. On my Linux machine, I use /home/bruno/Work/tools/.
  2. Go to the wls12130 folder and run the configure.cmd (Windows) or (Unix).
    • Creating the domain may take too long and may be seen as the installer is freezed. Make sure to configure this if you are on Linux:
      $ export
  3. When the installer asks you if you want to create a domain, type [Y]
  4. Installer will ask you for username/password. On dev environments, I usually use weblogic/welcome1
  5. Installer will start WebLogic right away and you can check it running at http://localhost:7001/console

Installing WebLogic 12.1.3 with Docker (easier)

If you work on a Linux-based machine as your development environment and you aren't familiar with Docker yet, check the What is Docker, then give it a try. Long story short: Docker is a Linux container; it is like a virtual machine, but it is not (there are people running Docker on top of Vagrant virtual machines, for example). The most important thing for us here is that it will create a virtual network interface with a virtual IP address.

My laptop runs Ubuntu 14.04, so I used this Docker Installation Instruction to set it up. I will assume you will have Docker installed on your computer somehow, following instructions for your own operational system.
  1. Download the ZIP or checkout the docker-images Git repository and extract somewhere on your computer. I will use $DOCKER_HOME as a reference to that location.
  2. Copy the you download previously into $DOCKER_HOME/docker-images/dockerfiles/12.1.3
  3. Call the ../ script (as sudo) and wait for Docker to do its magic
  4. Call docker run -p 8001:8001 oracle/weblogic:12.1.3-developer and see WebLogic going up and running on a Docker container. 
    • It will attach port 8001 to your host interfaces
  5. Open http://localhost:8001/console. Username/password are weblogic/welcome1

Configuring your local Maven repository

It is now possible to use Maven without a local installation of WebLogic, which is perfect for CI environments (Hudson/Jenkins). You will still require a installation though to set up the Maven Plugin initially, but as soon you install this to your remote Maven repository for example, other developers and CI envs won't need to have WebLogic installed locally, if deploying to a remote server. For local development, you can also point to WebLogic as a "remote" server, of course. 

The steps to configure Maven are well documented and it is done by the Maven Synchronization Plug-in. After installing it to your local repository, you can call the sync goal to populate a local or remote repository. Here are the steps for a local environment:
  1. Go to the WebLogic home installation directory. For example:
    $ cd /home/bruno/Work/wls12130/
  2. Go to the subdir
    $ cd oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3/
  3. Execute the following command:
    $ mvn install:install-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar
  4. Finally you call the push command to upload all Maven artifacts (plugins, archetypes, etc) to your repository (local in this case)
    $ mvn -DoracleHome=/home/bruno/Work/wls12130/
If you want to setup a remote repository, check the documentation.

Create Java EE applications with WebLogic Maven Archetypes

WebLogic provides a set of archetypes that come with the Maven Plug-in pre-configured. Let's create a simple Web project by using the Basic WebApp Maven Archetype
mvn archetype:generate
Now of course you can open this Maven project on your NetBeans, IntelliJ IDEA, Eclipse, and then setup WebLogic in your IDE. Or you can just issue the command below to build, package, and deploy this WAR artifact to the WebLogic server you have running on your computer (either using Docker or the normal installation):
mvn package pre-integration-test 
Here we make sure to use -Dupload=true since I'm not sure if you are using Docker or not. If you are, then upload is required since the container has no access to your local file system (although possible!)

Description of wls_02.jpg follows

Now open http://localhost:7001/basicWebapp and see this sample application up and running!


By the way if you are an IntelliJ IDEA user you may want to watch this recent Webinar I did with JetBrains team: Developing Java EE Applications for WebLogic 12c with IntelliJ IDEA. The slides are available as well:

Check Bruno Borges slideshare repository


Bruno has been having fun working with Java since 2000 and now helps Oracle on sharing the technology accross all Latin America. Also plays videogames, does trekking and loves beer.

Follow me on Twitter! @brunoborges


« July 2016