Elastic Container Service Simple Demo

This runs on top of Amazon Elastic Compute Cloud (Amazon EC2) and the steps below follow the AWS GUI (graphical user interface). I learnt most of the content below by following Arthur Ulfeldt‘s tutorial Deploying Docker to AWS.

This demo will simply write the current datetime to a volume using the busybox image, the container is called data-source. Another container running nginx will then display this data, this container is called data-server.

Simple Demo Infrastructure Overview

Calling data-server on its public IP will then display as follows:

nginx data-server

Setup

Create your account at https://aws.amazon.com/ login and under AWS Management Console type or look for ECS, this will take you to the ECS Dashboard

Cluster

Create cluster type of launch type FARGATE, it may be called something like Networking only and mention Powered by AWS Fagate - things in IT change daily :)

  • Cluster name: simple-demo2
  • Check Create VPC
  • Tag: Description|simple-demo2 (this is the key|value)
  • Check Enable container insights for CloudWatch
  • From the CLI you can view all clusters:

Task Definition

Select Task Definitions -> Create new Task Definition

  • Select the FARGATE template
  • Task Definition Name: task-definition-data-server
  • Requires Compatibilities: FARGATE
  • Task Role: escTaskExecutionRole
  • Network Mode: awsvpc
  • Task execution role: ecsTaskExecutionRole
  • Task memory (GB): 0.5GB
  • Task CPU (vCPU): 0.25 vCPU

Volumes:

  • create one called shared-data

CONTAINER 1

  • Container name: data-source
  • Image: busybox
  • Memory Limits (MiB): 128
  • Entry point: sh, -c, while true; do echo $(date) > /shared-data/index.html; sleep 5; done
  • Mount points: select source volume, and set the path /shared-data to match the shell script
  • Log configuration: check Auto-configure CloudWatch Logs

CONTAINER 2

  • Container name: data-server
  • Image: nginx
  • Memory Limits (MiB): 128
  • Port mappings: 0 -> 80
  • Mount points: select source volume, and set the path /usr/share/nginx/html

Run Task

Now manually run the above task definition from Tasks tab, Run new Task.

Once it starts up select the running task, copy its Public IP into a browsers and you should see the current time update every 5 seconds. Per the image above this IP was 3.104.47.134

References