Deploying Docker Containers in Amazon ECS using AWS Fargate

AWS Fargate lets you run containers without managing servers or clusters. This article is a guide to deploying a simple “Hello World!” Docker Container in Amazon ECS using Fargate. The container we’ll use is available here, built using this Dockerfile. We’ll create the following ECS Objects:

  • Container Definition specifies the Docker Image to use for the container, along with its port mappings, environment, network settings, resource limits, etc.
  • Task Definition is a blueprint for your application, & specifies which containers are included in your task, how they interact with each other & what resources they use. You can also specify data volumes for your containers to use.
  • Service lets you run & maintain a specified number (the “desired count”) of simultaneous instances of a task definition in a cluster.
  • Cluster is a regional grouping of one or more container instances on which you can run task requests.

We start at the ECS Console at https://console.aws.amazon.com/ecs.

Click Create Cluster:

Select the Fargate template & click Next:

Enter Cluster Name, select Create VPC & click Create:

View Cluster:

Select Task Definitions on the left:

Create New Task Definition:

Select Fargate & click Next:

Add Container, enter container Name & Image & click Add:

Enter Task Definition Name & Task Size & click Create:

View Task Definition:

Select Create Service from Actions drop-down:

Select Fargate, enter Service Name & Number of Tasks & click Next:

Select VPC & Subnet & click Next:

Click Next:

Create Service:

View Service:

Click Task ID to view its details:

Note the Public IP:

Allow incoming connections to port 5000 in the security group & open IP:5000 to see the result:

 

Harish KM is a Cloud Evangelist and a Full Stack Engineer at QloudX. Harish is very passionate about cloud native solutions and using the best tools for projects. This means that he is an expert in a multitude of application languages and is up to date with all the new offerings and services from cloud providers, especially AWS.

Leave a Reply

Your email address will not be published. Required fields are marked *