What is ECS?

awsElastic Container Service is Amazon platform for Docker containers. A cluster is a collection of ECS container instances, which in turn are EC2 instances running the Docker Engine along with an ECS agent that provides AWS resources for running containers. This article will describe the steps needed to make use of this service.


Create a cluster

Containers in AWS are always located in a cluster.

  1. Start by logging on with your IAM account, and assume the role of admin.
  2. Go to Services > Elastic Container Service.
    1. If this is your first visit, click the Get started button, and then click Cancel to get back to the ECS console.
  3. Click the Create cluster button.
  4. Select EC2 Linux + Networking.
  5. On the Configure cluster page enter the following details:
    1. Cluster name: test-cluster
    2. Provisioning Model: On-Demand Instance
    3. EC2 instance type: t2.micro (free for first 12 months)
    4. Number of instances: 1
    5. EC2 Ami Id: Amazon Linux 2 AMI
    6. EBS storage (GiB): 22
    7. Key pair: admin (create a key pair called admin if you haven't already)
  6. Leave rest at default, and click the Create button. 

This will set up a cluster with one EC2 instance, for Docker with Linux, with internet access on port 80. Click View Cluster once the creation is complete. 

 

SSH access to your EC2 instance

There may be times when you need to access your ECS instance using SSH.

  1. Go to Services > EC2.
  2. Select Security Groups (left pane).
  3. Select your security group (e.g. EC2ContainerService-test-cluster-EcsSecurityGroup-xxxx.)
  4. Select the Inbound rules tab.
  5. Click the Edit inbound rules button.
  6. Click the Add rule button and add the following settings:
    1. Type: Custom TCP
    2. Port range: 22
    3. Source type: My IP
    4. Description: SSH access.
  7. Click Save rules.

SSH access is now enabled.

 

IP address of EC2 instance

Your EC2 instance has an IP address that you will need.

  1. Go to Services > EC2.
  2. Select Instances (left pane).
  3. Select your EC2 instance.

You can see its IP address if you scroll right, or look at the details pane below.

Using this IP addresss, you can open a Terminal and run the following command (create an EC2 key pair called admin, if you haven't already):

$ ssh -i ~/.ssh/admin.pem This email address is being protected from spambots. You need JavaScript enabled to view it.

Now that you have remote access to your ECS instance, you can run the following command to list docker containers, and you will see the ECS agent, running as a container.

$ docker ps

 

Docker

At this stage you have enough to start using Docker on AWS.

 

Thanks for visiting.