aws-sam-cli: sam local invoke throws "Error: Error building docker image"
Description:
We are encountering below error while locally invoking a lambda in AWS code build machine
Image was not found. 842 | Building image… 843 | Failed to build Docker Image 844 | NoneType: None 845 | Exception on /2015-03-31/functions/FunctionName/invocations [POST] 846 | Traceback (most recent call last): 847 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/flask/app.py”, line 2447, in wsgi_app 848 | response = self.full_dispatch_request() 849 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/flask/app.py”, line 1952, in full_dispatch_request 850 | rv = self.handle_user_exception(e) 851 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/flask/app.py”, line 1821, in handle_user_exception 852 | reraise(exc_type, exc_value, tb) 853 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/flask/_compat.py”, line 39, in reraise 854 | raise value 855 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/flask/app.py”, line 1950, in full_dispatch_request 856 | rv = self.dispatch_request() 857 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/flask/app.py”, line 1936, in dispatch_request 858 | return self.view_functionsrule.endpoint 859 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/samcli/local/lambda_service/local_lambda_invoke_service.py”, line 151, in _invoke_request_handler 860 | self.lambda_runner.invoke(function_name, request_data, stdout=stdout_stream_writer, stderr=self.stderr) 861 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/samcli/commands/local/lib/local_lambda.py”, line 130, in invoke 862 | self.local_runtime.invoke( 863 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py”, line 217, in wrapped_func 864 | return_value = func(*args, **kwargs) 865 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/samcli/local/lambdafn/runtime.py”, line 176, in invoke 866 | container = self.create(function_config, debug_context, container_host, container_host_interface) 867 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/samcli/local/lambdafn/runtime.py”, line 73, in create 868 | container = LambdaContainer( 869 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/samcli/local/docker/lambda_container.py”, line 87, in init 870 | image = LambdaContainer._get_image(lambda_image, runtime, packagetype, imageuri, layers) 871 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/samcli/local/docker/lambda_container.py”, line 213, in _get_image 872 | return lambda_image.build(runtime, packagetype, image, layers) 873 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/samcli/local/docker/lambda_image.py”, line 144, in build 874 | self._build_image(image if image else image_name, image_tag, downloaded_layers, stream=stream_writer) 875 | File “/root/.pyenv/versions/3.8.10/lib/python3.8/site-packages/samcli/local/docker/lambda_image.py”, line 245, in _build_image 876 | raise ImageBuildException(“Error building docker image: {}”.format(log[“error”])) 877 | samcli.commands.local.cli_common.user_exceptions.ImageBuildException: Error building docker image: The command ‘/bin/sh -c chmod +x /var/rapid/aws-lambda-rie’ returned a non-zero code: 1
Build machine specs:
AWS CodeBuild - Linux env SAM CLI --version: 1.27.2 AWS region: us-east-1
Steps to reproduce:
Observed result:
Expected result:
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS:
sam --version
:- AWS region:
Add --debug flag to command you are running
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 17 (13 by maintainers)
It does appear isolated to only CodeBuild. Or at least it’s running fine locally on my Mac machine.
We have not yet started explicitly definiting an Architecture in our Lambda function, so it’s defaulting to
x86_64
Architecture.Local Logs:
We are facing same issue while invoking a lambda in AWS code build machine-
SAM CLI, version 1.27.2 AWS region: us-east-1 AWS CodeBuild - Linux env