AWS Lambda Docker container runtime error: Runtime exited with error: exit status 127

While testing my Lambda using a Docker container, when the Lambda is invoked, I’m getting this runtime error:

Process 17(bootstrap) exited: Runtime exited with error: exit status 127

Process exit status code 127 errors are usually a file not found error. Going back through the Lambda logs, luckily there’s an error telling me I have an error in my shell script:

/var/task/test.sh: line 5: output: command not found

Quick and easy fix.

Debugging Docker container builds

When running a ‘docker build . -t imagename’ to build a new image, each of the steps in your Dockerfile outputs a one-line status, but if you need to see the actual output of each step, you need pass the –progress-plain option. If your build is stopping at a particular step and you need to see the output of previous steps that are now cached, you can use the –no-cache option:

docker build --progress=plain --no-cache . -t imagename

AWS Lambda Custom Runtime for executing arm64 binaries

I’m configuring an AWS Lambda with a custom runtime using the Serverless framework, and I’ve run into this error:

Architecture config by default on Lambda is showing x86_64::

If I trying to create with arm64 instead it gives:

An error occurred: HelloLambdaFunction - Resource handler returned message: "Runtime provided does not support the following architectures [arm64]. Please select different architectures from [x86_64] or select a different runtime

This is slightly obscure and it a result of the ‘provided’ runtime coming in 2 flavors, Amazon Linux 1 (provided) and Amazon Linux 2 (provided.al2), and only provided.al2 supports arm64.

If you change your serverless.yaml to include the provided.al2 runtime, then it deploys as expected.

This just means replacing this:

provider:
  name: aws
  runtime: provided

with:

provider:
  name: aws
  runtime: provided.al2

Note now how the runtime shows Amazon Linux 2 and arm64: