Docker, WebLogic Images on Local Linux

0
Share this on .. Tweet about this on TwitterShare on LinkedIn19Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

This blog series shows how to get started with WebLogic and Docker – in 3 different Clouds:

This blog is about creating and running a WebLogic Docker Container on a local machine and uploading the image to the Docker Hub registry.

Outline

This blog will show how to create an Oracle WebLogic Docker container image, using the official Oracle Docker images on GitHub (https://github.com/oracle/docker-images). Next, that image will be uploaded to the Docker Hub registry. Finally, the image from the Docker Hub registry will be run on a local machine.

Starting point

Starting point for this blog is:

  • a Docker account
  • an Oracle Enterprise Linux 7.3 machine, with graphical capabilities

 

Start Docker EE for Oracle Linux trial

First thing to do is to start a (free) 1 month trial for ‘Docker Enterprise Edition for Oracle Linux’. Log in with your Docker account and go to the Docker store (https://store.docker.com/editions/enterprise/docker-ee-server-oraclelinux/trial):

After you complete some more details and contact information, you will be on the page below:

Copy YOUR URL: https://storebits.docker.com/ee/oraclelinux/sub-3495f92c… as you will need it later.

 

Installation of Docker EE

 

I installed Docker EE on a OEL 7.3 machine. The steps are outlined below.

  • Check Linux Version and Kernel version

The commands below show how you can check the Linux release and Kernel version:

[developer@localhost ~]$ rpm -qf /etc/redhat-release oraclelinux-release-7.3-1.0.4.el7.x86_64 
[developer@localhost ~]$ uname -r 4.1.12-61.1.18.el7uek.x86_64 
[developer@localhost ~]$

The Linux release and Kernel versions are important, as Docker EE for Oracle is certified for specific versions – a familiar topic for on-premises solutions. Note that I’m running UEK (Unbreakable Enterprise Kernel) and not RHCK (Red Hat Compatible Kernel). I proceeded with the UEK kernel, despite the fact that Docker EE is only certified for RHCK – and didn’t encounter problems. I wouldn’t recommend that for a production set-up 😉

  • Configure the yum repository
[developer@localhost ~]$ su -

Password:

Last login: Thu Apr 27 10:36:54 EDT 2017 on pts/0

[root@localhost ~]# vi /etc/yum

yum/         yum.conf     yum.repos.d/

[root@localhost ~]# vi /etc/yum/vars/dockerurl

Now, paste the URL (the one you saved above) https://storebits.docker.com/ee/oralelinux/sub-3495f92c…  into the file, and save it.

  • Install yum-utils

Install yum-utils, which provides the yum-config-manager utility:

$ sudo yum install -y yum-utils

[root@localhost ~]# yum install -y yum-utils

Loaded plugins: langpacks, ulninfo

ol7_UEKR4                                                                                                                                    | 1.2 kB  00:00:00

ol7_latest                                                                                                                                   | 1.4 kB  00:00:00

Package yum-utils-1.1.31-40.el7.noarch already installed and latest version

Nothing to do

[root@localhost ~]#

  • Add the stable yum repository

Use the following command to add the stable repository:

[root@localhost ~]# yum-config-manager --add-repo https://storebits.docker.com/ee/oralelinux/sub-3495f92c-5a7e-4b52-b2ea-b95a8d03b9c1/docker-ee.repo</pre>

Loaded plugins: langpacks

adding repo from: https://storebits.docker.com/ee/oralelinux/sub-3495f92c-5a7e-4b52-b2ea-b95a8d03b9c1/docker-ee.repo

grabbing file https://storebits.docker.com/ee/oralelinux/sub-3495f92c-5a7e-4b52-b2ea-b95a8d03b9c1/docker-ee.repo to /etc/yum.repos.d/docker-ee.repo

repo saved to /etc/yum.repos.d/docker-ee.repo

[root@localhost ~]#

  • prepare the yum cache
[root@localhost ~]# yum makecache fast

Loaded plugins: langpacks, ulninfo

docker-ee-stable-17.03                                                                                                                       | 2.9 kB  00:00:00

ol7_UEKR4                                                                                                                                    | 1.2 kB  00:00:00

ol7_latest                                                                                                                                   | 1.4 kB  00:00:00

docker-ee-stable-17.03/x86_64/primary_db                                                                                                     | 6.1 kB  00:00:00

Metadata Cache Created

[root@localhost ~]#

  • Install docker-ee package

Now, install docker-ee:

[root@localhost ~]# yum -y install docker-ee

Loaded plugins: langpacks, ulninfo

Resolving Dependencies

--> Running transaction check

---> Package docker-ee.x86_64 0:17.03.1.ee.3-1.el7 will be installed



...

...

...

Installed:

docker-ee.x86_64 0:17.03.1.ee.3-1.el7

Dependency Installed:

docker-ee-selinux.noarch 0:17.03.1.ee.3-1.el7

Dependency Updated:

selinux-policy.noarch 0:3.13.1-102.0.3.el7_3.16                              selinux-policy-targeted.noarch 0:3.13.1-102.0.3.el7_3.16

Complete!

[root@localhost ~]#

Start and test of Docker EE

Now it is time to test the Docker EE installation by starting the daemon and running a docker container.

  • Start Docker daemon

As user root:

[root@localhost ~]# systemctl start docker

[root@localhost ~]#

  • Test docker

As user root, test by running the hello-world container image:

[root@localhost ~]# docker run hello-world

Unable to find image 'hello-world:latest' locally

latest: Pulling from library/hello-world

78445dd45222: Pull complete

Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7

Status: Downloaded newer image for hello-world:latest

Hello from Docker!

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 	
- The Docker client contacted the Docker daemon.

- The Docker daemon pulled the "hello-world" image from the Docker Hub.

- The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.

- The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

To try something more ambitious, you can run an Ubuntu container with:

$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

https://cloud.docker.com/

For more examples and ideas, visit:

https://docs.docker.com/engine/userguide/

[root@localhost ~]#

  • Running Docker as non-root user

To run Docker as a non-root user, you must add that user to the group ‘docker’. Note that this may have security implications when you do this in a production set-up.

First, verify that the group ‘docker’ is present and then add user ‘developer’ to that group:

[root@localhost ~]# grep docker /etc/group

docker:x:983:

[root@localhost ~]# usermod -aG docker developer

[root@localhost ~]#

Log-in as user developer (you may first need to log-out) and then test docker:

[developer@localhost ~]$ whoami

developer

[developer@localhost ~]$ docker run hello-world

Hello from Docker!

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

- The Docker client contacted the Docker daemon.

- The Docker daemon pulled the "hello-world" image from the Docker Hub.

- The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.

- The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

To try something more ambitious, you can run an Ubuntu container with:

$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

https://cloud.docker.com/

For more examples and ideas, visit:

https://docs.docker.com/engine/userguide/

[developer@localhost ~]$

Build a WebLogic container image

With Docker installed on the system, we can start to build a WebLogic Docker container image. The following steps are required:

  1. Download the Oracle Docker image files from GitHub
  2. Build the Oracle JDK (Server JRE) base image
  3. Build the Oracle WebLogic Server install image
  4. Build the Oracle WebLogic Server domain image
  • Download Oracle Docker image files from github

In GitHub, find the Oracle Docker image files: https://github.com/oracle/docker-images

Download them and unzip them as user developer in the home directory.

  • Build the Oracle JDK (Server JRE) base image

Download the jre (server-jre-8u131-linux-x64.tar.gz) from http://www.oracle.com/technetwork/java/javase/downloads/server-jre8-downloads-2133154.html.

Then build the Oracle Server JRE image:

[developer@localhost java-8]$ pwd

/home/developer/docker-images-master/OracleJava/java-8

[developer@localhost java-8]$ mv ~/Downloads/server-jre-8u131-linux-x64.tar.gz .

[developer@localhost java-8]$ docker build -t oracle/serverjre:8 .

Sending build context to Docker daemon 54.72 MB

Step 1/5 : FROM oraclelinux:7-slim

7-slim: Pulling from library/oraclelinux

1f5b026b07bc: Pull complete

Digest: sha256:fdfc68d89f73172835cc2c715084b5a754cefa230b5012f7d2e8305f19acdce9

Status: Downloaded newer image for oraclelinux:7-slim

---> 442ebf722584

Step 2/5 : MAINTAINER Bruno Borges <bruno.borges@oracle.com>

---> Running in dd5326816e4d

---> 97d3fa9565ae

Removing intermediate container dd5326816e4d

Step 3/5 : ENV JAVA_PKG server-jre-8u*-linux-x64.tar.gz JAVA_HOME /usr/java/default

---> Running in 22cb13c0d942

---> 5f4e6116a586

Removing intermediate container 22cb13c0d942

Step 4/5 : ADD $JAVA_PKG /usr/java/

---> bded319e9e7d

Removing intermediate container 09a592e1468e

Step 5/5 : RUN export JAVA_DIR=$(ls -1 -d /usr/java/*) &&     ln -s $JAVA_DIR /usr/java/latest &&     ln -s $JAVA_DIR /usr/java/default &&     alternatives --install /usr/bin/java java $JAVA_DIR/bin/java 20000 &&     alternatives --install /usr/bin/javac javac $JAVA_DIR/bin/javac 20000 &&     alternatives --install /usr/bin/jar jar $JAVA_DIR/bin/jar 20000

---> Running in 3a8c6176ff4f

---> 26377fc400d6

Removing intermediate container 3a8c6176ff4f

Successfully built 26377fc400d6

[developer@localhost java-8]$

  • Build the Oracle WebLogic Server install image

Download files:

Then build the Oracle WebLogic Server install image:

[developer@localhost 12.2.1]$ pwd

/home/developer/docker-images-master/OracleWebLogic/dockerfiles/12.2.1

[developer@localhost 12.2.1]$ mv ~/Downloads/fmw_12.2.1.0.0_wls_quick_Disk1_1of1.zip .

[developer@localhost 12.2.1]$ mv ~/Downloads/server-jre-8u131-linux-x64.tar.gz .

[developer@localhost 12.2.1]$ cp Dockerfile.developer  Dockerfile

[developer@localhost 12.2.1]$ docker build -t oracle/weblogic:12.2.1-developer .

Sending build context to Docker daemon 276.1 MB

Step 1/10 : FROM oracle/serverjre:8

---> 26377fc400d6

Step 2/10 : MAINTAINER Bruno Borges <bruno.borges@oracle.com>

…

…

Successfully built 98fd41ed6652

[developer@localhost 12.2.1]$

Now, images are:

[developer@localhost 12.2.1]$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

oracle/weblogic     12.2.1-developer    98fd41ed6652        5 minutes ago       1.06 GB

oracle/serverjre    8                   26377fc400d6        33 minutes ago      266 MB

oraclelinux         7-slim              442ebf722584        6 days ago          114 MB

hello-world         latest              48b5124b2768        3 months ago        1.84 kB

[developer@localhost 12.2.1]$

  • Build the Oracle WebLogic Server domain image

Build the Oracle WebLogic Server domain image. Note that I chose to build an image with the domain named ‘developer_domain’. So, when later on, I start a container from this image and see the domain named ‘developer_domain’, I know that it is really from the image I built myself.

The image is named ‘1221-domain’:

[developer@localhost 1221-domain]$ pwd

/home/developer/docker-images-master/OracleWebLogic/samples/1221-domain

[developer@localhost 1221-domain]$ docker build -t 1221-domain --build-arg ADMIN_PASSWORD=welcome01 --build-arg DOMAIN_NAME=developer_domain .

Sending build context to Docker daemon 27.14 kB

Step 1/17 : FROM oracle/weblogic:12.2.1-developer

---> 98fd41ed6652

Step 2/17 : MAINTAINER Bruno Borges <bruno.borges@oracle.com>

…

…

Successfully built 10e8405f95fa

[developer@localhost 1221-domain]$

Run and Test theWebLogic container image

Running a container from this image is quite simple. The container is named wlsadmin, container port 7001 is mapped to port 7001 on the local machine:

[developer@localhost 1221-domain]$ docker run -d  --name wlsadmin -p 7001:7001 1221-domain

41cb5ee31b1fc0076e0b281cd0a4cd72744b7bc5855b1412a3c0cdd602b61725

Verify that the container is running:

[developer@localhost 1221-domain]$ docker container list

CONTAINER ID        IMAGE               COMMAND              CREATED             STATUS              PORTS                                                  NAMES

41cb5ee31b1f        1221-domain         "startWebLogic.sh"   29 seconds ago      Up 28 seconds       5556/tcp, 7002/tcp, 8453/tcp, 0.0.0.0:7001->7001/tcp   wlsadmin

[developer@localhost 1221-domain]$

And the ultimate test is to point a browser to the well-known url http://localhost:7001/console and watch the WebLogic login screen appear!

Stop the WebLogic container

Stop the container using (part of) the container ID:

[developer@localhost ~]$ docker container list

CONTAINER ID        IMAGE               COMMAND              CREATED              STATUS              PORTS                                                  NAMES

e283cbcebca9        1221-domain         "startWebLogic.sh"   About a minute ago   Up About a minute   5556/tcp, 7002/tcp, 8453/tcp, 0.0.0.0:7001->7001/tcp   trusting_beaver

[developer@localhost ~]$ docker stop e28

e28

[developer@localhost ~]$

Prepare a Docker Hub registry

We want to store the WebLogic container image that we created in the previous part in a Docker container registry. That should make this image available for running in the Oracle, Microsoft and Amazon clouds. The obvious choice is to use Docker Hub as a registry.

First, log in into Docker Cloud (https://hub.docker.com) and use your Docker account to login:

Click on ‘Create Repository’ (remember: a repository is a part of a registry where images are stored that have the same name but different tags):

Add yourself (i.e. your own user account) as a collaborator:

You need to be added as ‘Collaborator’ so you can upload images!

Now, the respository is ready to be used.

Upload the image into Docker Hub repository

First, tag the image with the same name that it has in the Docker Hub repository:

[developer@localhost ~]$ docker image list

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

1221-domain         latest              10e8405f95fa        37 hours ago        1.06 GB

oracle/weblogic     12.2.1-developer    98fd41ed6652        38 hours ago        1.06 GB

oracle/serverjre    8                   26377fc400d6        38 hours ago        266 MB

oraclelinux         7-slim              442ebf722584        8 days ago          114 MB

hello-world         latest              48b5124b2768        3 months ago        1.84 kB

[developer@localhost ~]$ docker tag 1221-domain:latest lgorissen/myfirstweblogic:latest

[developer@localhost ~]$

For uploading the image, login into the repository and push the image:

[developer@localhost ~]$

[developer@localhost ~]$ docker login

Username: lgorissen

Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.

Password:

Login Succeeded

[developer@localhost ~]$ docker push lgorissen/myfirstweblogic

The push refers to a repository [docker.io/lgorissen/myfirstweblogic]

bdf62266c46a: Pushed

018ffe8b5f56: Pushed

1b2e609eea7b: Pushed

091f64d4e188: Pushed

4ccdb37e8c17: Pushed

b94907830dcf: Pushed

latest: digest: sha256:0a38df39cdabe4b235e4547b5eaf7af4d2ea163e7bc8bc1bf2e5c333091a7042 size: 1582

[developer@localhost ~]$

Now, verify in your Docker Hub repository that the image is actually there…

Share this on .. Tweet about this on TwitterShare on LinkedIn19Share on Facebook0Share on Google+0Email this to someoneShare on Tumblr0Buffer this page

About Author

Luc Gorissen works in IT since 1990. He has held various positions in many areas, and works since 2006 with Oracle Middleware. He likes the challenge of introducing new technologies in large companies. In the last couple of years, Business Process Management and Case Management are his main focus areas.

Leave a Reply