From 9f694e16a647f4db0adf74fecbaac50812d16de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Mon, 14 Nov 2022 13:54:24 -0800 Subject: [PATCH 01/10] Accept image names with `library/` prefix as a valid substitute Docker official images can be pulled with or without `library/` prefix as part of the image name. For example, `mysql` or `library/mysql`. This is explicit when using private repositories. --- .../testcontainers/DockerClientFactory.java | 2 +- .../containers/CassandraContainer.java | 4 ++- .../containers/CassandraContainerTest.java | 4 +-- .../containers/CassandraDriver3Test.java | 2 +- .../containers/CassandraDriver4Test.java | 2 +- .../consul/ConsulContainer.java | 4 ++- .../consul/ConsulTestImages.java | 2 +- .../containers/InfluxDBContainer.java | 4 ++- .../containers/InfluxDBTestImages.java | 2 +- .../containers/MariaDBContainer.java | 4 ++- .../org/testcontainers/MariaDBTestImages.java | 2 +- .../containers/MongoDBContainer.java | 4 ++- .../containers/MongoDBContainerTest.java | 16 +++++++--- .../containers/MySQLContainer.java | 4 ++- .../org/testcontainers/MySQLTestImages.java | 6 ++-- .../containers/Neo4jContainer.java | 8 +++-- .../Neo4jContainerJUnitIntegrationTest.java | 2 +- .../containers/Neo4jContainerTest.java | 30 +++++++++++-------- .../containers/NginxContainer.java | 4 ++- .../testcontainers/junit/SimpleNginxTest.java | 2 +- .../containers/OrientDBContainer.java | 4 ++- .../containers/OrientDBContainerTest.java | 2 +- .../containers/PostgreSQLContainer.java | 4 ++- .../testcontainers/PostgreSQLTestImages.java | 2 +- .../containers/RabbitMQContainer.java | 4 ++- .../containers/RabbitMQTestImages.java | 2 +- .../containers/SolrContainer.java | 4 ++- .../containers/SolrContainerTest.java | 2 +- .../testcontainers/vault/VaultContainer.java | 4 ++- .../testcontainers/vault/VaultClientTest.java | 4 ++- .../vault/VaultContainerTest.java | 2 +- 31 files changed, 92 insertions(+), 50 deletions(-) diff --git a/core/src/main/java/org/testcontainers/DockerClientFactory.java b/core/src/main/java/org/testcontainers/DockerClientFactory.java index 73bf24e511c..d2b3cbdf166 100644 --- a/core/src/main/java/org/testcontainers/DockerClientFactory.java +++ b/core/src/main/java/org/testcontainers/DockerClientFactory.java @@ -75,7 +75,7 @@ static Map markerLabels() { return Collections.unmodifiableMap(labels); } - private static final DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.16"); + private static final DockerImageName TINY_IMAGE = DockerImageName.parse("library/alpine:3.16"); private static DockerClientFactory instance; diff --git a/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java b/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java index a12ac03f18d..6bbfcd411ae 100644 --- a/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java +++ b/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java @@ -29,6 +29,8 @@ public class CassandraContainer> extends G private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("cassandra"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/cassandra"); + private static final String DEFAULT_TAG = "3.11.2"; @Deprecated @@ -64,7 +66,7 @@ public CassandraContainer(String dockerImageName) { public CassandraContainer(DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); addExposedPort(CQL_PORT); this.enableJmxReporting = false; diff --git a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraContainerTest.java b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraContainerTest.java index d8f21fc3068..a03be3388ba 100644 --- a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraContainerTest.java +++ b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraContainerTest.java @@ -17,7 +17,7 @@ @Slf4j public class CassandraContainerTest { - private static final DockerImageName CASSANDRA_IMAGE = DockerImageName.parse("cassandra:3.11.2"); + private static final DockerImageName CASSANDRA_IMAGE = DockerImageName.parse("library/cassandra:3.11.2"); private static final String TEST_CLUSTER_NAME_IN_CONF = "Test Cluster Integration Test"; @@ -88,7 +88,7 @@ public void testInitScript() { public void testInitScriptWithLegacyCassandra() { try ( CassandraContainer cassandraContainer = new CassandraContainer<>( - DockerImageName.parse("cassandra:2.2.11") + DockerImageName.parse("library/cassandra:2.2.11") ) .withInitScript("initial.cql") ) { diff --git a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver3Test.java b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver3Test.java index 502f2ca8e67..5f10bab03d0 100644 --- a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver3Test.java +++ b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver3Test.java @@ -11,7 +11,7 @@ public class CassandraDriver3Test { @Rule - public CassandraContainer cassandra = new CassandraContainer<>("cassandra:3.11.2"); + public CassandraContainer cassandra = new CassandraContainer<>("library/cassandra:3.11.2"); @Test public void testCassandraGetContactPoint() { diff --git a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver4Test.java b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver4Test.java index a4fb8c87b8e..0223fcbdf10 100644 --- a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver4Test.java +++ b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver4Test.java @@ -11,7 +11,7 @@ public class CassandraDriver4Test { @Rule - public CassandraContainer cassandra = new CassandraContainer<>("cassandra:3.11.2"); + public CassandraContainer cassandra = new CassandraContainer<>("library/cassandra:3.11.2"); @Test public void testCassandraGetContactPoint() { diff --git a/modules/consul/src/main/java/org/testcontainers/consul/ConsulContainer.java b/modules/consul/src/main/java/org/testcontainers/consul/ConsulContainer.java index 0c9d2607072..e11982cb31a 100644 --- a/modules/consul/src/main/java/org/testcontainers/consul/ConsulContainer.java +++ b/modules/consul/src/main/java/org/testcontainers/consul/ConsulContainer.java @@ -19,6 +19,8 @@ public class ConsulContainer extends GenericContainer { private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("consul"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/consul"); + private static final int CONSUL_HTTP_PORT = 8500; private static final int CONSUL_GRPC_PORT = 8502; @@ -33,7 +35,7 @@ public ConsulContainer(String dockerImageName) { public ConsulContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); // Use the status leader endpoint to verify if consul is running. setWaitStrategy(Wait.forHttp("/v1/status/leader").forPort(CONSUL_HTTP_PORT).forStatusCode(200)); diff --git a/modules/consul/src/test/java/org/testcontainers/consul/ConsulTestImages.java b/modules/consul/src/test/java/org/testcontainers/consul/ConsulTestImages.java index de2b9702066..00b2a33d957 100644 --- a/modules/consul/src/test/java/org/testcontainers/consul/ConsulTestImages.java +++ b/modules/consul/src/test/java/org/testcontainers/consul/ConsulTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface ConsulTestImages { - DockerImageName CONSUL_IMAGE = DockerImageName.parse("consul:1.10.12"); + DockerImageName CONSUL_IMAGE = DockerImageName.parse("library/consul:1.10.12"); } diff --git a/modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainer.java b/modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainer.java index 40eea721b57..cb813a192fe 100644 --- a/modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainer.java +++ b/modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainer.java @@ -18,6 +18,8 @@ public class InfluxDBContainer> extends Gen private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("influxdb"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/influxdb"); + private static final String DEFAULT_TAG = "1.4.3"; @Deprecated @@ -53,7 +55,7 @@ public InfluxDBContainer(final String version) { public InfluxDBContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); waitStrategy = new WaitAllStrategy() diff --git a/modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBTestImages.java b/modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBTestImages.java index a0e2d31bbdf..2fae44363ca 100644 --- a/modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBTestImages.java +++ b/modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface InfluxDBTestImages { - DockerImageName INFLUXDB_TEST_IMAGE = DockerImageName.parse("influxdb:1.4.3"); + DockerImageName INFLUXDB_TEST_IMAGE = DockerImageName.parse("library/influxdb:1.4.3"); } diff --git a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java index b0944a6d3c0..09e804f0f26 100644 --- a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java +++ b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java @@ -14,6 +14,8 @@ public class MariaDBContainer> extends JdbcD private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("mariadb"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/mariadb"); + @Deprecated public static final String DEFAULT_TAG = "10.3.6"; @@ -52,7 +54,7 @@ public MariaDBContainer(String dockerImageName) { public MariaDBContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); addExposedPort(MARIADB_PORT); } diff --git a/modules/mariadb/src/test/java/org/testcontainers/MariaDBTestImages.java b/modules/mariadb/src/test/java/org/testcontainers/MariaDBTestImages.java index 7d18f2f8365..aa7af19cca9 100644 --- a/modules/mariadb/src/test/java/org/testcontainers/MariaDBTestImages.java +++ b/modules/mariadb/src/test/java/org/testcontainers/MariaDBTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface MariaDBTestImages { - DockerImageName MARIADB_IMAGE = DockerImageName.parse("mariadb:10.3.6"); + DockerImageName MARIADB_IMAGE = DockerImageName.parse("library/mariadb:10.3.6"); } diff --git a/modules/mongodb/src/main/java/org/testcontainers/containers/MongoDBContainer.java b/modules/mongodb/src/main/java/org/testcontainers/containers/MongoDBContainer.java index ae93e4121d3..c1d3dd3a353 100644 --- a/modules/mongodb/src/main/java/org/testcontainers/containers/MongoDBContainer.java +++ b/modules/mongodb/src/main/java/org/testcontainers/containers/MongoDBContainer.java @@ -19,6 +19,8 @@ public class MongoDBContainer extends GenericContainer { private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("mongo"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/mongo"); + private static final String DEFAULT_TAG = "4.0.10"; private static final int CONTAINER_EXIT_CODE_OK = 0; @@ -43,7 +45,7 @@ public MongoDBContainer(@NonNull final String dockerImageName) { public MongoDBContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); withExposedPorts(MONGODB_INTERNAL_PORT); withCommand("--replSet", "docker-rs"); diff --git a/modules/mongodb/src/test/java/org/testcontainers/containers/MongoDBContainerTest.java b/modules/mongodb/src/test/java/org/testcontainers/containers/MongoDBContainerTest.java index dd59420f937..f0103fab0ad 100644 --- a/modules/mongodb/src/test/java/org/testcontainers/containers/MongoDBContainerTest.java +++ b/modules/mongodb/src/test/java/org/testcontainers/containers/MongoDBContainerTest.java @@ -24,7 +24,9 @@ public class MongoDBContainerTest { public void shouldExecuteTransactions() { try ( // creatingMongoDBContainer { - final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10")) + final MongoDBContainer mongoDBContainer = new MongoDBContainer( + DockerImageName.parse("library/mongo:4.0.10") + ) // } ) { // startingMongoDBContainer { @@ -88,14 +90,20 @@ private void executeTx(MongoDBContainer mongoDBContainer) { @Test public void supportsMongoDB_4_4() { - try (final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.4"))) { + try ( + final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("library/mongo:4.4")) + ) { mongoDBContainer.start(); } } @Test public void shouldTestDatabaseName() { - try (final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10"))) { + try ( + final MongoDBContainer mongoDBContainer = new MongoDBContainer( + DockerImageName.parse("library/mongo:4.0.10") + ) + ) { mongoDBContainer.start(); final String databaseName = "my-db"; assertThat(mongoDBContainer.getReplicaSetUrl(databaseName)).endsWith(databaseName); @@ -104,7 +112,7 @@ public void shouldTestDatabaseName() { @Test public void supportsMongoDB_6() { - try (final MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:6.0.1")) { + try (final MongoDBContainer mongoDBContainer = new MongoDBContainer("library/mongo:6.0.1")) { mongoDBContainer.start(); executeTx(mongoDBContainer); } diff --git a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java index 316e709995c..3b56469e619 100644 --- a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java +++ b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java @@ -14,6 +14,8 @@ public class MySQLContainer> extends JdbcDatab private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("mysql"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/mysql"); + @Deprecated public static final String DEFAULT_TAG = "5.7.34"; @@ -50,7 +52,7 @@ public MySQLContainer(String dockerImageName) { public MySQLContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); addExposedPort(MYSQL_PORT); } diff --git a/modules/mysql/src/test/java/org/testcontainers/MySQLTestImages.java b/modules/mysql/src/test/java/org/testcontainers/MySQLTestImages.java index 81de83be0b9..9320e6bb9f7 100644 --- a/modules/mysql/src/test/java/org/testcontainers/MySQLTestImages.java +++ b/modules/mysql/src/test/java/org/testcontainers/MySQLTestImages.java @@ -4,9 +4,9 @@ public class MySQLTestImages { - public static final DockerImageName MYSQL_56_IMAGE = DockerImageName.parse("mysql:5.6.51"); + public static final DockerImageName MYSQL_56_IMAGE = DockerImageName.parse("library/mysql:5.6.51"); - public static final DockerImageName MYSQL_57_IMAGE = DockerImageName.parse("mysql:5.7.34"); + public static final DockerImageName MYSQL_57_IMAGE = DockerImageName.parse("library/mysql:5.7.34"); - public static final DockerImageName MYSQL_80_IMAGE = DockerImageName.parse("mysql:8.0.24"); + public static final DockerImageName MYSQL_80_IMAGE = DockerImageName.parse("library/mysql:8.0.24"); } diff --git a/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java b/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java index 94b4263fe8c..70aed7af05a 100644 --- a/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java +++ b/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java @@ -31,6 +31,8 @@ public class Neo4jContainer> extends GenericContaine */ private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("neo4j"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/neo4j"); + /** * The default tag (version) to use. */ @@ -91,9 +93,11 @@ public Neo4jContainer(String dockerImageName) { */ public Neo4jContainer(final DockerImageName dockerImageName) { super(dockerImageName); - this.standardImage = dockerImageName.getUnversionedPart().equals(DEFAULT_IMAGE_NAME.getUnversionedPart()); + this.standardImage = + dockerImageName.getUnversionedPart().equals(DEFAULT_IMAGE_NAME.getUnversionedPart()) || + dockerImageName.getUnversionedPart().equals(LIBRARY_IMAGE_NAME.getUnversionedPart()); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); WaitStrategy waitForBolt = new LogMessageWaitStrategy() .withRegEx(String.format(".*Bolt enabled on .*:%d\\.\n", DEFAULT_BOLT_PORT)); diff --git a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java index 3a2df1f7d0c..b291e2b075e 100644 --- a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java +++ b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java @@ -20,7 +20,7 @@ public class Neo4jContainerJUnitIntegrationTest { @ClassRule - public static Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4"); + public static Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4"); @Test public void shouldStart() { diff --git a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java index de5420afd88..9fcbf2d5f1c 100644 --- a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java +++ b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java @@ -30,7 +30,7 @@ public void shouldDisableAuthentication() { try ( // spotless:off // withoutAuthentication { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") .withoutAuthentication() // } // spotless:on @@ -47,7 +47,7 @@ public void shouldDisableAuthentication() { public void shouldCopyDatabase() { try ( // copyDatabase { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:3.5.30") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:3.5.30") .withDatabase(MountableFile.forClasspathResource("/test-graph.db")) // } ) { @@ -71,7 +71,8 @@ public void shouldFailOnCopyDatabaseForDefaultNeo4j4Image() { public void shouldFailOnCopyDatabaseForCustomNeo4j4Image() { assertThatIllegalArgumentException() .isThrownBy(() -> { - new Neo4jContainer<>("neo4j:4.4.1").withDatabase(MountableFile.forClasspathResource("/test-graph.db")); + new Neo4jContainer<>("library/neo4j:4.4.1") + .withDatabase(MountableFile.forClasspathResource("/test-graph.db")); }) .withMessage("Copying database folder is not supported for Neo4j instances with version 4.0 or higher."); } @@ -80,7 +81,8 @@ public void shouldFailOnCopyDatabaseForCustomNeo4j4Image() { public void shouldFailOnCopyDatabaseForCustomNonSemverNeo4j4Image() { assertThatIllegalArgumentException() .isThrownBy(() -> { - new Neo4jContainer<>("neo4j:latest").withDatabase(MountableFile.forClasspathResource("/test-graph.db")); + new Neo4jContainer<>("library/neo4j:latest") + .withDatabase(MountableFile.forClasspathResource("/test-graph.db")); }) .withMessage("Copying database folder is not supported for Neo4j instances with version 4.0 or higher."); } @@ -89,7 +91,7 @@ public void shouldFailOnCopyDatabaseForCustomNonSemverNeo4j4Image() { public void shouldCopyPlugins() { try ( // registerPluginsPath { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") .withPlugins(MountableFile.forClasspathResource("/custom-plugins")) // } ) { @@ -104,7 +106,7 @@ public void shouldCopyPlugins() { public void shouldCopyPlugin() { try ( // registerPluginsJar { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") .withPlugins(MountableFile.forClasspathResource("/custom-plugins/hello-world.jar")) // } ) { @@ -129,7 +131,7 @@ public void shouldCheckEnterpriseLicense() { String expectedImageName = "neo4j:4.4-enterprise"; assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> new Neo4jContainer<>("neo4j:4.4").withEnterpriseEdition()) + .isThrownBy(() -> new Neo4jContainer<>("library/neo4j:4.4").withEnterpriseEdition()) .withMessageContaining("The image " + expectedImageName + " requires you to accept a license agreement."); } @@ -139,7 +141,7 @@ public void shouldRunEnterprise() { try ( // enterpriseEdition { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") .withEnterpriseEdition() // } .withAdminPassword("Picard123") @@ -159,7 +161,7 @@ public void shouldRunEnterprise() { @Test public void shouldAddConfigToEnvironment() { // neo4jConfiguration { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") .withNeo4jConfig("dbms.security.procedures.unrestricted", "apoc.*,algo.*") .withNeo4jConfig("dbms.tx_log.rotation.size", "42M"); // } @@ -172,7 +174,8 @@ public void shouldAddConfigToEnvironment() { @Test public void shouldConfigureSingleLabsPlugin() { try ( - Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4").withLabsPlugins(Neo4jLabsPlugin.APOC) + Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") + .withLabsPlugins(Neo4jLabsPlugin.APOC) ) { // needs to get called explicitly for setup neo4jContainer.configure(); @@ -185,7 +188,7 @@ public void shouldConfigureSingleLabsPlugin() { public void shouldConfigureMultipleLabsPlugins() { try ( // configureLabsPlugins { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") .withLabsPlugins(Neo4jLabsPlugin.APOC, Neo4jLabsPlugin.BLOOM); // } ) { @@ -199,7 +202,7 @@ public void shouldConfigureMultipleLabsPlugins() { @Test public void shouldConfigureSingleLabsPluginWithString() { - try (Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4").withLabsPlugins("myApoc")) { + try (Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4").withLabsPlugins("myApoc")) { // needs to get called explicitly for setup neo4jContainer.configure(); @@ -210,7 +213,8 @@ public void shouldConfigureSingleLabsPluginWithString() { @Test public void shouldConfigureMultipleLabsPluginsWithString() { try ( - Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4").withLabsPlugins("myApoc", "myBloom") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") + .withLabsPlugins("myApoc", "myBloom") ) { // needs to get called explicitly for setup neo4jContainer.configure(); diff --git a/modules/nginx/src/main/java/org/testcontainers/containers/NginxContainer.java b/modules/nginx/src/main/java/org/testcontainers/containers/NginxContainer.java index 1bf951af7c8..d114478294d 100644 --- a/modules/nginx/src/main/java/org/testcontainers/containers/NginxContainer.java +++ b/modules/nginx/src/main/java/org/testcontainers/containers/NginxContainer.java @@ -19,6 +19,8 @@ public class NginxContainer> private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("nginx"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/nginx"); + private static final String DEFAULT_TAG = "1.9.4"; /** @@ -35,7 +37,7 @@ public NginxContainer(String dockerImageName) { public NginxContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); addExposedPort(NGINX_DEFAULT_PORT); setCommand("nginx", "-g", "daemon off;"); diff --git a/modules/nginx/src/test/java/org/testcontainers/junit/SimpleNginxTest.java b/modules/nginx/src/test/java/org/testcontainers/junit/SimpleNginxTest.java index d338ebf180b..75fca66e17f 100644 --- a/modules/nginx/src/test/java/org/testcontainers/junit/SimpleNginxTest.java +++ b/modules/nginx/src/test/java/org/testcontainers/junit/SimpleNginxTest.java @@ -20,7 +20,7 @@ */ public class SimpleNginxTest { - private static final DockerImageName NGINX_IMAGE = DockerImageName.parse("nginx:1.9.4"); + private static final DockerImageName NGINX_IMAGE = DockerImageName.parse("library/nginx:1.9.4"); private static String tmpDirectory = System.getProperty("user.home") + "/.tmp-test-container"; diff --git a/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java b/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java index 60207350f67..f0e6e637790 100644 --- a/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java +++ b/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java @@ -28,6 +28,8 @@ public class OrientDBContainer extends GenericContainer { private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("orientdb"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/orientdb"); + private static final String DEFAULT_TAG = "3.0.24-tp3"; private static final String DEFAULT_USERNAME = "admin"; @@ -66,7 +68,7 @@ public OrientDBContainer(@NonNull String dockerImageName) { public OrientDBContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); serverPassword = DEFAULT_SERVER_PASSWORD; databaseName = DEFAULT_DATABASE_NAME; diff --git a/modules/orientdb/src/test/java/org/testcontainers/containers/OrientDBContainerTest.java b/modules/orientdb/src/test/java/org/testcontainers/containers/OrientDBContainerTest.java index afd7bcee246..ba41090d650 100644 --- a/modules/orientdb/src/test/java/org/testcontainers/containers/OrientDBContainerTest.java +++ b/modules/orientdb/src/test/java/org/testcontainers/containers/OrientDBContainerTest.java @@ -12,7 +12,7 @@ */ public class OrientDBContainerTest { - private static final DockerImageName ORIENTDB_IMAGE = DockerImageName.parse("orientdb:3.2.0-tp3"); + private static final DockerImageName ORIENTDB_IMAGE = DockerImageName.parse("library/orientdb:3.2.0-tp3"); @Test public void shouldReturnTheSameSession() { diff --git a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java index d3ff65ee351..fd154ce2e57 100644 --- a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java +++ b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java @@ -21,6 +21,8 @@ public class PostgreSQLContainer> extends private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("postgres"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/postgres"); + public static final Integer POSTGRESQL_PORT = 5432; static final String DEFAULT_USER = "test"; @@ -49,7 +51,7 @@ public PostgreSQLContainer(final String dockerImageName) { public PostgreSQLContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); this.waitStrategy = new LogMessageWaitStrategy() diff --git a/modules/postgresql/src/test/java/org/testcontainers/PostgreSQLTestImages.java b/modules/postgresql/src/test/java/org/testcontainers/PostgreSQLTestImages.java index 8be01053570..cb31cc6a8c2 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/PostgreSQLTestImages.java +++ b/modules/postgresql/src/test/java/org/testcontainers/PostgreSQLTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface PostgreSQLTestImages { - DockerImageName POSTGRES_TEST_IMAGE = DockerImageName.parse("postgres:9.6.12"); + DockerImageName POSTGRES_TEST_IMAGE = DockerImageName.parse("library/postgres:9.6.12"); } diff --git a/modules/rabbitmq/src/main/java/org/testcontainers/containers/RabbitMQContainer.java b/modules/rabbitmq/src/main/java/org/testcontainers/containers/RabbitMQContainer.java index c13dfdf1a24..62b9bf6c8f6 100644 --- a/modules/rabbitmq/src/main/java/org/testcontainers/containers/RabbitMQContainer.java +++ b/modules/rabbitmq/src/main/java/org/testcontainers/containers/RabbitMQContainer.java @@ -28,6 +28,8 @@ public class RabbitMQContainer extends GenericContainer { */ private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("rabbitmq"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/rabbitmq"); + private static final String DEFAULT_TAG = "3.7.25-management-alpine"; private static final int DEFAULT_AMQP_PORT = 5672; @@ -64,7 +66,7 @@ public RabbitMQContainer(String dockerImageName) { public RabbitMQContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); addExposedPorts(DEFAULT_AMQP_PORT, DEFAULT_AMQPS_PORT, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT); diff --git a/modules/rabbitmq/src/test/java/org/testcontainers/containers/RabbitMQTestImages.java b/modules/rabbitmq/src/test/java/org/testcontainers/containers/RabbitMQTestImages.java index 0898cbdb350..efd25950a7d 100644 --- a/modules/rabbitmq/src/test/java/org/testcontainers/containers/RabbitMQTestImages.java +++ b/modules/rabbitmq/src/test/java/org/testcontainers/containers/RabbitMQTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface RabbitMQTestImages { - DockerImageName RABBITMQ_IMAGE = DockerImageName.parse("rabbitmq:3.7.25-management-alpine"); + DockerImageName RABBITMQ_IMAGE = DockerImageName.parse("library/rabbitmq:3.7.25-management-alpine"); } diff --git a/modules/solr/src/main/java/org/testcontainers/containers/SolrContainer.java b/modules/solr/src/main/java/org/testcontainers/containers/SolrContainer.java index 5161bce2738..470680df3c1 100644 --- a/modules/solr/src/main/java/org/testcontainers/containers/SolrContainer.java +++ b/modules/solr/src/main/java/org/testcontainers/containers/SolrContainer.java @@ -19,6 +19,8 @@ public class SolrContainer extends GenericContainer { private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("solr"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/solr"); + @Deprecated public static final String IMAGE = DEFAULT_IMAGE_NAME.getUnversionedPart(); @@ -48,7 +50,7 @@ public SolrContainer(final String dockerImageName) { public SolrContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); this.waitStrategy = new LogMessageWaitStrategy() diff --git a/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java b/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java index 94a02acf579..f33bfe40089 100644 --- a/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java +++ b/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java @@ -17,7 +17,7 @@ */ public class SolrContainerTest { - private static final DockerImageName SOLR_IMAGE = DockerImageName.parse("solr:8.3.0"); + private static final DockerImageName SOLR_IMAGE = DockerImageName.parse("library/solr:8.3.0"); private SolrClient client = null; diff --git a/modules/vault/src/main/java/org/testcontainers/vault/VaultContainer.java b/modules/vault/src/main/java/org/testcontainers/vault/VaultContainer.java index 4c44668d565..0fdb6a8580f 100644 --- a/modules/vault/src/main/java/org/testcontainers/vault/VaultContainer.java +++ b/modules/vault/src/main/java/org/testcontainers/vault/VaultContainer.java @@ -26,6 +26,8 @@ public class VaultContainer> extends GenericCo private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("vault"); + private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/vault"); + private static final String DEFAULT_TAG = "1.1.3"; private static final int VAULT_PORT = 8200; @@ -50,7 +52,7 @@ public VaultContainer(String dockerImageName) { public VaultContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); // Use the vault healthcheck endpoint to check for readiness, per https://www.vaultproject.io/api/system/health.html setWaitStrategy(Wait.forHttp("/v1/sys/health").forStatusCode(200)); diff --git a/modules/vault/src/test/java/org/testcontainers/vault/VaultClientTest.java b/modules/vault/src/test/java/org/testcontainers/vault/VaultClientTest.java index eebf73a5e62..b9db0bfa64c 100644 --- a/modules/vault/src/test/java/org/testcontainers/vault/VaultClientTest.java +++ b/modules/vault/src/test/java/org/testcontainers/vault/VaultClientTest.java @@ -17,7 +17,9 @@ public class VaultClientTest { @Test public void writeAndReadMultipleValues() throws VaultException { - try (VaultContainer vaultContainer = new VaultContainer<>("vault:1.1.3").withVaultToken(VAULT_TOKEN)) { + try ( + VaultContainer vaultContainer = new VaultContainer<>("library/vault:1.1.3").withVaultToken(VAULT_TOKEN) + ) { vaultContainer.start(); final VaultConfig config = new VaultConfig() diff --git a/modules/vault/src/test/java/org/testcontainers/vault/VaultContainerTest.java b/modules/vault/src/test/java/org/testcontainers/vault/VaultContainerTest.java index 608d8bbb8a7..f0ba947f7b5 100644 --- a/modules/vault/src/test/java/org/testcontainers/vault/VaultContainerTest.java +++ b/modules/vault/src/test/java/org/testcontainers/vault/VaultContainerTest.java @@ -24,7 +24,7 @@ public class VaultContainerTest { @ClassRule // vaultContainer { - public static VaultContainer vaultContainer = new VaultContainer<>("vault:1.6.1") + public static VaultContainer vaultContainer = new VaultContainer<>("library/vault:1.6.1") .withVaultToken(VAULT_TOKEN) .withSecretInVault("secret/testing1", "top_secret=password123") .withSecretInVault( From 5117c55f2eb25e642c5961bab88879c1c2529d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Mon, 14 Nov 2022 15:27:04 -0800 Subject: [PATCH 02/10] Use `library/` as part of JDBC Container Providers --- .../org/testcontainers/containers/MariaDBContainerProvider.java | 2 +- .../org/testcontainers/containers/MySQLContainerProvider.java | 2 +- .../testcontainers/containers/PostgreSQLContainerProvider.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java index 6697255ca79..a808ba2b312 100644 --- a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java +++ b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java @@ -24,7 +24,7 @@ public JdbcDatabaseContainer newInstance() { @Override public JdbcDatabaseContainer newInstance(String tag) { - return new MariaDBContainer(DockerImageName.parse(MariaDBContainer.IMAGE).withTag(tag)); + return new MariaDBContainer(DockerImageName.parse("library/mariadb").withTag(tag)); } @Override diff --git a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java index 621001d7b57..3989753dce2 100644 --- a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java +++ b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java @@ -25,7 +25,7 @@ public JdbcDatabaseContainer newInstance() { @Override public JdbcDatabaseContainer newInstance(String tag) { if (tag != null) { - return new MySQLContainer(DockerImageName.parse(MySQLContainer.IMAGE).withTag(tag)); + return new MySQLContainer(DockerImageName.parse("library/mysql").withTag(tag)); } else { return newInstance(); } diff --git a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java index de98885510c..a0bb4d1d0f9 100644 --- a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java +++ b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java @@ -24,7 +24,7 @@ public JdbcDatabaseContainer newInstance() { @Override public JdbcDatabaseContainer newInstance(String tag) { - return new PostgreSQLContainer(DockerImageName.parse(PostgreSQLContainer.IMAGE).withTag(tag)); + return new PostgreSQLContainer(DockerImageName.parse("library/postgres").withTag(tag)); } @Override From 7b01bf38f5d764c2746978ba29b70266493e2292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Tue, 15 Nov 2022 08:52:50 -0800 Subject: [PATCH 03/10] fix --- .../org/testcontainers/utility/DockerImageName.java | 12 ++++++++++-- .../utility/DockerImageNameCompatibilityTest.java | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/testcontainers/utility/DockerImageName.java b/core/src/main/java/org/testcontainers/utility/DockerImageName.java index 9fca02aad6f..3f0f14faf30 100644 --- a/core/src/main/java/org/testcontainers/utility/DockerImageName.java +++ b/core/src/main/java/org/testcontainers/utility/DockerImageName.java @@ -11,6 +11,7 @@ import org.testcontainers.utility.Versioning.Sha256Versioning; import org.testcontainers.utility.Versioning.TagVersioning; +import java.util.Arrays; import java.util.regex.Pattern; @EqualsAndHashCode(exclude = { "rawName", "compatibleSubstituteFor" }) @@ -26,6 +27,8 @@ public final class DockerImageName { private static final Pattern REPO_NAME = Pattern.compile(REPO_NAME_PART + "(/" + REPO_NAME_PART + ")*"); + private static final String LIBRARY_PREFIX = "library/"; + private final String rawName; @With @@ -258,13 +261,18 @@ public void assertCompatibleWith(DockerImageName... anyOthers) { throw new IllegalArgumentException("anyOthers parameter must be non-empty"); } - for (DockerImageName anyOther : anyOthers) { + String imageWithoutLibraryPrefix = this.repository.replace(LIBRARY_PREFIX, ""); + DockerImageName[] dockerImageNames = Arrays.copyOf(anyOthers, anyOthers.length + 1); + dockerImageNames[dockerImageNames.length - 1] = + DockerImageName.parse(LIBRARY_PREFIX + imageWithoutLibraryPrefix); + + for (DockerImageName anyOther : dockerImageNames) { if (this.isCompatibleWith(anyOther)) { return; } } - final DockerImageName exampleOther = anyOthers[0]; + final DockerImageName exampleOther = dockerImageNames[0]; throw new IllegalStateException( String.format( diff --git a/core/src/test/java/org/testcontainers/utility/DockerImageNameCompatibilityTest.java b/core/src/test/java/org/testcontainers/utility/DockerImageNameCompatibilityTest.java index 0bb1b3f75ca..dd17981111f 100644 --- a/core/src/test/java/org/testcontainers/utility/DockerImageNameCompatibilityTest.java +++ b/core/src/test/java/org/testcontainers/utility/DockerImageNameCompatibilityTest.java @@ -91,6 +91,12 @@ public void testAssertMethodAcceptsCompatible() { subject.assertCompatibleWith(DockerImageName.parse("bar")); } + @Test + public void testAssertMethodAcceptsCompatibleLibraryPrefix() { + DockerImageName subject = DockerImageName.parse("library/foo"); + subject.assertCompatibleWith(DockerImageName.parse("foo")); + } + @Test public void testAssertMethodRejectsIncompatible() { DockerImageName subject = DockerImageName.parse("foo"); From 9fff1801f4e85a97804e444e1907b92e1677e7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Tue, 15 Nov 2022 21:29:49 -0800 Subject: [PATCH 04/10] Revert "Use `library/` as part of JDBC Container Providers" This reverts commit 5117c55f2eb25e642c5961bab88879c1c2529d40. --- .../org/testcontainers/containers/MariaDBContainerProvider.java | 2 +- .../org/testcontainers/containers/MySQLContainerProvider.java | 2 +- .../testcontainers/containers/PostgreSQLContainerProvider.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java index a808ba2b312..6697255ca79 100644 --- a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java +++ b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainerProvider.java @@ -24,7 +24,7 @@ public JdbcDatabaseContainer newInstance() { @Override public JdbcDatabaseContainer newInstance(String tag) { - return new MariaDBContainer(DockerImageName.parse("library/mariadb").withTag(tag)); + return new MariaDBContainer(DockerImageName.parse(MariaDBContainer.IMAGE).withTag(tag)); } @Override diff --git a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java index 3989753dce2..621001d7b57 100644 --- a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java +++ b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainerProvider.java @@ -25,7 +25,7 @@ public JdbcDatabaseContainer newInstance() { @Override public JdbcDatabaseContainer newInstance(String tag) { if (tag != null) { - return new MySQLContainer(DockerImageName.parse("library/mysql").withTag(tag)); + return new MySQLContainer(DockerImageName.parse(MySQLContainer.IMAGE).withTag(tag)); } else { return newInstance(); } diff --git a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java index a0bb4d1d0f9..de98885510c 100644 --- a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java +++ b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainerProvider.java @@ -24,7 +24,7 @@ public JdbcDatabaseContainer newInstance() { @Override public JdbcDatabaseContainer newInstance(String tag) { - return new PostgreSQLContainer(DockerImageName.parse("library/postgres").withTag(tag)); + return new PostgreSQLContainer(DockerImageName.parse(PostgreSQLContainer.IMAGE).withTag(tag)); } @Override From 65cf2337dddf105c42ca72ccab0ae950ea0090d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Tue, 15 Nov 2022 21:30:15 -0800 Subject: [PATCH 05/10] Revert "Accept image names with `library/` prefix as a valid substitute" This reverts commit 9f694e16a647f4db0adf74fecbaac50812d16de9. --- .../testcontainers/DockerClientFactory.java | 2 +- .../containers/CassandraContainer.java | 4 +-- .../containers/CassandraContainerTest.java | 4 +-- .../containers/CassandraDriver3Test.java | 2 +- .../containers/CassandraDriver4Test.java | 2 +- .../consul/ConsulContainer.java | 4 +-- .../consul/ConsulTestImages.java | 2 +- .../containers/InfluxDBContainer.java | 4 +-- .../containers/InfluxDBTestImages.java | 2 +- .../containers/MariaDBContainer.java | 4 +-- .../org/testcontainers/MariaDBTestImages.java | 2 +- .../containers/MongoDBContainer.java | 4 +-- .../containers/MongoDBContainerTest.java | 16 +++------- .../containers/MySQLContainer.java | 4 +-- .../org/testcontainers/MySQLTestImages.java | 6 ++-- .../containers/Neo4jContainer.java | 8 ++--- .../Neo4jContainerJUnitIntegrationTest.java | 2 +- .../containers/Neo4jContainerTest.java | 30 ++++++++----------- .../containers/NginxContainer.java | 4 +-- .../testcontainers/junit/SimpleNginxTest.java | 2 +- .../containers/OrientDBContainer.java | 4 +-- .../containers/OrientDBContainerTest.java | 2 +- .../containers/PostgreSQLContainer.java | 4 +-- .../testcontainers/PostgreSQLTestImages.java | 2 +- .../containers/RabbitMQContainer.java | 4 +-- .../containers/RabbitMQTestImages.java | 2 +- .../containers/SolrContainer.java | 4 +-- .../containers/SolrContainerTest.java | 2 +- .../testcontainers/vault/VaultContainer.java | 4 +-- .../testcontainers/vault/VaultClientTest.java | 4 +-- .../vault/VaultContainerTest.java | 2 +- 31 files changed, 50 insertions(+), 92 deletions(-) diff --git a/core/src/main/java/org/testcontainers/DockerClientFactory.java b/core/src/main/java/org/testcontainers/DockerClientFactory.java index d2b3cbdf166..73bf24e511c 100644 --- a/core/src/main/java/org/testcontainers/DockerClientFactory.java +++ b/core/src/main/java/org/testcontainers/DockerClientFactory.java @@ -75,7 +75,7 @@ static Map markerLabels() { return Collections.unmodifiableMap(labels); } - private static final DockerImageName TINY_IMAGE = DockerImageName.parse("library/alpine:3.16"); + private static final DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.16"); private static DockerClientFactory instance; diff --git a/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java b/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java index 6bbfcd411ae..a12ac03f18d 100644 --- a/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java +++ b/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java @@ -29,8 +29,6 @@ public class CassandraContainer> extends G private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("cassandra"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/cassandra"); - private static final String DEFAULT_TAG = "3.11.2"; @Deprecated @@ -66,7 +64,7 @@ public CassandraContainer(String dockerImageName) { public CassandraContainer(DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); addExposedPort(CQL_PORT); this.enableJmxReporting = false; diff --git a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraContainerTest.java b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraContainerTest.java index a03be3388ba..d8f21fc3068 100644 --- a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraContainerTest.java +++ b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraContainerTest.java @@ -17,7 +17,7 @@ @Slf4j public class CassandraContainerTest { - private static final DockerImageName CASSANDRA_IMAGE = DockerImageName.parse("library/cassandra:3.11.2"); + private static final DockerImageName CASSANDRA_IMAGE = DockerImageName.parse("cassandra:3.11.2"); private static final String TEST_CLUSTER_NAME_IN_CONF = "Test Cluster Integration Test"; @@ -88,7 +88,7 @@ public void testInitScript() { public void testInitScriptWithLegacyCassandra() { try ( CassandraContainer cassandraContainer = new CassandraContainer<>( - DockerImageName.parse("library/cassandra:2.2.11") + DockerImageName.parse("cassandra:2.2.11") ) .withInitScript("initial.cql") ) { diff --git a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver3Test.java b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver3Test.java index 5f10bab03d0..502f2ca8e67 100644 --- a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver3Test.java +++ b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver3Test.java @@ -11,7 +11,7 @@ public class CassandraDriver3Test { @Rule - public CassandraContainer cassandra = new CassandraContainer<>("library/cassandra:3.11.2"); + public CassandraContainer cassandra = new CassandraContainer<>("cassandra:3.11.2"); @Test public void testCassandraGetContactPoint() { diff --git a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver4Test.java b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver4Test.java index 0223fcbdf10..a4fb8c87b8e 100644 --- a/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver4Test.java +++ b/modules/cassandra/src/test/java/org/testcontainers/containers/CassandraDriver4Test.java @@ -11,7 +11,7 @@ public class CassandraDriver4Test { @Rule - public CassandraContainer cassandra = new CassandraContainer<>("library/cassandra:3.11.2"); + public CassandraContainer cassandra = new CassandraContainer<>("cassandra:3.11.2"); @Test public void testCassandraGetContactPoint() { diff --git a/modules/consul/src/main/java/org/testcontainers/consul/ConsulContainer.java b/modules/consul/src/main/java/org/testcontainers/consul/ConsulContainer.java index e11982cb31a..0c9d2607072 100644 --- a/modules/consul/src/main/java/org/testcontainers/consul/ConsulContainer.java +++ b/modules/consul/src/main/java/org/testcontainers/consul/ConsulContainer.java @@ -19,8 +19,6 @@ public class ConsulContainer extends GenericContainer { private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("consul"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/consul"); - private static final int CONSUL_HTTP_PORT = 8500; private static final int CONSUL_GRPC_PORT = 8502; @@ -35,7 +33,7 @@ public ConsulContainer(String dockerImageName) { public ConsulContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); // Use the status leader endpoint to verify if consul is running. setWaitStrategy(Wait.forHttp("/v1/status/leader").forPort(CONSUL_HTTP_PORT).forStatusCode(200)); diff --git a/modules/consul/src/test/java/org/testcontainers/consul/ConsulTestImages.java b/modules/consul/src/test/java/org/testcontainers/consul/ConsulTestImages.java index 00b2a33d957..de2b9702066 100644 --- a/modules/consul/src/test/java/org/testcontainers/consul/ConsulTestImages.java +++ b/modules/consul/src/test/java/org/testcontainers/consul/ConsulTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface ConsulTestImages { - DockerImageName CONSUL_IMAGE = DockerImageName.parse("library/consul:1.10.12"); + DockerImageName CONSUL_IMAGE = DockerImageName.parse("consul:1.10.12"); } diff --git a/modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainer.java b/modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainer.java index cb813a192fe..40eea721b57 100644 --- a/modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainer.java +++ b/modules/influxdb/src/main/java/org/testcontainers/containers/InfluxDBContainer.java @@ -18,8 +18,6 @@ public class InfluxDBContainer> extends Gen private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("influxdb"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/influxdb"); - private static final String DEFAULT_TAG = "1.4.3"; @Deprecated @@ -55,7 +53,7 @@ public InfluxDBContainer(final String version) { public InfluxDBContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); waitStrategy = new WaitAllStrategy() diff --git a/modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBTestImages.java b/modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBTestImages.java index 2fae44363ca..a0e2d31bbdf 100644 --- a/modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBTestImages.java +++ b/modules/influxdb/src/test/java/org/testcontainers/containers/InfluxDBTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface InfluxDBTestImages { - DockerImageName INFLUXDB_TEST_IMAGE = DockerImageName.parse("library/influxdb:1.4.3"); + DockerImageName INFLUXDB_TEST_IMAGE = DockerImageName.parse("influxdb:1.4.3"); } diff --git a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java index 09e804f0f26..b0944a6d3c0 100644 --- a/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java +++ b/modules/mariadb/src/main/java/org/testcontainers/containers/MariaDBContainer.java @@ -14,8 +14,6 @@ public class MariaDBContainer> extends JdbcD private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("mariadb"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/mariadb"); - @Deprecated public static final String DEFAULT_TAG = "10.3.6"; @@ -54,7 +52,7 @@ public MariaDBContainer(String dockerImageName) { public MariaDBContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); addExposedPort(MARIADB_PORT); } diff --git a/modules/mariadb/src/test/java/org/testcontainers/MariaDBTestImages.java b/modules/mariadb/src/test/java/org/testcontainers/MariaDBTestImages.java index aa7af19cca9..7d18f2f8365 100644 --- a/modules/mariadb/src/test/java/org/testcontainers/MariaDBTestImages.java +++ b/modules/mariadb/src/test/java/org/testcontainers/MariaDBTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface MariaDBTestImages { - DockerImageName MARIADB_IMAGE = DockerImageName.parse("library/mariadb:10.3.6"); + DockerImageName MARIADB_IMAGE = DockerImageName.parse("mariadb:10.3.6"); } diff --git a/modules/mongodb/src/main/java/org/testcontainers/containers/MongoDBContainer.java b/modules/mongodb/src/main/java/org/testcontainers/containers/MongoDBContainer.java index c1d3dd3a353..ae93e4121d3 100644 --- a/modules/mongodb/src/main/java/org/testcontainers/containers/MongoDBContainer.java +++ b/modules/mongodb/src/main/java/org/testcontainers/containers/MongoDBContainer.java @@ -19,8 +19,6 @@ public class MongoDBContainer extends GenericContainer { private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("mongo"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/mongo"); - private static final String DEFAULT_TAG = "4.0.10"; private static final int CONTAINER_EXIT_CODE_OK = 0; @@ -45,7 +43,7 @@ public MongoDBContainer(@NonNull final String dockerImageName) { public MongoDBContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); withExposedPorts(MONGODB_INTERNAL_PORT); withCommand("--replSet", "docker-rs"); diff --git a/modules/mongodb/src/test/java/org/testcontainers/containers/MongoDBContainerTest.java b/modules/mongodb/src/test/java/org/testcontainers/containers/MongoDBContainerTest.java index f0103fab0ad..dd59420f937 100644 --- a/modules/mongodb/src/test/java/org/testcontainers/containers/MongoDBContainerTest.java +++ b/modules/mongodb/src/test/java/org/testcontainers/containers/MongoDBContainerTest.java @@ -24,9 +24,7 @@ public class MongoDBContainerTest { public void shouldExecuteTransactions() { try ( // creatingMongoDBContainer { - final MongoDBContainer mongoDBContainer = new MongoDBContainer( - DockerImageName.parse("library/mongo:4.0.10") - ) + final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10")) // } ) { // startingMongoDBContainer { @@ -90,20 +88,14 @@ private void executeTx(MongoDBContainer mongoDBContainer) { @Test public void supportsMongoDB_4_4() { - try ( - final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("library/mongo:4.4")) - ) { + try (final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.4"))) { mongoDBContainer.start(); } } @Test public void shouldTestDatabaseName() { - try ( - final MongoDBContainer mongoDBContainer = new MongoDBContainer( - DockerImageName.parse("library/mongo:4.0.10") - ) - ) { + try (final MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10"))) { mongoDBContainer.start(); final String databaseName = "my-db"; assertThat(mongoDBContainer.getReplicaSetUrl(databaseName)).endsWith(databaseName); @@ -112,7 +104,7 @@ public void shouldTestDatabaseName() { @Test public void supportsMongoDB_6() { - try (final MongoDBContainer mongoDBContainer = new MongoDBContainer("library/mongo:6.0.1")) { + try (final MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:6.0.1")) { mongoDBContainer.start(); executeTx(mongoDBContainer); } diff --git a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java index 3b56469e619..316e709995c 100644 --- a/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java +++ b/modules/mysql/src/main/java/org/testcontainers/containers/MySQLContainer.java @@ -14,8 +14,6 @@ public class MySQLContainer> extends JdbcDatab private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("mysql"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/mysql"); - @Deprecated public static final String DEFAULT_TAG = "5.7.34"; @@ -52,7 +50,7 @@ public MySQLContainer(String dockerImageName) { public MySQLContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); addExposedPort(MYSQL_PORT); } diff --git a/modules/mysql/src/test/java/org/testcontainers/MySQLTestImages.java b/modules/mysql/src/test/java/org/testcontainers/MySQLTestImages.java index 9320e6bb9f7..81de83be0b9 100644 --- a/modules/mysql/src/test/java/org/testcontainers/MySQLTestImages.java +++ b/modules/mysql/src/test/java/org/testcontainers/MySQLTestImages.java @@ -4,9 +4,9 @@ public class MySQLTestImages { - public static final DockerImageName MYSQL_56_IMAGE = DockerImageName.parse("library/mysql:5.6.51"); + public static final DockerImageName MYSQL_56_IMAGE = DockerImageName.parse("mysql:5.6.51"); - public static final DockerImageName MYSQL_57_IMAGE = DockerImageName.parse("library/mysql:5.7.34"); + public static final DockerImageName MYSQL_57_IMAGE = DockerImageName.parse("mysql:5.7.34"); - public static final DockerImageName MYSQL_80_IMAGE = DockerImageName.parse("library/mysql:8.0.24"); + public static final DockerImageName MYSQL_80_IMAGE = DockerImageName.parse("mysql:8.0.24"); } diff --git a/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java b/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java index 70aed7af05a..94b4263fe8c 100644 --- a/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java +++ b/modules/neo4j/src/main/java/org/testcontainers/containers/Neo4jContainer.java @@ -31,8 +31,6 @@ public class Neo4jContainer> extends GenericContaine */ private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("neo4j"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/neo4j"); - /** * The default tag (version) to use. */ @@ -93,11 +91,9 @@ public Neo4jContainer(String dockerImageName) { */ public Neo4jContainer(final DockerImageName dockerImageName) { super(dockerImageName); - this.standardImage = - dockerImageName.getUnversionedPart().equals(DEFAULT_IMAGE_NAME.getUnversionedPart()) || - dockerImageName.getUnversionedPart().equals(LIBRARY_IMAGE_NAME.getUnversionedPart()); + this.standardImage = dockerImageName.getUnversionedPart().equals(DEFAULT_IMAGE_NAME.getUnversionedPart()); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); WaitStrategy waitForBolt = new LogMessageWaitStrategy() .withRegEx(String.format(".*Bolt enabled on .*:%d\\.\n", DEFAULT_BOLT_PORT)); diff --git a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java index b291e2b075e..3a2df1f7d0c 100644 --- a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java +++ b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerJUnitIntegrationTest.java @@ -20,7 +20,7 @@ public class Neo4jContainerJUnitIntegrationTest { @ClassRule - public static Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4"); + public static Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4"); @Test public void shouldStart() { diff --git a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java index 9fcbf2d5f1c..de5420afd88 100644 --- a/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java +++ b/modules/neo4j/src/test/java/org/testcontainers/containers/Neo4jContainerTest.java @@ -30,7 +30,7 @@ public void shouldDisableAuthentication() { try ( // spotless:off // withoutAuthentication { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") .withoutAuthentication() // } // spotless:on @@ -47,7 +47,7 @@ public void shouldDisableAuthentication() { public void shouldCopyDatabase() { try ( // copyDatabase { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:3.5.30") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:3.5.30") .withDatabase(MountableFile.forClasspathResource("/test-graph.db")) // } ) { @@ -71,8 +71,7 @@ public void shouldFailOnCopyDatabaseForDefaultNeo4j4Image() { public void shouldFailOnCopyDatabaseForCustomNeo4j4Image() { assertThatIllegalArgumentException() .isThrownBy(() -> { - new Neo4jContainer<>("library/neo4j:4.4.1") - .withDatabase(MountableFile.forClasspathResource("/test-graph.db")); + new Neo4jContainer<>("neo4j:4.4.1").withDatabase(MountableFile.forClasspathResource("/test-graph.db")); }) .withMessage("Copying database folder is not supported for Neo4j instances with version 4.0 or higher."); } @@ -81,8 +80,7 @@ public void shouldFailOnCopyDatabaseForCustomNeo4j4Image() { public void shouldFailOnCopyDatabaseForCustomNonSemverNeo4j4Image() { assertThatIllegalArgumentException() .isThrownBy(() -> { - new Neo4jContainer<>("library/neo4j:latest") - .withDatabase(MountableFile.forClasspathResource("/test-graph.db")); + new Neo4jContainer<>("neo4j:latest").withDatabase(MountableFile.forClasspathResource("/test-graph.db")); }) .withMessage("Copying database folder is not supported for Neo4j instances with version 4.0 or higher."); } @@ -91,7 +89,7 @@ public void shouldFailOnCopyDatabaseForCustomNonSemverNeo4j4Image() { public void shouldCopyPlugins() { try ( // registerPluginsPath { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") .withPlugins(MountableFile.forClasspathResource("/custom-plugins")) // } ) { @@ -106,7 +104,7 @@ public void shouldCopyPlugins() { public void shouldCopyPlugin() { try ( // registerPluginsJar { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") .withPlugins(MountableFile.forClasspathResource("/custom-plugins/hello-world.jar")) // } ) { @@ -131,7 +129,7 @@ public void shouldCheckEnterpriseLicense() { String expectedImageName = "neo4j:4.4-enterprise"; assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> new Neo4jContainer<>("library/neo4j:4.4").withEnterpriseEdition()) + .isThrownBy(() -> new Neo4jContainer<>("neo4j:4.4").withEnterpriseEdition()) .withMessageContaining("The image " + expectedImageName + " requires you to accept a license agreement."); } @@ -141,7 +139,7 @@ public void shouldRunEnterprise() { try ( // enterpriseEdition { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") .withEnterpriseEdition() // } .withAdminPassword("Picard123") @@ -161,7 +159,7 @@ public void shouldRunEnterprise() { @Test public void shouldAddConfigToEnvironment() { // neo4jConfiguration { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") .withNeo4jConfig("dbms.security.procedures.unrestricted", "apoc.*,algo.*") .withNeo4jConfig("dbms.tx_log.rotation.size", "42M"); // } @@ -174,8 +172,7 @@ public void shouldAddConfigToEnvironment() { @Test public void shouldConfigureSingleLabsPlugin() { try ( - Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") - .withLabsPlugins(Neo4jLabsPlugin.APOC) + Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4").withLabsPlugins(Neo4jLabsPlugin.APOC) ) { // needs to get called explicitly for setup neo4jContainer.configure(); @@ -188,7 +185,7 @@ public void shouldConfigureSingleLabsPlugin() { public void shouldConfigureMultipleLabsPlugins() { try ( // configureLabsPlugins { - Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4") .withLabsPlugins(Neo4jLabsPlugin.APOC, Neo4jLabsPlugin.BLOOM); // } ) { @@ -202,7 +199,7 @@ public void shouldConfigureMultipleLabsPlugins() { @Test public void shouldConfigureSingleLabsPluginWithString() { - try (Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4").withLabsPlugins("myApoc")) { + try (Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4").withLabsPlugins("myApoc")) { // needs to get called explicitly for setup neo4jContainer.configure(); @@ -213,8 +210,7 @@ public void shouldConfigureSingleLabsPluginWithString() { @Test public void shouldConfigureMultipleLabsPluginsWithString() { try ( - Neo4jContainer neo4jContainer = new Neo4jContainer<>("library/neo4j:4.4") - .withLabsPlugins("myApoc", "myBloom") + Neo4jContainer neo4jContainer = new Neo4jContainer<>("neo4j:4.4").withLabsPlugins("myApoc", "myBloom") ) { // needs to get called explicitly for setup neo4jContainer.configure(); diff --git a/modules/nginx/src/main/java/org/testcontainers/containers/NginxContainer.java b/modules/nginx/src/main/java/org/testcontainers/containers/NginxContainer.java index d114478294d..1bf951af7c8 100644 --- a/modules/nginx/src/main/java/org/testcontainers/containers/NginxContainer.java +++ b/modules/nginx/src/main/java/org/testcontainers/containers/NginxContainer.java @@ -19,8 +19,6 @@ public class NginxContainer> private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("nginx"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/nginx"); - private static final String DEFAULT_TAG = "1.9.4"; /** @@ -37,7 +35,7 @@ public NginxContainer(String dockerImageName) { public NginxContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); addExposedPort(NGINX_DEFAULT_PORT); setCommand("nginx", "-g", "daemon off;"); diff --git a/modules/nginx/src/test/java/org/testcontainers/junit/SimpleNginxTest.java b/modules/nginx/src/test/java/org/testcontainers/junit/SimpleNginxTest.java index 75fca66e17f..d338ebf180b 100644 --- a/modules/nginx/src/test/java/org/testcontainers/junit/SimpleNginxTest.java +++ b/modules/nginx/src/test/java/org/testcontainers/junit/SimpleNginxTest.java @@ -20,7 +20,7 @@ */ public class SimpleNginxTest { - private static final DockerImageName NGINX_IMAGE = DockerImageName.parse("library/nginx:1.9.4"); + private static final DockerImageName NGINX_IMAGE = DockerImageName.parse("nginx:1.9.4"); private static String tmpDirectory = System.getProperty("user.home") + "/.tmp-test-container"; diff --git a/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java b/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java index f0e6e637790..60207350f67 100644 --- a/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java +++ b/modules/orientdb/src/main/java/org/testcontainers/containers/OrientDBContainer.java @@ -28,8 +28,6 @@ public class OrientDBContainer extends GenericContainer { private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("orientdb"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/orientdb"); - private static final String DEFAULT_TAG = "3.0.24-tp3"; private static final String DEFAULT_USERNAME = "admin"; @@ -68,7 +66,7 @@ public OrientDBContainer(@NonNull String dockerImageName) { public OrientDBContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); serverPassword = DEFAULT_SERVER_PASSWORD; databaseName = DEFAULT_DATABASE_NAME; diff --git a/modules/orientdb/src/test/java/org/testcontainers/containers/OrientDBContainerTest.java b/modules/orientdb/src/test/java/org/testcontainers/containers/OrientDBContainerTest.java index ba41090d650..afd7bcee246 100644 --- a/modules/orientdb/src/test/java/org/testcontainers/containers/OrientDBContainerTest.java +++ b/modules/orientdb/src/test/java/org/testcontainers/containers/OrientDBContainerTest.java @@ -12,7 +12,7 @@ */ public class OrientDBContainerTest { - private static final DockerImageName ORIENTDB_IMAGE = DockerImageName.parse("library/orientdb:3.2.0-tp3"); + private static final DockerImageName ORIENTDB_IMAGE = DockerImageName.parse("orientdb:3.2.0-tp3"); @Test public void shouldReturnTheSameSession() { diff --git a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java index fd154ce2e57..d3ff65ee351 100644 --- a/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java +++ b/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java @@ -21,8 +21,6 @@ public class PostgreSQLContainer> extends private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("postgres"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/postgres"); - public static final Integer POSTGRESQL_PORT = 5432; static final String DEFAULT_USER = "test"; @@ -51,7 +49,7 @@ public PostgreSQLContainer(final String dockerImageName) { public PostgreSQLContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); this.waitStrategy = new LogMessageWaitStrategy() diff --git a/modules/postgresql/src/test/java/org/testcontainers/PostgreSQLTestImages.java b/modules/postgresql/src/test/java/org/testcontainers/PostgreSQLTestImages.java index cb31cc6a8c2..8be01053570 100644 --- a/modules/postgresql/src/test/java/org/testcontainers/PostgreSQLTestImages.java +++ b/modules/postgresql/src/test/java/org/testcontainers/PostgreSQLTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface PostgreSQLTestImages { - DockerImageName POSTGRES_TEST_IMAGE = DockerImageName.parse("library/postgres:9.6.12"); + DockerImageName POSTGRES_TEST_IMAGE = DockerImageName.parse("postgres:9.6.12"); } diff --git a/modules/rabbitmq/src/main/java/org/testcontainers/containers/RabbitMQContainer.java b/modules/rabbitmq/src/main/java/org/testcontainers/containers/RabbitMQContainer.java index 62b9bf6c8f6..c13dfdf1a24 100644 --- a/modules/rabbitmq/src/main/java/org/testcontainers/containers/RabbitMQContainer.java +++ b/modules/rabbitmq/src/main/java/org/testcontainers/containers/RabbitMQContainer.java @@ -28,8 +28,6 @@ public class RabbitMQContainer extends GenericContainer { */ private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("rabbitmq"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/rabbitmq"); - private static final String DEFAULT_TAG = "3.7.25-management-alpine"; private static final int DEFAULT_AMQP_PORT = 5672; @@ -66,7 +64,7 @@ public RabbitMQContainer(String dockerImageName) { public RabbitMQContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); addExposedPorts(DEFAULT_AMQP_PORT, DEFAULT_AMQPS_PORT, DEFAULT_HTTP_PORT, DEFAULT_HTTPS_PORT); diff --git a/modules/rabbitmq/src/test/java/org/testcontainers/containers/RabbitMQTestImages.java b/modules/rabbitmq/src/test/java/org/testcontainers/containers/RabbitMQTestImages.java index efd25950a7d..0898cbdb350 100644 --- a/modules/rabbitmq/src/test/java/org/testcontainers/containers/RabbitMQTestImages.java +++ b/modules/rabbitmq/src/test/java/org/testcontainers/containers/RabbitMQTestImages.java @@ -3,5 +3,5 @@ import org.testcontainers.utility.DockerImageName; public interface RabbitMQTestImages { - DockerImageName RABBITMQ_IMAGE = DockerImageName.parse("library/rabbitmq:3.7.25-management-alpine"); + DockerImageName RABBITMQ_IMAGE = DockerImageName.parse("rabbitmq:3.7.25-management-alpine"); } diff --git a/modules/solr/src/main/java/org/testcontainers/containers/SolrContainer.java b/modules/solr/src/main/java/org/testcontainers/containers/SolrContainer.java index 470680df3c1..5161bce2738 100644 --- a/modules/solr/src/main/java/org/testcontainers/containers/SolrContainer.java +++ b/modules/solr/src/main/java/org/testcontainers/containers/SolrContainer.java @@ -19,8 +19,6 @@ public class SolrContainer extends GenericContainer { private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("solr"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/solr"); - @Deprecated public static final String IMAGE = DEFAULT_IMAGE_NAME.getUnversionedPart(); @@ -50,7 +48,7 @@ public SolrContainer(final String dockerImageName) { public SolrContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); this.waitStrategy = new LogMessageWaitStrategy() diff --git a/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java b/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java index f33bfe40089..94a02acf579 100644 --- a/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java +++ b/modules/solr/src/test/java/org/testcontainers/containers/SolrContainerTest.java @@ -17,7 +17,7 @@ */ public class SolrContainerTest { - private static final DockerImageName SOLR_IMAGE = DockerImageName.parse("library/solr:8.3.0"); + private static final DockerImageName SOLR_IMAGE = DockerImageName.parse("solr:8.3.0"); private SolrClient client = null; diff --git a/modules/vault/src/main/java/org/testcontainers/vault/VaultContainer.java b/modules/vault/src/main/java/org/testcontainers/vault/VaultContainer.java index 0fdb6a8580f..4c44668d565 100644 --- a/modules/vault/src/main/java/org/testcontainers/vault/VaultContainer.java +++ b/modules/vault/src/main/java/org/testcontainers/vault/VaultContainer.java @@ -26,8 +26,6 @@ public class VaultContainer> extends GenericCo private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("vault"); - private static final DockerImageName LIBRARY_IMAGE_NAME = DockerImageName.parse("library/vault"); - private static final String DEFAULT_TAG = "1.1.3"; private static final int VAULT_PORT = 8200; @@ -52,7 +50,7 @@ public VaultContainer(String dockerImageName) { public VaultContainer(final DockerImageName dockerImageName) { super(dockerImageName); - dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, LIBRARY_IMAGE_NAME); + dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); // Use the vault healthcheck endpoint to check for readiness, per https://www.vaultproject.io/api/system/health.html setWaitStrategy(Wait.forHttp("/v1/sys/health").forStatusCode(200)); diff --git a/modules/vault/src/test/java/org/testcontainers/vault/VaultClientTest.java b/modules/vault/src/test/java/org/testcontainers/vault/VaultClientTest.java index b9db0bfa64c..eebf73a5e62 100644 --- a/modules/vault/src/test/java/org/testcontainers/vault/VaultClientTest.java +++ b/modules/vault/src/test/java/org/testcontainers/vault/VaultClientTest.java @@ -17,9 +17,7 @@ public class VaultClientTest { @Test public void writeAndReadMultipleValues() throws VaultException { - try ( - VaultContainer vaultContainer = new VaultContainer<>("library/vault:1.1.3").withVaultToken(VAULT_TOKEN) - ) { + try (VaultContainer vaultContainer = new VaultContainer<>("vault:1.1.3").withVaultToken(VAULT_TOKEN)) { vaultContainer.start(); final VaultConfig config = new VaultConfig() diff --git a/modules/vault/src/test/java/org/testcontainers/vault/VaultContainerTest.java b/modules/vault/src/test/java/org/testcontainers/vault/VaultContainerTest.java index f0ba947f7b5..608d8bbb8a7 100644 --- a/modules/vault/src/test/java/org/testcontainers/vault/VaultContainerTest.java +++ b/modules/vault/src/test/java/org/testcontainers/vault/VaultContainerTest.java @@ -24,7 +24,7 @@ public class VaultContainerTest { @ClassRule // vaultContainer { - public static VaultContainer vaultContainer = new VaultContainer<>("library/vault:1.6.1") + public static VaultContainer vaultContainer = new VaultContainer<>("vault:1.6.1") .withVaultToken(VAULT_TOKEN) .withSecretInVault("secret/testing1", "top_secret=password123") .withSecretInVault( From 9c803a3c61476be6a19c741d259ee805adec26fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Tue, 15 Nov 2022 21:36:38 -0800 Subject: [PATCH 06/10] add prefix to alpine --- core/src/main/java/org/testcontainers/DockerClientFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/testcontainers/DockerClientFactory.java b/core/src/main/java/org/testcontainers/DockerClientFactory.java index 73bf24e511c..d2b3cbdf166 100644 --- a/core/src/main/java/org/testcontainers/DockerClientFactory.java +++ b/core/src/main/java/org/testcontainers/DockerClientFactory.java @@ -75,7 +75,7 @@ static Map markerLabels() { return Collections.unmodifiableMap(labels); } - private static final DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.16"); + private static final DockerImageName TINY_IMAGE = DockerImageName.parse("library/alpine:3.16"); private static DockerClientFactory instance; From 6a008efe271b5a6d16724d2ad7dabff9748ce89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 17 Nov 2022 11:17:52 -0800 Subject: [PATCH 07/10] Improve logic --- .../java/org/testcontainers/utility/DockerImageName.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/testcontainers/utility/DockerImageName.java b/core/src/main/java/org/testcontainers/utility/DockerImageName.java index 3f0f14faf30..01280f0287e 100644 --- a/core/src/main/java/org/testcontainers/utility/DockerImageName.java +++ b/core/src/main/java/org/testcontainers/utility/DockerImageName.java @@ -261,10 +261,13 @@ public void assertCompatibleWith(DockerImageName... anyOthers) { throw new IllegalArgumentException("anyOthers parameter must be non-empty"); } - String imageWithoutLibraryPrefix = this.repository.replace(LIBRARY_PREFIX, ""); DockerImageName[] dockerImageNames = Arrays.copyOf(anyOthers, anyOthers.length + 1); - dockerImageNames[dockerImageNames.length - 1] = - DockerImageName.parse(LIBRARY_PREFIX + imageWithoutLibraryPrefix); + if (this.repository.startsWith(LIBRARY_PREFIX)) { + dockerImageNames[dockerImageNames.length - 1] = DockerImageName.parse(this.repository); + } else { + String imageWithLibraryPrefix = LIBRARY_PREFIX + this.repository; + dockerImageNames[dockerImageNames.length - 1] = DockerImageName.parse(imageWithLibraryPrefix); + } for (DockerImageName anyOther : dockerImageNames) { if (this.isCompatibleWith(anyOther)) { From 2fef0b090060471ef300b70f01966f9c467e187f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Fri, 2 Dec 2022 18:03:49 -0600 Subject: [PATCH 08/10] move logic to isCompatibleWith --- .../utility/DockerImageName.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/org/testcontainers/utility/DockerImageName.java b/core/src/main/java/org/testcontainers/utility/DockerImageName.java index 01280f0287e..4b416ed8d17 100644 --- a/core/src/main/java/org/testcontainers/utility/DockerImageName.java +++ b/core/src/main/java/org/testcontainers/utility/DockerImageName.java @@ -11,7 +11,6 @@ import org.testcontainers.utility.Versioning.Sha256Versioning; import org.testcontainers.utility.Versioning.TagVersioning; -import java.util.Arrays; import java.util.regex.Pattern; @EqualsAndHashCode(exclude = { "rawName", "compatibleSubstituteFor" }) @@ -235,7 +234,14 @@ public DockerImageName asCompatibleSubstituteFor(DockerImageName otherImageName) */ public boolean isCompatibleWith(DockerImageName other) { // is this image already the same or equivalent? - if (other.equals(this)) { + String finalImageName; + if (this.repository.startsWith(LIBRARY_PREFIX)) { + finalImageName = this.repository; + } else { + finalImageName = LIBRARY_PREFIX + this.repository; + } + DockerImageName imageWithLibraryPrefix = DockerImageName.parse(finalImageName); + if (other.equals(this) || imageWithLibraryPrefix.equals(this)) { return true; } @@ -261,21 +267,13 @@ public void assertCompatibleWith(DockerImageName... anyOthers) { throw new IllegalArgumentException("anyOthers parameter must be non-empty"); } - DockerImageName[] dockerImageNames = Arrays.copyOf(anyOthers, anyOthers.length + 1); - if (this.repository.startsWith(LIBRARY_PREFIX)) { - dockerImageNames[dockerImageNames.length - 1] = DockerImageName.parse(this.repository); - } else { - String imageWithLibraryPrefix = LIBRARY_PREFIX + this.repository; - dockerImageNames[dockerImageNames.length - 1] = DockerImageName.parse(imageWithLibraryPrefix); - } - - for (DockerImageName anyOther : dockerImageNames) { + for (DockerImageName anyOther : anyOthers) { if (this.isCompatibleWith(anyOther)) { return; } } - final DockerImageName exampleOther = dockerImageNames[0]; + final DockerImageName exampleOther = anyOthers[0]; throw new IllegalStateException( String.format( From 6d240ba9b9276a61eb16fe4f4dfec8e796c94a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez=20Gonzales?= Date: Tue, 13 Dec 2022 11:25:41 -0600 Subject: [PATCH 09/10] Update core/src/main/java/org/testcontainers/DockerClientFactory.java Co-authored-by: Kevin Wittek --- core/src/main/java/org/testcontainers/DockerClientFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/testcontainers/DockerClientFactory.java b/core/src/main/java/org/testcontainers/DockerClientFactory.java index d2b3cbdf166..73bf24e511c 100644 --- a/core/src/main/java/org/testcontainers/DockerClientFactory.java +++ b/core/src/main/java/org/testcontainers/DockerClientFactory.java @@ -75,7 +75,7 @@ static Map markerLabels() { return Collections.unmodifiableMap(labels); } - private static final DockerImageName TINY_IMAGE = DockerImageName.parse("library/alpine:3.16"); + private static final DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.16"); private static DockerClientFactory instance; From e0807e7e134b82f1e4529dafec616a8dce1a637c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Tue, 13 Dec 2022 11:30:43 -0600 Subject: [PATCH 10/10] Fix comment --- .../main/java/org/testcontainers/utility/DockerImageName.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/testcontainers/utility/DockerImageName.java b/core/src/main/java/org/testcontainers/utility/DockerImageName.java index 4b416ed8d17..e3a35855bf8 100644 --- a/core/src/main/java/org/testcontainers/utility/DockerImageName.java +++ b/core/src/main/java/org/testcontainers/utility/DockerImageName.java @@ -233,7 +233,7 @@ public DockerImageName asCompatibleSubstituteFor(DockerImageName otherImageName) * @return whether this image has declared compatibility. */ public boolean isCompatibleWith(DockerImageName other) { - // is this image already the same or equivalent? + // Make sure we always compare against a version of the image name containing the LIBRARY_PREFIX String finalImageName; if (this.repository.startsWith(LIBRARY_PREFIX)) { finalImageName = this.repository;