This blog series shows how to get started with WebLogic and Docker – in 3 different Clouds:
- Docker and the Oracle Images
- Create and run a WebLogic Docker Image on a local machine and upload the WebLogic Docker Image into the Docker Hub registry
- WebLogic Docker Container on Oracle Container Cloud Service
- WebLogic Docker Container on Microsoft Azure Container Service
- WebLogic Docker Container on Amazon EC2 Container Service
This blog is running a WebLogic Docker Container image from the Docker Hub registry on the Microsoft Azure Container Service.
Starting point & Outline
Starting point for this blog is:
- A computer running Ubuntu and with Docker installed
- A WebLogic Docker Container Image in a private Docker Hub repository, as described in this blog
- Access to Microsoft Azure, e.g. via a trial subscription
The blog itself consists of 2 main parts:
- Create an Azure Container Service
- Run the container image from the Docker Hub repository on the created Cloud Service
Create an Azure Container Service
The Azure Container Service offers the choice between using Docker Swarm, DC/OS, or Kubernetes for orchestration/management of the Docker container solution. For our specific use case, I picked Docker Swarm.
The high level steps for creating your Azure Container Service are:
- create an SSH RSA public key
- deploy an Azure Container Service cluster (via the Azure portal), by using an Azure Resource Manager template (for Docker Swarm)
Let’s get started.
- create an SSH RSA public key
Log in into the Ubuntu machine and generate the key:
developer@developer-VirtualBox:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/developer/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/developer/.ssh/id_rsa. Your public key has been saved in /home/developer/.ssh/id_rsa.pub. The key fingerprint is: SHA256:Lpm8BrZoQscz1E6Maq9J0WdjjLjHAP5fxZXBdlrdzMY developer@developer-VirtualBox The key's randomart image is: +---[RSA 2048]----+ | .. .+.| | ooo .E| |. + .o+ . | |o ooo+ . .. | | =+oo* So | | +*=*o.+. | |ooo*oo=.. | |o =.o oo | | =. o. | +----[SHA256]-----+ developer@developer-VirtualBox:~$
- deploy an Azure Container Service cluster (via the Azure portal), by using an Azure Resource Manager template (for Docker Swarm)
First, login into the Microsoft Azure Portal on http://portal.azure.com. Here, click the + sign, select ‘Containers’ and then ‘Azure Container Service’:
The next screen appears:
Click the Create button.
Complete the settings like shown in the figure above and click OK to move to the next page:
For the Master configuration, complete the settings as shown above. Use the SSH key that was created in step (1). Note that the ‘Master’ is the Manager node in a Docker Swarm. One Master node is enough for this simple configuration. Next, click OK.
That brings us to the Agent configuration page, where Agent is actually a Docker Swarm Worker node. We need only 1 agent. For the Virtual Machine size, the DS2 profile is chosen, which has 2 cpu cores and 7GB of RAM. That should be enough to run the WebLogic container on.
Click OK to continue:
Review the Summary page, and the click OK to start creation of your Azure Container Service:
After some time, your Azure Container Service will be created!
Run the WebLogic image from Docker Hub registry
Now, we will start to get the WebLogic image from the Docker Hub registry running on the Azure Container Service. This is achieved from the command line of our local Ubuntu machine – the one that also has Docker installed.
The following steps will be done:
- Make a tunnel to the Master node
- Run the WebLogic container
- Add a LoadBalancer rule for forwarding port 7001
- Test
Let’s get started.
- Make a SSH tunnel to the Master node
From the local Ubuntu machine, make an SSH tunnel to the Master node. In that way, docker commands from the Ubuntu machine will be handled by the Docker Swarm container on the Master node. First, establish the tunnel, set the Docker host that will be used by the local Ubuntu machine and then list the images. The output of the ‘docker images list’ command shows what Docker images are available on the Master node – in our case: none (as this is a fresh installation):
developer@developer-VirtualBox:~$ ssh -fNL 2375:localhost:2375 -p 2200 lgorisse@lgomgmt.northeurope.cloudapp.azure.com developer@developer-VirtualBox:~$ export DOCKER_HOST=:2375 developer@developer-VirtualBox:~$ docker images list REPOSITORY TAG IMAGE ID CREATED SIZE developer@developer-VirtualBox:~$
- Run the WebLogic container
Now, give the commands below on the local Ubuntu machine to start the WebLogic container on the Azure Container Service. The WebLogic container will run on the agent machine.
The following steps have to be done:
- Login into the Docker Hub, using your Docker Hub account. This is necessary because the Docker Hub registry that I used is a private registry (= password protected)
- Pull the WebLogic Container image with the docker pull command
- Run the image with the port mapping for port 7001
- Notice in the output below that I also had a yeasy/simple-web container running
developer@developer-VirtualBox:~$ docker login 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. Username: lgorissen Password: Login Succeeded developer@developer-VirtualBox:~$ docker pull lgorissen/myfirstweblogic Using default tag: latest swarm-agent-595FAAF3000001: Pulling lgorissen/myfirstweblogic:latest... : downloaded developer@developer-VirtualBox:~$ docker run -d -p 7001:7001 lgorissen/myfirstweblogic 6506b88dc7cc166df55c470e4e7f9732cfb55353c8a1a84d8048c7689c886a7c developer@developer-VirtualBox:~$ docker container ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6506b88dc7cc lgorissen/myfirstweblogic "startWebLogic.sh" Less than a second ago Up 21 seconds 5556/tcp, 7002/tcp, 8453/tcp, 10.0.0.5:7001->7001/tcp swarm-agent-595FAAF3000001/competent_allen fd4c32b1fd19 yeasy/simple-web "/bin/sh -c 'pytho..." 8 minutes ago Up 8 minutes 10.0.0.5:80->80/tcp swarm-agent-595FAAF3000001/pensive_pike developer@developer-VirtualBox:~$
- Add a LoadBalancer rule for forwarding port 7001
In this set-up, the Agent machine can’t be reached over port 7001. A route in the LoadBalancer that routes traffic for this port has to be created. Creating that LoadBalancer route can be done in the Azure Portal. First, look up the resource groups in the portal:
Open the weblogic-demo resource group by clicking on it:
Click on the Load balancer for the agent (remember, out WebLogic container is running on the agent virtual machine). That brings up the Load balancer screen:
Click on the Add sign to add a new load balancer rule for port 7001:
Enter front-end, back-end and port numbers to establish the new route and save it.
- Test
Again look into the resource groups in the Azure Portal to find the public dns name for the agents:
From the figure above, we see that the url to use for accessing the WebLogic container is: http://lgoagents.northeurope.cloudapp.azure.com:7001/
Nifty :-S
Its great post to perform on Docker, WebLogic Image on Microsoft Azure Container Service with useful screenshots your post made it easy. It inspire me to do more in my WebLogic course thank you.