Skip to content

Commit

Permalink
fix(core): support docker engine v20.10.0-beta1 (#11124)
Browse files Browse the repository at this point in the history
Running an image by only providing the hash fails on docker engine v20.10.0-beta1 with invalid repository name.

```
docker run --rm b92402b29db56f1bbace74c369bedef5ee296a76fd8545426255247da70ce21a
docker: Error response from daemon: invalid repository name (b92402b29db56f1bbace74c369bedef5ee296a76fd8545426255247da70ce21a), cannot specify 64-byte hexadecimal strings.
```

Using `docker run --rm sha256:b92402b29db56f1bbace74c369bedef5ee296a76fd8545426255247da70ce21a` instead works as expected.

I haven't been able to pinpoint the exact change yet as this seems not to be mentioned in https://github.com/docker/docker-ce/blob/0fc7084265b3786a5867ec311d3f916af7bf7a23/CHANGELOG.md

Created an issue with docker to clarify whether this is a regression or a planned change docker/cli#2815

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
johanneswuerbach committed Oct 29, 2020
1 parent 0c8264a commit 87887a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/core/lib/bundling.ts
Expand Up @@ -117,7 +117,7 @@ export class BundlingDockerImage {

const docker = dockerExec(dockerArgs);

const match = docker.stdout.toString().match(/sha256:([a-z0-9]+)/);
const match = docker.stdout.toString().match(/sha256:[a-z0-9]+/);

if (!match) {
throw new Error('Failed to extract image ID from Docker build output');
Expand All @@ -129,7 +129,7 @@ export class BundlingDockerImage {
// different every time the Docker layer cache is cleared, due primarily to
// timestamps.
const hash = FileSystem.fingerprint(path, { extraHash: JSON.stringify(options) });
return new BundlingDockerImage(match[1], hash);
return new BundlingDockerImage(match[0], hash);
}

/** @param image The Docker image */
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/core/test/bundling.test.ts
Expand Up @@ -46,11 +46,11 @@ nodeunitShim({
},

'bundling with image from asset'(test: Test) {
const imageId = 'abcdef123456';
const imageId = 'sha256:abcdef123456';
const spawnSyncStub = sinon.stub(child_process, 'spawnSync').returns({
status: 0,
stderr: Buffer.from('stderr'),
stdout: Buffer.from(`sha256:${imageId}`),
stdout: Buffer.from(imageId),
pid: 123,
output: ['stdout', 'stderr'],
signal: null,
Expand Down Expand Up @@ -133,11 +133,11 @@ nodeunitShim({
},

'BundlerDockerImage json is the bundler image if building an image'(test: Test) {
const imageId = 'abcdef123456';
const imageId = 'sha256:abcdef123456';
sinon.stub(child_process, 'spawnSync').returns({
status: 0,
stderr: Buffer.from('stderr'),
stdout: Buffer.from(`sha256:${imageId}`),
stdout: Buffer.from(imageId),
pid: 123,
output: ['stdout', 'stderr'],
signal: null,
Expand Down

0 comments on commit 87887a3

Please sign in to comment.