Docker Compose is excellent for describing a local application, but it quietly inherits a developer machine’s network, filesystem, credentials, and lifecycle. Moving to Amazon ECS means those assumptions must become explicit infrastructure decisions.
Map services to deployment units
An ECS task definition describes one deployable unit. Containers that must share a lifecycle—such as an application and a tightly coupled telemetry sidecar—can live in one task. A database usually should not. Managed services such as RDS and ElastiCache have durability and operational models that are different from an application task.
Choose Fargate when you want AWS to manage the container hosts and the workload fits its model. EC2 capacity can make sense for specialized hardware, daemon workloads, or cost optimization at sustained scale. The application image should work in either case.
Networking becomes part of application design
In awsvpc mode, tasks receive network interfaces and security groups. Put application tasks in private subnets, expose them through an Application Load Balancer when HTTP ingress is needed, and allow only the required traffic between security groups.
Health checks have two layers. The container health check answers whether the process is internally healthy. The load balancer target check answers whether the service should receive traffic. A shallow /health endpoint can keep a broken instance in rotation; a check that depends on every external system can cause a regional dependency failure to restart the whole fleet. Define readiness deliberately.
Give the task an identity
Use an ECS task role for AWS API access instead of distributing access keys. The execution role is for ECS operations such as pulling an image or sending logs; the task role is what application code assumes. Keeping them separate makes least privilege much clearer.
Deploy with rollback signals
A rolling deployment needs enough healthy capacity to overlap old and new tasks. Configure graceful shutdown so draining targets stop receiving requests before the process exits. ECS deployment circuit breakers and CloudWatch alarms can stop or roll back a release that never stabilizes.