It was 11 PM on a Tuesday. I had a fresh container image in ECR, a shiny ECS task definition, and the kind of dangerous confidence that only comes from watching three YouTube tutorials back‑to‑back.
I clicked Run Task and sat back.
Thirty seconds later, the task stopped. Status: STOPPED . Exit code: 1 .
No problem, I thought. I’ll just check the logs.
CloudWatch showed my Flask app starting up, connecting to the database, and cheerfully logging: “Server running on port 5000.” Then — absolutely nothing. No crash. No stack trace. Just a wall of digital silence.
I spent the next three hours rewriting the Dockerfile, stripping dependencies, even changing the entrypoint to echo "hello" . Same result every time. The container would start, breathe for 30 seconds, then quietly bow out.
That’s when I noticed the Stopped Reason column in the ECS console:
“Essential container in task exited”
Brilliant. Thanks, AWS. Very helpful.
The Buried Clue
Around hour four, frustration drove me into CloudTrail. I filtered for RunTask events and clicked into the raw response. And there, buried under a mountain of JSON, was the real failure reason:
“ECS was unable to start the task because the network configuration was invalid. The subnet ID provided does not exist in the specified VPC.”
Wait — what?
I opened my task definition and re‑checked the subnet I’d picked. It was valid… but it belonged to a different VPC than my ECR repository. My container was trying to pull the image from ECR, but that subnet had no internet gateway and no VPC endpoint for ECR. So ECS gave it 30 seconds to initialise, killed it, and never bothered to surface the real error in CloudWatch.
My application logs were happy because the application started. But the infrastructure was already dead.
The Fix
I added a VPC endpoint for ECR in my private subnet (costs about ₹5/month), updated the task definition, and redeployed.
Boom. The task stayed alive.
No more silent deaths. No more midnight meltdowns.
The Tiny Habit That Saves Me Now
Whenever a container dies without a proper log message, I now run this mental checklist before touching a single line of code:
- Check the Stopped Reason in the ECS console – sometimes it holds a better clue than CloudWatch.
- Dig into CloudTrail for the
RunTask event – the real failure often lives there.
- Verify the VPC networking – does the subnet have internet access or the right VPC endpoints for ECR, S3, and CloudWatch?
If your logs are empty, the bug isn’t in your code. It’s in the invisible layer between your container and AWS.
P.S. – Next time you see “Essential container exited”, skip the Docker rabbit hole. Go straight to your VPC. I burned six hours so you don’t have to.
Loading article