Day 60: Deploying a container with Amazon ECS

Vishesh GhuleVishesh Ghule
3 min read

🚀 Introduction

Amazon Elastic Container Service (ECS) is a great tool for putting your containerized applications into action. Think of it as a handy manager for your Docker containers, making deployment easy. ECS takes away the hassle of dealing with the nitty-gritty details of container management. What sets ECS apart is its compatibility with other AWS services like Amazon EC2, AWS Fargate, and Elastic Load Balancing, creating a smooth and comprehensive container management system. It lets developers and admins easily deploy, scale, and keep an eye on applications without getting bogged down by manual tasks. ECS’s knack for balancing workloads, optimizing resources, and automating chores makes it a top pick for those looking for a user-friendly and efficient container orchestration platform. In this blog, we’ll walk through the straightforward process of deploying containers with ECS, uncovering the features that make it a go-to for hassle-free application deployment.


🔸Create Cluster

  1. On the ECS dashboard, click on Create cluster

Zoom image will be displayed

  1. Under the Cluster configuration, enter the Cluster name

3. For the infrastructure, choose AWS Fargate (serverless). In the event you wish to create your own EC2s for the project, select Amazon EC2 instances and proceed.

4. Scroll down and click on Create

5. After a few seconds, the cluster is created.


🔸Create Task Defination

  1. On the left navigation plane, click on Task definitions and click on Create new task definition then select Create new task definition

2. Give the task definition a family name and under the Launch type, select AWS Fargate.

3. Under the container details, give the container a name and the repository url (eg the url to a public docker image on dockerhub).

4. Set the container port to 5000 since our app runs on port 5000

5. Leave the rest as default scroll down to the bottom and click on Create


🔸Create Service

  • Now we need to create a service which creates the task in the task definition
  1. On the ECS console, click on Clusters then select the cluster you created

2. Under the Services tab, click on Create

3. Use the following configurations:

Compute options → Launch type

Launch type → FARGATE

Platform version → LATEST

  • Application type → Service

  • Select the Family of the task definition we created in the previous step

  • Give a Service name

  • Service type → Replica

  • Desired tasks → 2

  • Under Networking, create a new Security group and allow TCP traffic on port 5000

4. Scroll down and click on Create

5. Give it some time for the service to deploy successfully

6. Select the service you created

7. Move to the Tasks tab and click on one of the running tasks

8. Copy the ip address and paste it on a browser. Add the port number to the ip address. The app loads on the browser


🔸Clean up

  1. To delete the servive, select the service in the cluster console, then click on Delete service

2. Type delete to confirm deletion of the service

3. To delete the cluster, click on Delete cluster at the top of the Clusters console page

4. Deregister the task definition


🚀Conclusion

In summary, ECS handles the technical stuff, letting developers and admins focus on building and improving applications. As we’ve seen in this blog, ECS is a straightforward solution for managing containers, making it accessible for both experienced users and beginners. It provides a reliable and simple path to efficiently deploy and handle applications. ECS isn’t just a tool; it’s a helpful companion that simplifies the world of containers, giving teams the freedom to innovate and deliver applications more easily.


Thanks for reading to the end; I hope you gained some knowledge.❤️🙌

Linkedln

Twitter

Github

0
Subscribe to my newsletter

Read articles from Vishesh Ghule directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vishesh Ghule
Vishesh Ghule

I'm proficient in a variety of DevOps technologies, including AWS, Linux, Python, Docker, Git/Github, Shell Scripting, Jenkins and Computer Networking. My greatest strength is the ability to learn new things because I believe there is always room for self-development