Reputation: 541
FROM <custom-name>.artifactory.<company>.net/base/gobuilder:latest as builder
...
FROM <custom-name>.artifactory.<company>.net/base/distroless-base:<hash>
...
I have an issue with the testcontainers library. For the most part, it just runs Docker containers so I guess the answer is more Docker-specific rather than bound to the library itself.
You can see the outline of my Dockerfile that uses our company's images in our Artifactory registry. It works just fine in CI/CD but for some reason doesn't with this library.
req := testcontainers.ContainerRequest{
FromDockerfile: testcontainers.FromDockerfile{
Context: "/path/to/context/,
Dockerfile: "Dockerfile",
},
}
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
})
This is how I create the container in my code.
What I get is this error:
Error response from daemon: no such image: 9305d9c8-1cfe-4c16-924b-3f734757d016:a6417aac-340b-4c37-a785-a45aa11f9ede: No such image: 9305d9c8-1cfe-4c16-924b-3f734757d016:a6417aac-340b-4c37-a785-a45aa11f9ede: failed to create container
--- FAIL: TestContainer
Nonetheless, if I run docker images -a
, I see the image listed:
<custom-name>.artifactory.<company>.net/base/gobuilder latest 0ca0c1df3fa1 3 months ago 935MB
I have tried to restart the Docker service multiple times but with no luck.
What else could I try?
As an experiment, I tried to use a public image for Go but got the same error. It's also strange that it shows a non-existing image hash when returning the error.
Upvotes: 2
Views: 1144
Reputation: 111
What version of Testcontainers for Go do you use? In the latest release, v0.19.0, it's possible to build from a Dockerfile from private registries without passing the credentials, as they will be automatically discovered by the Docker credentials helpers. https://golang.testcontainers.org/features/docker_auth/
req := ContainerRequest{
FromDockerfile: testcontainers.FromDockerfile{
Context: "/path/to/build/context",
Dockerfile: "CustomDockerfile",
BuildArgs: map[string]*string {
"FOO": "BAR",
},
},
}
In previous versions you were forced to pass the auth credentials as part of the FromDockerfile
struct.
Upvotes: 2