title: How to reuse Testcontainers between multiple SpringBootTests?
body: <p>I'm using TestContainers with Spring Boot to run unit tests for repositories like this:</p>
  
  <pre><code>@Testcontainers
  @ExtendWith(SpringExtension.class)
  @ActiveProfiles("itest")
  @SpringBootTest(classes = RouteTestingCheapRouteDetector.class)
  @ContextConfiguration(initializers = AlwaysFailingRouteRepositoryShould.Initializer.class)
  @TestExecutionListeners(listeners = DependencyInjectionTestExecutionListener.class)
  @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
  @Tag("docker")
  @Tag("database")
  class AlwaysFailingRouteRepositoryShould {
  
    @SuppressWarnings("rawtypes")
    @Container
    private static final PostgreSQLContainer database =
        new PostgreSQLContainer("postgres:9.6")
            .withDatabaseName("database")
            .withUsername("postgres")
            .withPassword("postgres");
  </code></pre>
  
  <p>But now I have 14 of these tests and every time a test is run a new instance of Postgres is spun up. Is it possible to reuse the same instance across all tests? The <a href="https://www.testcontainers.org/test_framework_integration/manual_lifecycle_control/" rel="noreferrer">Singleton pattern</a> doesn't help since every test starts a new application.</p>
  
  <p>I've also tried <code>testcontainers.reuse.enable=true</code> in <code>.testcontainers.properties</code> and <code>.withReuse(true)</code>, but that didn't help.</p>