The initial error happens during sam build --use-container inside the Bitbucket pipeline:
RuntimeError: Container does not exist. Cannot get logs for this container
In the Bitbucket pipeline I get following error output, when I run the command docker run amazon/aws-sam-cli-build-image-python3.7 echo 'hello world'.
6b6e3df282b0: Verifying Checksum
6b6e3df282b0: Download complete
6b6e3df282b0: Pull complete
failed to register layer: Error processing tar file(exit status 1): Container ID 1230228 cannot be mapped to a host ID
Run docker run amazon/aws-sam-cli-build-image-python3.7 echo 'hello world' inside the bitbucket pipeline.
6b6e3df282b0: Verifying Checksum
6b6e3df282b0: Download complete
6b6e3df282b0: Pull complete
failed to register layer: Error processing tar file(exit status 1): Container ID 1230228 cannot be mapped to a host ID
From my initial analysis it seems to be related to this error and solution: https://circleci.com/docs/2.0/high-uid-error/.
The error is caused by a userns remapping failure. CircleCI runs Docker containers with userns enabled in order to securely run customers’ containers. The host machine is configured with a valid UID/GID for remapping. This UID/GID must be in the range of 0 - 65535.
Though this can only be applied by the docker image owner.
A working docker pull.
sam --version: 0.53.0 (inside aws-sam-cli-build-image-python3.7), 'samcliVersion': '1.0.0' (inside python:3.7-buster) docker history amazon/aws-sam-cli-build-image-python3.7
IMAGE CREATED CREATED BY SIZE COMMENT
9afb7fbe0b02 4 weeks ago /bin/sh -c #(nop) COPY file:ca68a30f0c2f97ee… 101MB
<missing> 4 weeks ago |1 SAM_CLI_VERSION=0.53.0 /bin/sh -c pip3 in… 457MB
<missing> 4 weeks ago /bin/sh -c #(nop) ENV LANG=en_US.UTF-8 0B
<missing> 4 weeks ago /bin/sh -c #(nop) ENV PATH=/var/lang/bin:/u… 0B
<missing> 4 weeks ago |1 SAM_CLI_VERSION=0.53.0 /bin/sh -c rm samc… 57.4MB
<missing> 4 weeks ago |1 SAM_CLI_VERSION=0.53.0 /bin/sh -c curl -L… 172MB
<missing> 4 weeks ago /bin/sh -c #(nop) ARG SAM_CLI_VERSION 0B
<missing> 4 weeks ago /bin/sh -c curl "https://awscli.amazonaws.co… 298kB
<missing> 4 weeks ago /bin/sh -c chmod 1777 /tmp && /usr/bin/pyt… 644MB
Add --debug flag to command you are running
Fetching amazon/aws-sam-cli-build-image-python3.7 Docker container image..............................................................................................................................................................................................................................................................................................................................................................................................................................................
Mounting /opt/atlassian/pipelines/agent/build/build/**reducted** as /tmp/samcli/source:ro,delegated inside runtime container
Container was not created. Skipping deletion
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 35126, 'exitReason': 'RuntimeError', 'exitCode': 255, 'requestId': '0d920e92-1049-402b-a78d-6d2140eed13c', 'installationId': '1e1cbc8e-2ae3-42a0-95f8-d96eb5680fb6', 'sessionId': '8c001b5a-94b8-4456-a433-d566899baddc', 'executionEnvironment': 'CLI', 'pyversion': '3.7.8', 'samcliVersion': '1.0.0'}}]}
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/bin/sam", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/samcli/lib/telemetry/metrics.py", line 96, in wrapped
raise exception # pylint: disable=raising-bad-type
File "/usr/local/lib/python3.7/site-packages/samcli/lib/telemetry/metrics.py", line 62, in wrapped
return_value = func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/samcli/commands/build/command.py", line 129, in cli
mode,
File "/usr/local/lib/python3.7/site-packages/samcli/commands/build/command.py", line 194, in do_cli
artifacts = builder.build()
File "/usr/local/lib/python3.7/site-packages/samcli/lib/build/app_builder.py", line 117, in build
function.metadata)
File "/usr/local/lib/python3.7/site-packages/samcli/lib/build/app_builder.py", line 271, in _build_function
options)
File "/usr/local/lib/python3.7/site-packages/samcli/lib/build/app_builder.py", line 369, in _build_function_on_container
container.wait_for_logs(stdout=stdout_stream, stderr=stderr_stream)
File "/usr/local/lib/python3.7/site-packages/samcli/local/docker/container.py", line 197, in wait_for_logs
raise RuntimeError("Container does not exist. Cannot get logs for this container")
RuntimeError: Container does not exist. Cannot get logs for this container
The files with an id of 1230228 seem to come from the image FROM amazon/aws-sam-cli-emulation-image-python3.7.
Tried to setup a user mapping into a valid range with echo "pipelines:1230228:65536" > /etc/subuid && echo "pipelines:1230228:65536" > /etc/subgid
That didn't work.
Additionally tried to change permission by fixing images
https://hub.docker.com/repository/docker/tobwiens/aws-sam-cli-emulation-image-python3.7-fix2125
https://hub.docker.com/repository/docker/tobwiens/aws-sam-cli-build-image-python3.7-fix2125
That didn't work either.
Further help is appreciated. Thank you.
Seems to be effecting other runtimes, at least nodejs10.x:
❯ docker run amazon/aws-sam-cli-emulation-image-nodejs10.x echo 'hello world'
Unable to find image 'amazon/aws-sam-cli-emulation-image-nodejs10.x:latest' locally
latest: Pulling from amazon/aws-sam-cli-emulation-image-nodejs10.x
cb4a6ee8d388: Pull complete
227c392a77a2: Extracting 56.46kB/56.46kB
05668e4bd7cc: Download complete
6ce50915c1c0: Download complete
docker: failed to register layer: Error processing tar file(exit status 1): Container ID 1230228 cannot be mapped to a host ID.
See 'docker run --help'.
Raising this with the image owners, will share updates here.
Most helpful comment
Raising this with the image owners, will share updates here.