ECS task stops with exec format error on start
exec /usr/local/bin/docker-entrypoint.sh: exec format errorShort answer
The container's binary was built for another CPU than the task runs on. Match them: either set the task definition's cpuArchitecture to what the image was built for, or rebuild the image for that platform with docker buildx --platform and push it again.
Fix it fast
1Find out which cause you have
Read the CPU architecture in the task definition JSON. It is X86_64 or ARM64.
grep -n -B1 -A2 "cpuArchitecture" taskdef.json2Match what you see, then jump to its fix
What does the error look like?
exec /usr/local/bin/docker-entrypoint.sh: exec format error
Cause 1 of 2
The task definition and the image disagree
1Check
The task definition's cpuArchitecture takes X86_64 or ARM64.
grep -n -A3 "runtimePlatform" taskdef.json2Fix
Set the value to the architecture your image was built for, register a new revision and update the service.
"runtimePlatform": {
"cpuArchitecture": "ARM64",
"operatingSystemFamily": "LINUX"
}3Verify
The new task reaches RUNNING and its log shows the app starting.
grep -n "cpuArchitecture" taskdef.jsonConfirmed by docs.aws.amazon.com
Cause 2 of 2
Image built on a different architecture than you target
1Check
Docker builds for the host architecture by default. Docker's documentation shows building explicitly for linux/amd64 or linux/arm64.
uname -m2Fix
Build for the platform the task uses and push that image.
docker buildx build --platform linux/amd64 -t my-app .3Verify
Run the task again with the new image tag.
docker buildx build --platform linux/amd64 -t my-app .Confirmed by docs.docker.com
How do I stop it coming back?
- Pass --platform explicitly in your CI build.
- Keep the architecture in the task definition in version control.
- Build a multi-platform image if you run both kinds of task.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Servers
A container starts and stops at once with exec format error
exec /usr/bin/sh: exec format error
The kernel was asked to run a file it cannot execute.
4 causes, each with a fixBack end
Node.js in Docker Compose cannot reach MySQL on 127.0.0.1:3306
Error: connect ECONNREFUSED 127.0.0.1:3306
Inside a container, 127.0.0.1 is that container, not MySQL.
3 causes, each with a fixBack end
A Docker build or container says npm: not found
npm: command not found
A container only has the programs its image holds.
3 causes, each with a fixBack end
Kong Gateway returns 502 'An invalid response was received from the upstream server'
upstream sent too big header while reading response header from upstream
Kong returns 502 when it cannot get a valid HTTP response from the upstream.
4 causes, each with a fixBack end
Node.js cannot connect to MongoDB: ECONNREFUSED on port 27017
MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
ECONNREFUSED means nothing accepted the connection at that address and port.
4 causes, each with a fixBack end
NestJS watch mode does not restart after I save a file
Changes show on the host but not in the running container
Watch mode only sees files that exist inside the process that runs it.
3 causes, each with a fix