Testcontainers-java: Testcontainers.exposeHostPorts not working when offline

Created on 11 Apr 2019  路  5Comments  路  Source: testcontainers/testcontainers-java

The problem can be debugged in RemoteDockerImage#resolve.
The call to List<Image> updatedImages = (List)listImagesCmd.exec() returns the sshd image but it has a null repoTags. Thus AVAILABLE_IMAGE_NAME_CACHE is not updated with it and it's pulled.

$ docker inspect e716acb1cdb2 [ { "Id": "sha256:e716acb1cdb228671503beae1f4048b711f7edcab5f1b0decaf7e380ce14e312", "RepoTags": [], "RepoDigests": [ "quay.io/testcontainers/sshd@sha256:18aa929c653284189fc9cefa45b731021857b6047a0a1757e909f958f258f088" ], ..

@rnorth said:

Hmm, this could be a bug introduced during the refactoring of image identity handling (related to registry auth)

Most helpful comment

Confirmed that it works! Thanks again

All 5 comments

I'm on TC 1.11.1.

I've done some digging and put together a test that confirms this.

There are two problems:

  1. As identified and solved by @bsideup, the default TestcontainersConfiguration for the sshd image uses a SHA256-versioned image rather than an image tag. This can be worked around via a properties file to override the default sshd image (see docs, although this option is not explicitly documented)
  2. Testcontainers' image indexing code can't handle images that have SHA256 digests. We need a way to access the RepoDigests from docker-java's Image class. Unless I'm missing something, at the moment only RepoTags is mapped.

I'll raise a PR to fix issue (1), and a separate issue to track (2).

Released in 1.11.2!

Thanks @rnorth , will try it later today :)

Confirmed that it works! Thanks again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

richard77 picture richard77  路  3Comments

vmassol picture vmassol  路  3Comments

oneiros-de picture oneiros-de  路  3Comments

aniketbhatnagar picture aniketbhatnagar  路  3Comments

naderghanbari picture naderghanbari  路  3Comments