Describe the bug
Hi,
I am having a problem using TarballImageAsset as a grep expression used to get the image digest is not ok for the docker version/OS I am currently using.
My code:
const image = new TarballImageAsset(this, `${taskEnvId}ContainerImage`,{
tarballFile: path.join(__dirname, '..', '..', 'image.tar.gz')
})
The error:
[11:37:20] my-app: build: Building Docker image using command 'sh,-c,docker load -i asset.2fafafafafafafafafafafafafafafafafafafafafafafafafafafafafafafaf.tar.gz | tail -n 1 | sed "s/Loaded image: //g"'
my-app: success: Published c12098d40a4cc1e247b7041b9e6fefa4c1596ff63692672b5c386d002d00862c:123123123123-eu-central-1
[11:37:23] my-app: debug: docker tag 'Loaded image ID: sha256:4a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a' 123123123123.dkr.ecr.eu-central-1.amazonaws.com/cdk-hnb659fds-container-assets-123123123123-eu-central-1:2fafafafafafafafafafafafafafafafafafafafafafafafafafafafafafafaf
Error parsing reference: "Loaded image ID: sha256:4a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a" is not a valid repository/tag: invalid reference format: repository name (library/Loaded image ID) must be lowercase
my-app: fail: docker tag 'Loaded image ID: sha256:4a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a' 123123123123.dkr.ecr.eu-central-1.amazonaws.com/cdk-hnb659fds-container-assets-123123123123-eu-central-1:2fafafafafafafafafafafafafafafafafafafafafafafafafafafafafafafaf exited with error code 1: Error parsing reference: "Loaded image ID: sha256:4a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a" is not a valid repository/tag: invalid reference format: repository name (library/Loaded image ID) must be lowercase
My docker environment (Mac):
$> docker version
Client:
Version: 27.4.0
API version: 1.47
Go version: go1.22.10
Git commit: bde2b89
Built: Sat Dec 7 10:35:43 2024
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.37.2 (179585)
Engine:
Version: 27.4.0
API version: 1.47 (minimum version 1.24)
Go version: go1.22.10
Git commit: 92a8393
Built: Sat Dec 7 10:38:33 2024
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.7.21
GitCommit: 472731909fa34bd7bc9c087e4c27943f9835f111
runc:
Version: 1.1.13
GitCommit: v1.1.13-0-g58aa920
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
The asset tarball should be imported to local docker image cache, tagged and uploaded to ECR.
Current Behavior
The asset tarball cannot be imported to local docker image cache as the image tag is is cleaned with a sed expression that is not properly built for latest docker clients.
Reproduction Steps
Ensure you use the latest docker version for mac, similar to this one:
$> docker version
Client:
Version: 27.4.0
API version: 1.47
Go version: go1.22.10
Git commit: bde2b89
Built: Sat Dec 7 10:35:43 2024
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.37.2 (179585)
Engine:
Version: 27.4.0
API version: 1.47 (minimum version 1.24)
Go version: go1.22.10
Git commit: 92a8393
Built: Sat Dec 7 10:38:33 2024
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.7.21
GitCommit: 472731909fa34bd7bc9c087e4c27943f9835f111
runc:
Version: 1.1.13
GitCommit: v1.1.13-0-g58aa920
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Create a tarball image asset as follows:
const image = new TarballImageAsset(this, `${taskEnvId}ContainerImage`,{
tarballFile: path.join(__dirname, '..', '..', 'image.tar.gz')
})
Run a CDK synth stack with that asset.
Possible Solution
The problem seems to be the sed expression used here, that expects docker load output to match the expression Loaded image: <digest>.
However, in the attached docker version docker load actually prints Loaded image ID: <digest>.
Just changing the sed expression from sed "s/Loaded image: //g" to sed "s/Loaded image[^:]*: //g" or similar should work for every scenario. For example:
$> echo 'Loaded image ID: sha256:4a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a'| sed "s/Loaded image[^:]*: //g"
sha256:4a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
$> echo 'Loaded image: sha256:4a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a'| sed "s/Loaded image[^:]*: //g"
sha256:4a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a
Additional Information/Context
No response
CDK CLI Version
2.176.0 (build 899965d)
Framework Version
No response
Node.js Version
v23.6.1
OS
Mac OS
Language
TypeScript
Language Version
typescript@^5.7.3
Other information
No response
Describe the bug
Hi,
I am having a problem using
TarballImageAssetas a grep expression used to get the image digest is not ok for the docker version/OS I am currently using.My code:
The error:
My docker environment (Mac):
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
The asset tarball should be imported to local docker image cache, tagged and uploaded to ECR.
Current Behavior
The asset tarball cannot be imported to local docker image cache as the image tag is is cleaned with a
sedexpression that is not properly built for latest docker clients.Reproduction Steps
Ensure you use the latest docker version for mac, similar to this one:
Create a tarball image asset as follows:
Run a CDK synth stack with that asset.
Possible Solution
The problem seems to be the
sedexpression used here, that expectsdocker loadoutput to match the expressionLoaded image: <digest>.However, in the attached docker version
docker loadactually printsLoaded image ID: <digest>.Just changing the sed expression from
sed "s/Loaded image: //g"tosed "s/Loaded image[^:]*: //g"or similar should work for every scenario. For example:Additional Information/Context
No response
CDK CLI Version
2.176.0 (build 899965d)
Framework Version
No response
Node.js Version
v23.6.1
OS
Mac OS
Language
TypeScript
Language Version
typescript@^5.7.3
Other information
No response