AWS ECS container exited with exit code 1

Working with containers in production can be hectic at times, however, having good observability into the system will prove beneficial.

AWS ECS is a container service with largely two types (1) Fargate (like serverless) & (2) EC2 – which run containers on EC2 instances.

Alright, let’s move on…
So, to get more visibility into the ECS, you will have to add ‘awslogs’ to the logs group option when creating or updating an ECS service.

After this you can check the status of deployment in the deployment section of ECS – if the containers are running, exited or failed to start.

If faced with this error: container exited with exit code 1 and then further digging into the logs you might find this: (exec bin/sh: format error), given this situation there is a problem not with the containers but with the instances that are hosting them – most probably.

Upon further investigation it was found the architecture or the AMI of the container instance were not willing to host containers with (arm architecture), hence, the instances were modified to (x86) AMI and viola the error was gone.

Bonus tip!
Use ECS optimized AMI for container instances.


Posted

in

by

Tags: