[AWS] Step-by-Step Hands On: Hosting Nginx on AWS ECS

In this hands-on tutorial, I’ll walk you through deploying an Nginx web server on AWS ECS. You’ll learn how to create a Docker image, push it to Amazon ECR, and set up ECS to host your application. By the end, you’ll have a basic understanding of how to run and manage containers in the cloud with ECS.

A task is a running container within a service inside an ECS cluster.

Let’s create an ECS cluster.

With only the cluster it doesn’t do much anything. We need to give it service and tasks.

We will use NGINX from Amazon ECR public gallery.

The service later will grab that container and then run task. User will be able to hit public IP of the container on that task and see the web page.

The next thing to do is to create a task definition.

Let’s look up to the gallery.ecr.aws and search the nginx. Choose this one, copy the container name:

Put this into the task definition container:

Infrastructure requirements:

Now we will deploy a new service on this cluster.

Hook the service with the task definition that we have just created:

We need to do some update on the networking:

Security Group on service level should be enable inbound traffic from port 80. Create a new security group.

Push Create the service button.

The service will run.

The task will also running:

Go to the tasks and find the public IP.

Copy the public IP and open it on your browser. We will see this nginx page, telling us that we have managed to host nginx on ECS.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.