Amazon Elastic Container Service (Amazon ECS) is a fully managed container orchestration service. Customers such as Duolingo, Samsung, GE, and Cookpad use ECS to run their most sensitive and mission critical applications because of its security, reliability, and scalability.

In this lab we going to create a ECS Cluster using a Docker Image from our ECR we make on our last post and run a simple web service.



  • Create a Task Definition
  • Create a Key pair for the ECS cluster
  • Create the ECS Cluster
  • Create a Service with the Task Definition


  1. In AWS Management Console, go to Elastic Container Registry

2. Go to Repositories

3. Copy the URI and paste it in a save place to used later

4. Go to Elastic Container Service

5. Go to Task Definitions

6. Click on Create new Task Definition

In this step we can use Fargate and EC2 instances.

AWS Fargate is a serverless compute engine for containers that works with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). Fargate makes it easy for you to focus on building your applications. Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application, and improves security through application isolation by design.

For this lab we going to use EC2 for maintain the lab simple.

7. Select EC2 and Click Next Step

8. Give it a name

9. Go down until you see Container Definitions and click on Add container

10. Give the container a name, on Image pase the repository URI, On Hard limit put a limit of 512 and in ports use 80-80 to use HTP and click on Add

11. Go down and click on Create

12. Go to EC2

13. Go to Key Pairs

14. Click on Create key pair

15. Give it a name and click on Create key pair, and download.

16. Click on Clusters

17. Click on Create Cluster

18. Select EC2 Linux + Networking and click on Next step

19. Give it a name, in EC2 instance type select t2.micro, on Number of instances select 2

20. Select the Key pair we create for the cluster and click on Create

21. Wait until the cluster is create and click on View Cluster

22. On the Tab Services, click on Create

23. On Launch type select EC2, give it a service name, as Service type select Daemon, as Minimum Healthy percent put 50%, and click on Next step

24. Leave everything at defaults and click on Next step

25. Click on Next step

26. Review the configuration and click on Create Service

27. Click on View Service

Great your ECS Cluster is complete, you will see all the information in one place to monitor and check the health status of your services.


  1. Now for test that your service is running with your docker image go to EC2

2. Go to Instances

3. And test each Public IP address of the two instances the ECS cluster create

4. Test it on your browser and you will see the custom HTML message of the docker image


ECS is a great choice to run containers for several reasons. First, you can choose to run your ECS clusters using AWS Fargate, which is serverless compute for containers. Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application, and improves security through application isolation by design. Second, ECS is used extensively within Amazon to power services such as Amazon SageMaker, AWS Batch, Amazon Lex, and’s recommendation engine, ensuring ECS is tested extensively for security, reliability, and availability.


  1. Go to ECS

2. Select the cluster we create

3. Click on Delete Cluster

4. Confirm

5. Once the cluster is Deleted, go to Task Definitions

6. Click on Task Definition name we create for this lab

7. Select the Task Definition name, and click on Actions, Deregister

8. Confirm

5. Go to EC2

6. Click on Key pairs

7. Select the Key pair we use for the cluster, click on Actions and then Delete

8. Confirm

9. Delete the resources using the Clean-Up section on the AWS Elastic Container Registry (ECR) post