Docker, WebLogic Image on Amazon EC2 Container Service 5.0 Feature overview

Docker, WebLogic Image on Amazon EC2 Container Service

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.

Docker, WebLogic Image on Amazon EC2 Container Service 5.1 AWS console

Click on EC2 Container Service

Docker, WebLogic Image on Amazon EC2 Container Service 5.2 AWS console get started

Click on Get started

Docker, WebLogic Image on Amazon EC2 Container Service 5.3 AWS wizard no repository

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.

Docker, WebLogic Image on Amazon EC2 Container Service 5.4 AWS wizard step 1

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.

Docker, WebLogic Image on Amazon EC2 Container Service 5.5 AWS wizard step 2

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.

Docker, WebLogic Image on Amazon EC2 Container Service 5.6 AWS wizard step 3

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’:

Docker, WebLogic Image on Amazon EC2 Container Service 5.7 AWS wizard step 3 create key pair

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’:

Docker, WebLogic Image on Amazon EC2 Container Service 5.8 AWS wizard step 3 select key pair

Click Review & launch:

Docker, WebLogic Image on Amazon EC2 Container Service 5.9 AWS wizard step 4 review

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:

Docker, WebLogic Image on Amazon EC2 Container Service 5.10 AWS ECS creation

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

Docker, WebLogic Image on Amazon EC2 Container Service 5.11 AWS ECS creation finished

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:

Docker, WebLogic Image on Amazon EC2 Container Service 5.12 AWS ECS cluster status

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:

Docker, WebLogic Image on Amazon EC2 Container Service 5.13 AWS ECS cluster task cause

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:

Docker, WebLogic Image on Amazon EC2 Container Service 5.14 AWS ECS cluster ip address

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:

Docker, WebLogic Image on Amazon EC2 Container Service 5.15 AWS MobaXterm

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

Docker, WebLogic Image on Amazon EC2 Container Service 5.16 AWS MobaXterm session

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:

Docker, WebLogic Image on Amazon EC2 Container Service 5.17 AWS ECS cluster task running

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

Docker, WebLogic Image on Amazon EC2 Container Service 5.17 AWS ECS WebLogic 1

And after logging in, check for the developer_domain:

Docker, WebLogic Image on Amazon EC2 Container Service 5.19 AWS ECS WebLogic 2

 

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