Closed chostrander closed 1 year ago
Curiously, I'm not able to reproduce this behavior. I built the image with docker build . -t sam/custom-graal-image
and then used the commands you did.
However, when I purposefully introduced a typo in the image name, I see the error you are describing.
@sriram-mv - Strange.. when following the Example instructions I copied the instruction from the page by using the "copy" tag..
The "docker build . -t sam/custom-graal-image" ran fine for me too.
it was this command 'sam build --use-container --build-image sam/custom-graal-image' that is failing. I made sure the image was in my local docker repo by using the "docker images" and then I even modified the command to put the "latest" tag on it "sam build --use-container --build-image sam/custom-graal-image:latest" and still got same error.
Curious as I am on LinuxMint(flavor of Ubuntu) I am using: docker-desktop -> v4.23.0 docker -v output is "Docker version 24.0.6, build ed223bc"
will look at this more but it appears it may be a docker thing?
this is what my docker version environment output is: lient: Docker Engine - Community Cloud integration: v1.0.35+desktop.4 Version: 24.0.6 API version: 1.43 Go version: go1.20.7 Git commit: ed223bc Built: Mon Sep 4 12:31:40 2023 OS/Arch: linux/amd64 Context: desktop-linux
Server: Docker Desktop 4.23.0 (120376) Engine: Version: 24.0.6 API version: 1.43 (minimum version 1.12) Go version: go1.20.7 Git commit: 1a79695 Built: Mon Sep 4 12:32:16 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.22 GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca runc: Version: 1.1.8 GitCommit: v1.1.8-0-g82f18fe docker-init: Version: 0.19.0 GitCommit: de40ad0
ah the tag needs to match exactly you should'nt need to add the :latest
. However, I'm testing this on a mac, I have not tested it on linux like you mention. 🤔
@chostrander sounds like a docker issue IMO. I'm not able to repro it on mac or linux.
Patch is released in v1.99.0. Closing
Description:
using aws samples: https://github.com/aws-samples/aws-sam-cli-java-examples/tree/main/03-maven-graalvm-custom
I execute this command per the instructions: sam build --use-container --build-image sam/custom-graal-image
I get the following: `Starting Build inside a container
Building codeuri: /software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/HelloWorldFunction runtime: provided.al2 metadata: {'BuildMethod': 'makefile'} architecture: x86_64 functions:
HelloWorldFunctionGraalVM
Error: Could not find sam/custom-graal-image image locally and failed to pull it from docker. Traceback: File "click/core.py", line 1078, in main File "click/core.py", line 1688, in invoke File "click/core.py", line 1434, in invoke File "click/core.py", line 783, in invoke File "click/decorators.py", line 92, in new_func File "click/core.py", line 783, in invoke File "samcli/lib/telemetry/metric.py", line 184, in wrapped File "samcli/lib/telemetry/metric.py", line 149, in wrapped File "samcli/lib/utils/version_checker.py", line 42, in wrapped File "samcli/cli/main.py", line 95, in wrapper File "samcli/commands/build/command.py", line 170, in cli File "samcli/commands/build/command.py", line 266, in do_cli File "samcli/commands/build/build_context.py", line 281, in run File "samcli/lib/build/app_builder.py", line 217, in build File "samcli/lib/build/build_strategy.py", line 81, in build File "samcli/lib/build/build_strategy.py", line 91, in _build_functions File "samcli/lib/build/build_strategy.py", line 164, in build_single_function_definition File "samcli/lib/build/app_builder.py", line 697, in _build_function File "samcli/lib/build/app_builder.py", line 939, in _build_function_on_container File "samcli/local/docker/manager.py", line 115, in run File "samcli/local/docker/manager.py", line 88, in create
An unexpected error was encountered while executing "sam build". Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20build%20-%20DockerImagePullFailedException
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20DockerImagePullFailedException `
I do 'docker images' and it shows it is in my local repo
docker images REPOSITORY TAG IMAGE ID CREATED SIZE sam/custom-graal-image latest 52f6ed17eab6 15 minutes ago 2.88GB
Steps to reproduce:
I followed the steps here: https://github.com/aws-samples/aws-sam-cli-java-examples/blob/main/03-maven-graalvm-custom/README.md
Observed result:
`07:56:54 hoss@alienwarearea51-desktop 03-maven-graalvm-custom ±|main|→ sam build --use-container --build-image sam/custom-graal-image --debug 2023-10-02 19:58:11,873 | No config file found in this directory.
2023-10-02 19:58:11,877 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: '/software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/samconfig.toml'
2023-10-02 19:58:11,878 | Config file location: /software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/samconfig.toml
2023-10-02 19:58:11,879 | Config file '/software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/samconfig.toml' does not exist
2023-10-02 19:58:11,883 | Using SAM Template at /software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/template.yaml
2023-10-02 19:58:11,913 | Using config file: samconfig.toml, config environment: default
2023-10-02 19:58:11,914 | Expand command line arguments to:
2023-10-02 19:58:11,915 | --template_file=/software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/template.yaml --use_container --build_image=('sam/custom-graal-image',) --mount_with=READ
--build_dir=.aws-sam/build --cache_dir=.aws-sam/cache
2023-10-02 19:58:11,973 | 'build' command is called
2023-10-02 19:58:11,974 | Starting Build inside a container
2023-10-02 19:58:11,977 | No Parameters detected in the template
2023-10-02 19:58:11,996 | There is no customer defined id or cdk path defined for resource HelloWorldFunctionGraalVM, so we will use the resource logical id as the resource id
2023-10-02 19:58:11,998 | 0 stacks found in the template
2023-10-02 19:58:11,999 | No Parameters detected in the template
2023-10-02 19:58:12,014 | There is no customer defined id or cdk path defined for resource HelloWorldFunctionGraalVM, so we will use the resource logical id as the resource id
2023-10-02 19:58:12,015 | 1 resources found in the stack
2023-10-02 19:58:12,016 | Found Serverless function with name='HelloWorldFunctionGraalVM' and CodeUri='HelloWorldFunction/'
2023-10-02 19:58:12,016 | --base-dir is not presented, adjusting uri HelloWorldFunction/ relative to /software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/template.yaml
2023-10-02 19:58:12,020 | 1 resources found in the stack
2023-10-02 19:58:12,021 | Found Serverless function with name='HelloWorldFunctionGraalVM' and CodeUri='HelloWorldFunction/'
2023-10-02 19:58:12,022 | Instantiating build definitions
2023-10-02 19:58:12,027 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(provided.al2,
/software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/HelloWorldFunction, Zip, , f6d04515-4d32-4fc8-8d91-e2f1a8cf9513, {'BuildMethod': 'makefile'}, {}, x86_64, []), Function:
Function(function_id='HelloWorldFunctionGraalVM', name='HelloWorldFunctionGraalVM', functionname='03-maven-graalvm-custom', runtime='provided.al2', memory=1024, timeout=20,
handler='helloworld.App::handleRequest', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='/software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/HelloWorldFunction',
environment={'Variables': {'JAVA_TOOL_OPTIONS': '-XX:+TieredCompilation -XX:TieredStopAtLevel=1'}}, rolearn=None, layers=[], events=None, metadata={'BuildMethod': 'makefile', 'SamResourceId':
'HelloWorldFunctionGraalVM'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None, function_build_info=<FunctionBuildInfo.BuildableZip: ('BuildableZip',
'Regular ZIP function which can be build with SAM CLI')>, stack_path='', runtime_management_config=None))
2023-10-02 19:58:12,034 | Building codeuri: /software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/HelloWorldFunction runtime: provided.al2 metadata: {'BuildMethod': 'makefile'}
architecture: x86_64 functions: HelloWorldFunctionGraalVM
2023-10-02 19:58:12,035 | Building to following folder /software/projects/aws-sam-cli-java-examples/03-maven-graalvm-custom/.aws-sam/build/HelloWorldFunctionGraalVM
2023-10-02 19:58:12,788 | Failed to download image with name sam/custom-graal-image
2023-10-02 19:58:12,790 | Container was not created. Skipping deletion
2023-10-02 19:58:12,791 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-10-02 19:58:12,803 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2023-10-02 19:58:12,805 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '5cc2c65d-0834-4d89-b996-04ccb19cbda4', 'installationId': '41608184-77e2-40ac-9ec4-7c7bebe76365', 'sessionId':
'bd22d5d2-6b3f-435c-a87d-bb6af16e15b5', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.3', 'samcliVersion': '1.96.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region':
'', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '2f06cfee9022772b2a5818e0e23fcafc1f2e9bd089bd791ab9255747317a6cfc', 'initialCommit': None}, 'duration': 878, 'exitReason': 'DockerImagePullFailedException', 'exitCode': 255}}]}
2023-10-02 19:58:12,805 | Unable to find Click Context for getting session_id.
2023-10-02 19:58:12,815 | Sending Telemetry: {'metrics': [{'events': {'requestId': '2c76b3e6-6183-4a87-8880-b09663e96db6', 'installationId': '41608184-77e2-40ac-9ec4-7c7bebe76365', 'sessionId':
'bd22d5d2-6b3f-435c-a87d-bb6af16e15b5', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.11.3', 'samcliVersion': '1.96.0', 'commandName': 'sam build', 'metricSpecificAttributes': {'events':
[{'event_name': 'SamConfigFileExtension', 'event_value': '.toml', 'thread_id': 'cc4d147be7f246e49332b5408a6cec1f', 'time_stamp': '2023-10-03 00:58:11.878', 'exception_name': None}, {'event_name':
'BuildWorkflowUsed', 'event_value': 'provided-None', 'thread_id': 'd7358d529ab8451396a3b0a5b0686ed3', 'time_stamp': '2023-10-03 00:58:12.022', 'exception_name': None}, {'event_name':
'BuildFunctionRuntime', 'event_value': 'provided.al2', 'thread_id': 'ca103bbe91ef453aa5154015dce22f16', 'time_stamp': '2023-10-03 00:58:12.022', 'exception_name': None}, {'event_name':
'BuildWorkflowUsed', 'event_value': 'provided-None', 'thread_id': '7aef5a207daf4648b7f2f3095151420e', 'time_stamp': '2023-10-03 00:58:12.036', 'exception_name': None}]}}}]}
2023-10-02 19:58:13,275 | Telemetry response: 200
Error: Could not find sam/custom-graal-image image locally and failed to pull it from docker. Traceback: File "click/core.py", line 1078, in main File "click/core.py", line 1688, in invoke File "click/core.py", line 1434, in invoke File "click/core.py", line 783, in invoke File "click/decorators.py", line 92, in new_func File "click/core.py", line 783, in invoke File "samcli/lib/telemetry/metric.py", line 184, in wrapped File "samcli/lib/telemetry/metric.py", line 149, in wrapped File "samcli/lib/utils/version_checker.py", line 42, in wrapped File "samcli/cli/main.py", line 95, in wrapper File "samcli/commands/build/command.py", line 170, in cli File "samcli/commands/build/command.py", line 266, in do_cli File "samcli/commands/build/build_context.py", line 281, in run File "samcli/lib/build/app_builder.py", line 217, in build File "samcli/lib/build/build_strategy.py", line 81, in build File "samcli/lib/build/build_strategy.py", line 91, in _build_functions File "samcli/lib/build/build_strategy.py", line 164, in build_single_function_definition File "samcli/lib/build/app_builder.py", line 697, in _build_function File "samcli/lib/build/app_builder.py", line 939, in _build_function_on_container File "samcli/local/docker/manager.py", line 115, in run File "samcli/local/docker/manager.py", line 88, in create
An unexpected error was encountered while executing "sam build". Search for an existing issue:
https://github.com/aws/aws-sam-cli/issues?q=is%3Aissue+is%3Aopen+Bug%3A%20sam%20build%20-%20DockerImagePullFailedException
Or create a bug report:
https://github.com/aws/aws-sam-cli/issues/new?template=Bug_report.md&title=Bug%3A%20sam%20build%20-%20DockerImagePullFailedException `
Expected result:
I expected the build command to succeed.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
OS: Linux Ubuntu DISTRIB_ID=Ubuntu DISTRIB_RELEASE=23.04 DISTRIB_CODENAME=lunar DISTRIB_DESCRIPTION="Ubuntu 23.04"
sam --version
: SAM CLI, version 1.96.0AWS region: <haven't gotten to that point>
Paste the output of
sam --info
here"version": "1.96.0", "system": { "python": "3.11.3", "os": "Linux-6.2.0-33-generic-x86_64-with-glibc2.37" }, "additional_dependencies": { "docker_engine": "24.0.6", "aws_cdk": "Not available", "terraform": "Not available" }, "available_beta_feature_env_vars": [ "SAM_CLI_BETA_FEATURES", "SAM_CLI_BETA_BUILD_PERFORMANCE", "SAM_CLI_BETA_TERRAFORM_SUPPORT", "SAM_CLI_BETA_RUST_CARGO_LAMBDA" ] }