Error when running Nodejs docker in AWS ECS Fargate

We are trying to deploy a NodeJS Docker in AWS Fargate using ECS. Code is configured to come through GitHub -> CodeBuild -> ECR -> ECS Fargate.

We are facing standard_init_linux.go:219: exec user process caused: exec format error when we run the ECS Service. When we run the image in local, it is running without an issue. When we searched regarding this error, it was mentioned that it is due to architecture mismatch.


FROM node:14 as builder

COPY . /contents
WORKDIR /contents

RUN npm install

RUN npm run build



The CodeBuild architecture we tried are

  1. AL2 aarch64 1.0/2.0
  2. AL2 x86-64 2.0/3.0
  3. Ubuntu 3.0/4.0/5.0

What is the right environment for node 14 for CodeBuild? Is there anything else that might be causing the issue?

Any help is appreciated. Thanks!

Answers 1

  • As you pointed out this problem is typically caused by an architecture mismatch. Fargate does NOT support (yet) Graviton/Arm architectures and it always expects an x86-64 based image. Because Codebuild supports multiple architecture it is likely that that is where the mismatch is occurring. Do NOT use AL2 aarch64 1.0/2.0 with CodeBuild because that option will provision a Graviton/Arm environment to build and hence the resulting image would NOT work on Fargate. The other two should generate an image that is compatible with Fargate.

    The litmus test (to be sure this is due to an architecture mismatch) would be to provision a small Graviton based instance on the fly and test the SAME container image that is failing on Fargate with that error message. If it works with Graviton that is the problem.

Related Articles