Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to start containers with raw image IDs #663

Merged
merged 2 commits into from
Nov 23, 2023

Conversation

gzm0
Copy link
Contributor

@gzm0 gzm0 commented Oct 25, 2023

Docker supports starting containers with bare image IDs:

docker run aa285b773a2c042056883845aea893a743d358a5d40f61734fa228fde93dae6f

However, if a tag or digest is added to the ID, Docker will refuse it:

docker run aa285b773a2c042056883845aea893a743d358a5d40f61734fa228fde93dae6f:latest
Unable to find image 'aa285b773a2c042056883845aea893a743d358a5d40f61734fa228fde93dae6f:latest' locally
docker: Error response from daemon: invalid repository name (aa285b773a2c042056883845aea893a743d358a5d40f61734fa228fde93dae6f), cannot specify 64-byte hexadecimal strings.
See 'docker run --help'.

We adjust the string conversion of ImageName for this specific case to allow starting containers with bare image IDs.

More context:
testcontainers/testcontainers-java#7707

Docker supports starting containers with bare image IDs:

```
docker run aa285b773a2c042056883845aea893a743d358a5d40f61734fa228fde93dae6f
```

However, if a tag or digest is added to the ID, Docker will refuse it:

```
docker run aa285b773a2c042056883845aea893a743d358a5d40f61734fa228fde93dae6f:latest
Unable to find image 'aa285b773a2c042056883845aea893a743d358a5d40f61734fa228fde93dae6f:latest' locally
docker: Error response from daemon: invalid repository name (aa285b773a2c042056883845aea893a743d358a5d40f61734fa228fde93dae6f), cannot specify 64-byte hexadecimal strings.
See 'docker run --help'.
```

We adjust the string conversion of ImageName for this specific case to
allow starting containers with bare image IDs.

More context:
testcontainers/testcontainers-java#7707
@netlify
Copy link

netlify bot commented Oct 25, 2023

Deploy Preview for testcontainers-node ready!

Name Link
🔨 Latest commit b32f9cb
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-node/deploys/653a49e627ca840007a4c356
😎 Deploy Preview https://deploy-preview-663--testcontainers-node.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -96,5 +116,13 @@ describe("ContainerImage", () => {
expect(imageName.image).toBe("image");
expect(imageName.tag).toBe("sha256:1234abcd1234abcd1234abcd1234abcd");
});

it("should work with image being an image ID", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to should keep other tags (not latest) on image IDs, do we need a fromString test where the input has a non-latest tag (aa285b773a2c042056883845aea893a743d358a5d40f61734fa228fde93dae6f:1)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's probably a good idea. I've added a commit with a test (and also added the docker error message to the text explaining that it won't accept the reference).

@cristianrgreco cristianrgreco added enhancement New feature or request minor Backward compatible functionality labels Oct 26, 2023
@cristianrgreco cristianrgreco changed the title Allow to start containers with bare image IDs Allow to start containers with raw image IDs Nov 23, 2023
@cristianrgreco cristianrgreco merged commit 40cd6f6 into testcontainers:main Nov 23, 2023
109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor Backward compatible functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants