Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

ECS task stops with exec format error on start

Errorexec /usr/local/bin/docker-entrypoint.sh: exec format error

Short 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.

  • Applies to Amazon ECS on Fargate, Docker Buildx, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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.json
  2. 2Match what you see, then jump to its fix

    1. 1The first line of the container log is the exec format error, and the task stops at onceThe task definition and the image disagreeFix
    2. 2The image was built on an Apple Silicon Mac or an ARM runner, and the task is X86_64Image built on a different architecture than you targetFix

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.json

2Fix

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.json

Confirmed by docs.aws.amazon.com

Did this fix it?

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 -m

2Fix

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

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.