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 such a great option for Java EE based deployments that both developers and operations will benefit from it. Even Adam Bien, Java EE Rockstar, has agreed.

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

TL;DR

Alright, alright... Do the following:

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

$ unzip master.zip && 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 buildDockerImage.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 https://github.com/oracle/docker-images.git

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 buildDockerImage.sh, 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 buildDockerImage.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 create-wls-domain.py to get 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

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

Q: 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 create-wls-domain.py script while creating the domain. The WLST script will even use some defaults if these variables are not defined. Again, it's a sample.

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

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

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

Q: Can I build a Docker image with a deployed artifact?

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

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

 

 

 

 

Top