python3.8 fails to build with --use-container
See original GitHub issueDescription:
While running the following command:
sam build --use-container
I receive the following error:
docker.errors.ImageNotFound: 404 Client Error: Not Found (“pull access denied for public.ecr.aws/sam/build-python3.8, repository does not exist or may require ‘docker login’: denied: Your authorization token has expired. Reauthenticate and try again.”)
Steps to reproduce:
- sam init
- Which template source would you like to use? 1 (AWS Quick Start Templates)
- What package type would you like to use? 1 (Zip)
- Which runtime would you like to use? 2 (python3.8)
- Project name [sam-app]: sam-app
- AWS quick start application templates: 2
- cd sam-app
- sam build --use-container
Observed result:
2021-05-25 12:06:54,399 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2021-05-25 12:06:54,399 | Using config file: samconfig.toml, config environment: default
2021-05-25 12:06:54,400 | Expand command line arguments to:
2021-05-25 12:06:54,400 | --template_file=/Users/joris.conijn/workspace/sam-app/template.yaml --use_container --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache
2021-05-25 12:06:54,500 | 'build' command is called
2021-05-25 12:06:54,500 | Starting Build inside a container
2021-05-25 12:06:54,504 | No Parameters detected in the template
2021-05-25 12:06:54,532 | 1 stacks found in the template
2021-05-25 12:06:54,532 | No Parameters detected in the template
2021-05-25 12:06:54,572 | 1 resources found in the stack
2021-05-25 12:06:54,572 | No Parameters detected in the template
2021-05-25 12:06:54,594 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world_function'
2021-05-25 12:06:54,594 | --base-dir is not presented, adjusting uri hello_world_function relative to /Users/joris.conijn/workspace/sam-app/template.yaml
2021-05-25 12:06:54,594 | No Parameters detected in the template
2021-05-25 12:06:54,619 | Instantiating build definitions
2021-05-25 12:06:54,622 | Same function build definition found, adding function (Previous: BuildDefinition(python3.8, /Users/joris.conijn/workspace/sam-app/hello_world_function, Zip, , d9768cf4-a787-4e8d-8074-1839354bb129, {}, {}, []), Current: BuildDefinition(python3.8, /Users/joris.conijn/workspace/sam-app/hello_world_function, Zip, , 83602825-f669-4c5b-b413-cd8e7ca9a6e9, {}, {}, []), Function: Function(name='HelloWorldFunction', functionname='HelloWorldFunction', runtime='python3.8', memory=None, timeout=3, handler='hello_world/app.lambda_handler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='/Users/joris.conijn/workspace/sam-app/hello_world_function', environment=None, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'CloudWatchEvent', 'Properties': {'Pattern': {'source': ['aws.ec2'], 'detail-type': ['EC2 Instance State-change Notification']}}}}, metadata=None, inlinecode=None, codesign_config_arn=None, stack_path=''))
2021-05-25 12:06:54,626 | Building codeuri: /Users/joris.conijn/workspace/sam-app/hello_world_function runtime: python3.8 metadata: {} functions: ['HelloWorldFunction']
2021-05-25 12:06:54,626 | Building to following folder /Users/joris.conijn/workspace/sam-app/.aws-sam/build/HelloWorldFunction
2021-05-25 12:06:56,286 | Failed to download image with name public.ecr.aws/sam/build-python3.8:latest
2021-05-25 12:06:56,286 | Container was not created. Skipping deletion
2021-05-25 12:06:56,287 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '1c6d04f6-6875-44b7-9d12-be25b1dd8adc', 'installationId': 'e741b3c2-9523-4a05-821d-de8ee1f419de', 'sessionId': 'ce436781-e976-4923-8591-2359d5509839', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.8.10', 'samcliVersion': '1.23.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 1886, 'exitReason': 'DockerImagePullFailedException', 'exitCode': 255}}]}
2021-05-25 12:06:56,938 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Traceback (most recent call last):
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/docker/api/client.py", line 261, in _raise_for_status
response.raise_for_status()
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/requests/models.py", line 941, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.35/images/create?tag=latest&fromImage=public.ecr.aws%2Fsam%2Fbuild-python3.8%3Alatest
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/local/docker/manager.py", line 160, in pull_image
result_itr = self.docker_client.api.pull(image_name, tag=tag, stream=True, decode=True)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/docker/api/image.py", line 415, in pull
self._raise_for_status(response)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/docker/api/client.py", line 263, in _raise_for_status
raise create_api_error_from_http_exception(e)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.ImageNotFound: 404 Client Error: Not Found ("pull access denied for public.ecr.aws/sam/build-python3.8, repository does not exist or may require 'docker login': denied: Your authorization token has expired. Reauthenticate and try again.")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/local/docker/manager.py", line 85, in create
self.pull_image(image_name)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/local/docker/manager.py", line 163, in pull_image
raise DockerImagePullFailedException(str(ex)) from ex
samcli.local.docker.manager.DockerImagePullFailedException: 404 Client Error: Not Found ("pull access denied for public.ecr.aws/sam/build-python3.8, repository does not exist or may require 'docker login': denied: Your authorization token has expired. Reauthenticate and try again.")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/sam", line 8, in <module>
sys.exit(cli())
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 153, in wrapped
raise exception # pylint: disable=raising-bad-type
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 122, in wrapped
return_value = func(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/lib/utils/version_checker.py", line 42, in wrapped
actual_result = func(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/cli/main.py", line 90, in wrapper
return func(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/commands/build/command.py", line 210, in cli
do_cli(
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/commands/build/command.py", line 315, in do_cli
artifacts = builder.build()
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/lib/build/app_builder.py", line 169, in build
return build_strategy.build()
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/lib/build/build_strategy.py", line 41, in build
result.update(self._build_functions(self._build_graph))
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/lib/build/build_strategy.py", line 52, in _build_functions
function_build_results.update(self.build_single_function_definition(build_definition))
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/lib/build/build_strategy.py", line 118, in build_single_function_definition
result = self._build_function(
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/lib/build/app_builder.py", line 530, in _build_function
return self._build_function_on_container(
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/lib/build/app_builder.py", line 655, in _build_function_on_container
self._container_manager.run(container)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/local/docker/manager.py", line 115, in run
self.create(container)
File "/usr/local/Cellar/aws-sam-cli/1.23.0/libexec/lib/python3.8/site-packages/samcli/local/docker/manager.py", line 88, in create
raise DockerImagePullFailedException(
samcli.local.docker.manager.DockerImagePullFailedException: Could not find public.ecr.aws/sam/build-python3.8:latest image locally and failed to pull it from docker.
Expected result:
Should have build the Lambda function
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Mac OS X 11.3.1
sam --version
: SAM CLI, version 1.23.0- AWS region: N/A
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
sam build --use-container fails with Error: PythonPipBuilder ...
I am trying to build a Python Lambda function for the arm64 architecture on an AWS Cloud9 instance with SAM CLI, version 1.33.0....
Read more >Docker - Could not find python3 image locally and failed to ...
In my AWS SAM build-and-package step, the docker container fails to pull an image of python3.9. This issue suddenly started happening, and was ......
Read more >SAM Build only completes successfully with --use-container ...
I was able to fix it by upgrading pip : /Users/xyz/.pyenv/versions/3.8.8/bin/python3.8 -m pip install --upgrade pip.
Read more >Building applications - Amazon Serverless Application Model
... using the Python 3.8 container image pulled from DockerHub sam build --use-container --build-image Function1=amazon/aws-sam-cli-build-image-python3.8.
Read more >sam build - AWS Serverless Application Model
Build an AWS SAM application using the sam build command from the AWS SAM CLI. ... --use-container --build-image amazon/aws-sam-cli-build-image-python3.8 .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll close this for now since it seems resolved. Feel free to ping if you have any other issues!
Good find!
For future authentication, you might to give this a try (assuming you want the additional authenticated quota):
If you have your AWS credentials set up, it should login with ECR.