Create Service

Create service

In this section, we will create a service to run our containerized application on the ECS cluster.

In order to pull image from ECR, we have to add Outbound rule for our private subnet.

Container

  1. Go back to Cluster tab, choose our cluster docker-container-ecs Container
  2. In service tab, choose Create button Container
  • Compute options: Launch type
  • Launch type: FARGATE Container
  • Application type: Service
  • Family: our newly created task definition docker-container-task
  • Revision: your latest revision
  • Service name: docker-service-01 Container
  • VPC: my-workshop-01
  • Subnets: our private subnets
  • Choose Use an existing security group and choose alb-sg-01
  • Turn off public IP to secure our service Container
  • Load balancer type: Application Load Balancer
  • Container: choose container-01 8000:8000
  • Choose Use an existing load balancer and choose workshop-alb-01 Container
  • Choose Use an existing listener and choose 80:HTTP Container
  • Choose Create new target group
  • Target group name: single-service-01
  • Protocol: HTTP
  • Path pattern: /todos to route all traffic to our root path
  • Evaluation order: 1
  • Health check path: /todos
  • Choose Create button Container
  1. After a few minutes, our service will be up and running.
  • Click on the service name to see the details Container Container
  • Click View load balancer to see the details of the load balancer
  • Copy DNS name and paste it to the browser with the path /todos to see the result Container Container