Docker, WebLogic Image on Amazon EC2 Container Service

0
Share this on .. Tweet about this on TwitterShare on LinkedIn10Share on Facebook2Share 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 running a WebLogic Docker Container image from the Docker Hub registry on the Amazon EC2 Container Service.

Starting point & Outline

Starting point for this blog is:

  • A computer with a browser and MobaXterm installed
  • A WebLogic Docker Container Image in a private Docker Hub repository, as described in this blog
  • Access to Amazon EC2

The Amazon ECS cloud service knows the following concepts:

  • Cluster: a Cluster is a set of EC2 instances (hosts) that are running the ECS container agent.
  • Task: a Task definition describes how to run Docker containers in Amazon ECS. It describes the Docker image to use, CPU and memory requirements. networking, port mapping, etc. Tasks run on a Cluster.
  • Service: a number of instances of a Task definition that runs simultaneously in a Cluster

The Microsoft Azure and the Oracle Public Cloud offerings both had a clear distinction between the creation of the Container platform, and running containers on it. When you start with Amazon ECS, that is all combined into 1 wizard, where the platform (Cluster) is created and the first container that is run on that platform (Task).

The cluster wizard uses an Amazon ECS-optimized AMI: the container agent is already installed. Making life easier 😉


 

Create an Amazon EC2 Container Service, ECS

Start by logging in into your AWS console. I picked region Oregon – as it seems to be the cheapest.

Click on EC2 Container Service

Click on Get started

Select the first option ‘Deploy a sample …’ and de-select the ‘Store container ….’ option. In our example, we don’t need a registry as we will use the WebLogic container image that we have in the Docker Hub registry.

The above figure shows step 1 of the wizard. On this page, the Task definition is created.

Note that the image name points to the image we stored in Docker Hub. And don’t forget to add the port mapping for port 7001! Then, click Next step.

In this step, the Service is configured by giving it a name and configuring how many Tasks have to be run under that Service. Since we want to keep things simple, we decide to run only 1 Task under this Service. So, also no Load Balancer needed. Click Next step.

Here, the Cluster has to be configured, i.e. the EC2 instances that the Containers will run on. Note to pick an EC2 instance type that is sufficient to run WebLogic on. I picked t2.large, which has 2 cores and 8 GB of RAM.

Also, we need a key pair for logging in into the EC2 instances. For generating a new key pair, click on the ‘EC2 conole’ link. That will bring you to a page for creating key pairs. I created a new one, named ‘aws-lgo-weblogic’:

Download the key and remember where you stored it: you will need it later on!

Now, move back to the wizard page, refresh the key pair input field and select the keypair ‘aws-lgo-weblogic’:

Click Review & launch:

Review the above page and when you’re OK with it, click ‘Launch instance & run service’. That will bring you to a page where the progress of the Cluster creation is shown:

When your Cluster creation has finished, the ‘View service’ button as shown below will become visible:

Click it! It will bring you to the Cluster overview page. Now, zoom in on the weblogic-cluster and go to the Tasks tab and then select the ‘Stopped’ tasks. The resulting page should look like shown below:

The page shows that something is going wrong in our Cluster: why are there so many Tasks? Why are they STOPPED? So, let’s drill in on one of the many stopped tasks by clicking a Task link:

This reveals what’s going on. The message ‘STOPPED (CannotPullContainerError: Error: image lgorissen/m)’ means that the WebLogic image can’t be accessed. Which makes sense, because in the whole configuration wizard, we have not entered the credentials for accessing the private Docker Hub registry!

We need to configure the EC2 instance so it can access the Docker Hub registry.

First, look up the ip address of the EC2 instance. Go to the Amazon console and select the ‘instances’ section:

Note the ip address.

Fire up MobaXterm, click ‘Start a new remote session’ and select session type ‘SSH’ and use the public IP number and the earlier downloaded SSH key:

Click OK to start the session, and login as  ec2-user : it should look like shown below:

In that terminal, we will edit the Amazon ECS container agent configuration file:


[ec2-user@ip-10-0-1-142 ~]$ sudo vi /etc/ecs/ecs.config

And add the two lines below (insert your appropriate username, password and e-mail!):


ECS_ENGINE_AUTH_TYPE=docker

ECS_ENGINE_AUTH_DATA={"https://index.docker.io/v1/":{"username":"lgorissen","password":"<your_password>","email":"l.gorissen@icloud.com"}}

Next, (1) ensure that the agent uses the ECS_DATADIR variable, (2) re-start the ecs agent and (3) verify that the agent is running:


[ec2-user@ip-10-0-1-142 ~]$ docker inspect ecs-agent | grep ECS_DATADIR

"ECS_DATADIR=/data",

[ec2-user@ip-10-0-1-142 ~]$ sudo stop ecs

ecs stop/waiting

[ec2-user@ip-10-0-1-142 ~]$ sudo start ecs

ecs start/running, process 3266

[ec2-user@ip-10-0-1-142 ~]$ curl http://localhost:51678/v1/metadata

{"Cluster":"weblogic-cluster","ContainerInstanceArn":"arn:aws:ecs:us-west-2:009784947762:container-instance/ff16c35d-9339-4522-a28e-a11e2e7a3268","Version":"Amazon ECS Agent - v1.14.1 (467c3d7)"}
[ec2-user@ip-10-0-1-142 ~]$

Back to the weblogic-cluster overview page, the cluster should now have a Task with status RUNNING:

Then point browser to the public IP address you also used in the MobaXterm SSH session: http://35.160.191.190:7001/console

And after logging in, check for the developer_domain:

 

Indeed, this must be from our Container image from Docker Hub!

 

Share this on .. Tweet about this on TwitterShare on LinkedIn10Share on Facebook2Share 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