Testcontainers-java: Cannot use against local image Ids

Created on 16 May 2018  路  5Comments  路  Source: testcontainers/testcontainers-java

For example, if using the output of --iidfile then the image is attempted to be fetched instead of using the existing local image Id:

Caused by: org.testcontainers.containers.ContainerFetchException: Retry limit reached while trying to pull image: sha256:8cf620617c6203b24af7c5bf15a7212386c27ad008fc4c6ff7e37a1bf0a3cdd2
    at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:91)
    at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:25)
    at org.testcontainers.utility.LazyFuture.getResolvedValue(LazyFuture.java:20)
    at org.testcontainers.utility.LazyFuture.get(LazyFuture.java:27)
    at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:839)
    ... 55 more
Caused by: com.github.dockerjava.api.exception.NotFoundException: {"message":"pull access denied for sha256, repository does not exist or may require 'docker login'"}

docker run --it --rm sha256:8cf620617c6203b24af7c5bf15a7212386c27ad008fc4c6ff7e37a1bf0a3cdd2 works as expected.

resolutioacknowledged typfeature

Most helpful comment

That seems reasonable. I didn't dive too far into the code, but maybe query the engine to see if the image is available first before running or fetching?

All 5 comments

So we might change it, that we only fetch if the run failed? Kind of lazy fetching?

That seems reasonable. I didn't dive too far into the code, but maybe query the engine to see if the image is available first before running or fetching?

Starting a container using the Image ID was actually supported before #1324 was merged. GenericContainer(Future<String>) used to pass the value of that future directly to the docker client: https://github.com/testcontainers/testcontainers-java/blob/43a76abb5d27f322a6a7a30ffc148beb31cd5736/core/src/main/java/org/testcontainers/containers/GenericContainer.java#L331-L335

After #1324 there is no way anymore to bypass RemoteDockerImage and DockerImageName. resulting in this error when passing a Future<String> to GenericContainer's constructor:

Caused by: com.github.dockerjava.api.exception.NotFoundException: {"message":"pull access denied for b4c09c304a32, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}

This issue blocks us from upgrading to the latest TestContainers release. I would be happy to provide a PR to restore the old behavior but I need some pointers on how to do this.

I've amended #1406 to reflect that it's not just image digests we need to load into our image name cache, it's also image IDs. That ought to prevent us from attempting to pull images in this kind of scenario.

Thanks @rnorth reading the original issue description again I think @mkobit was talking about SHA256 digests and not about image IDs. Thus I think the issue title should be rephrased.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chomhanks picture chomhanks  路  3Comments

dabraham02124 picture dabraham02124  路  3Comments

andredasilvapinto picture andredasilvapinto  路  3Comments

itudoben picture itudoben  路  3Comments

rnorth picture rnorth  路  3Comments