Testcontainers-java: NPE when no image tag is specified

Created on 1 May 2018  路  4Comments  路  Source: testcontainers/testcontainers-java

This is my current GenericContainer declaration:

    @Shared
    GenericContainer container = new GenericContainer("my-local-image")
            .withEnv("CONFLUENCE_VERSION", "6.8.2")
            .withExposedPorts(1990)
            .waitingFor(Wait.forListeningPort())

and I get the following error:

java.lang.NullPointerException
    at org.testcontainers.utility.DockerImageName.toString(DockerImageName.java:97)
    at java.lang.String.valueOf(String.java:2994)
    at java.lang.StringBuilder.append(StringBuilder.java:131)
    at org.testcontainers.images.RemoteDockerImage.toString(RemoteDockerImage.java:25)
    at java.lang.String.valueOf(String.java:2994)
    at java.lang.StringBuilder.append(StringBuilder.java:131)
    at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:841)
    at org.testcontainers.containers.GenericContainer.setDockerImageName(GenericContainer.java:829)
    at org.testcontainers.containers.GenericContainer.<init>(GenericContainer.java:185)
    at com.comalatech.confluence.test.poc.PocSpec.$spock_initializeSharedFields(PocSpec.groovy:25)

FYI, the image exists locally and I am able to use it to launch containers using Docker for Mac

resolutioawaiting-release typbug

All 4 comments

Hey @aruizca, please try to add a tag to the image name, new GenericContainer("my-local-image:latest").

Thanks @kiview,
adding the latest tag fix the NPE and now I am into the next error :-)
I reckon this should be considered as a small bug since the latest tag should be applied by default.

It would be nice to either

  • default to the tag latest
  • issue a descriptive error message pointing to the missing tag.

@helmbold I also think, using latest as default tag is something Docker users are expecting.

Was this page helpful?
0 / 5 - 0 ratings