Running Production Containers on AWS ECS
Getting a container running locally with Docker Docker — platform for building and running containers docker.com ↗
is the easy part. The challenge begins when you need that container to run reliably in production: auto-scaling under load, recovering from failures, and integrating with the rest of your AWS infrastructure.
ECS Amazon ECS — container orchestration service aws.amazon.com/ecs ↗
provides the orchestration layer that bridges the gap between a working Dockerfile and a production-grade deployment. Paired with Fargate, it removes the need to manage EC2 instances entirely, letting you focus on your application rather than your infrastructure.
The foundation of any ECS Amazon ECS — container orchestration service aws.amazon.com/ecs ↗
deployment is the networking layer. Your tasks run inside a
VPC Amazon VPC — isolated virtual network aws.amazon.com/vpc ↗
, and you need to think carefully about subnet placement. Public subnets for your load balancer, private subnets for your application containers, and isolated subnets for your
RDS Amazon RDS — managed relational databases aws.amazon.com/rds ↗
database instances. Security groups act as firewalls between these layers — your ECS tasks should only accept traffic from the ALB, and your database should only accept connections from the ECS tasks. This defense-in-depth approach means that even if one layer is compromised, the attacker cannot easily move laterally.
For serving web traffic, place an Application Load Balancer in front of your ECS service and configure CloudFront Amazon CloudFront — global content delivery network aws.amazon.com/cloudfront ↗
as a CDN layer on top. CloudFront handles TLS termination at the edge, caches static responses, and shields your ALB from DDoS traffic. The combination of CloudFront, ALB, and ECS gives you a robust request path: edge cache, load distribution, and container-level routing with health checks that automatically replace unhealthy tasks.
Database connectivity deserves special attention. Your RDS Amazon RDS — managed relational databases aws.amazon.com/rds ↗
instance should live in a private subnet with no public accessibility. ECS tasks connect to it via the private DNS name within the VPC. Use AWS Secrets Manager to inject database credentials into your containers at runtime — never bake credentials into your
Docker Docker — platform for building and running containers docker.com ↗
image. ECS supports native Secrets Manager integration through the task definition’s
secrets block, which pulls values directly into environment variables without your application code needing to know about Secrets Manager at all.
Deployment strategy matters more than people realize. ECS supports rolling deployments out of the box, but I recommend configuring a minimum healthy percent of 100 and a maximum percent of 200. This means ECS spins up a full set of new tasks before draining the old ones, giving you zero-downtime deployments. Combine this with a deployment circuit breaker that automatically rolls back if new tasks fail health checks, and you have a deployment pipeline that is both fast and safe. Monitor everything through CloudWatch Container Insights — it gives you CPU, memory, and network metrics per task without any instrumentation code.