
Hello Readers! In this blog let’s see how to deploy and run your docker container in AWS Elastic Container service in AWS using the launch type EC2 instances.
What is ECS ?
Amazon Elastic Container Service (ECS) is a managed service to run containers typically using docker. first you have to need to know, What is Docker? So, Docker is a essentially a tool that exists that allows developers to launch containers and ensure that container instances are isolated from one another.
So, ECS kind of sits on top of Docker, so it allows you to launch setup and monitor your docker container on your ECS Cluster.
Firstly let’s see in short why we use Elastic Container Service?
Amazon Elastic Container Service is a scalable, high-performance container orchestration service that helps Docker containers and It’s allows you to easily run and scale containerised applications on AWS Instance.
So, Let’s get started!
Step 1: Firstly you must have logged into your AWS Management Console before starting. So, Create your AWS account if you don’t have one. After that Login to your AWS account and Click on Services menu > Choose Elastic Container Service.



Step 2: So, the first things to do is Click on the Clusters > Create Clusters



Step 3:Now, we will select EC2 Linux+Networking and click on Next Step.



Step 4: We will create cluster and give it a name let’s call it ecs-ec2-Demo, and Provisioning model let’s leave that as Default and after that ec2 instance type we will select t2.micro and number of instances let’s just start with one instances, EC2 AMI ID is Amazon Linux 2 AMI [ami-0c9b05548eb9b4603]
and at last we will create ssh key pair using key pair select one or you can use default key pair.
Step 5: Networking
you can create new VPC or if you want to use existing VPC, so let’s create a new VPC with two subnets if you want to use more subnets you can additional subnets and Security group is a Create a new security group and at last Security group inbound rules will be default port number 80, if you want to customize it you can customize it here.
Step 6: Container instance IAM role
It will create an IAM role for us so, let’s leave all option as default and at last click on Create icon.



Step 7: So, now its creating the cluster for us using the cloud formation stack and once its done we should able to see that it will create the vpc, couple of subnets, security group, internet gateway, route table, amazon ec2, launch configuration and so many things.



Step 8: We will create Task so, let’s go on Task Definition, Create a new task definition using ec2 and we will click on next step.



Step 9: Task definitions name is ecs-task, Task role and Network mode is totally optional let’s leave that as default task, Task Memory so how much memory we want for each of the container instance so , I will choose 50 MB just running an Nginx container and Task CPU will be 0.25vCPU.
Step 9: So,now let’s create the container Definition.



click on add button if you want to add the additional setting you can add here and after that it will create task definition for us.
Step 10: Now we will create a service,



Step 11:Launch type is ec2, cluster we have 1 cluster which name ecs-ec2-demo so select the cluster service name is ecs-service, you can select replicas or deamonset depending upon your number of instances and at last deployments and task placement we can leave as default and click on next step and we don’t need to create the load balancer because we have only one task so let’s leave everything is default and click on next step.
Auto scaling is totally optional you can leave that as Default and click on next step and click on create service, your service is created you can view your service clicking on view button.



Congrats! 👏 You have deploy and run your docker container in AWS Elastic Container service using the launch type EC2 instances.



Conclusion
Therefore In this blog we learn how we can deploy and run your docker container in AWS Elastic Container service using the launch type EC2 instances and you can also change the customization as per your requirements.Thanks,If you find this blog helpful do share with your friends.
HAPPY LEARNING!
1 thought on “Amazon Elastic Container Service Using EC2 Instance6 min read”
Comments are closed.