title: How to resolve org.testcontainers.containers.ContainerFetchException on Spring Boot?
body: <p>I am working on developing a few integration tests for my spring boot application. I am using <code>testcontainers</code> in order to create a <code>MongoDB</code> docker image. My code so far:</p>
  <p><strong>ContainerListener.java</strong> class:</p>
  <p>public class ContainerListener implements TestListener {</p>
  <pre><code>@ClassRule
  public static Network sharedNetwork = Network.newNetwork();
  
  @ClassRule
  public static GenericContainer mongoDBContainer = new GenericContainer(&quot;mongo:3.2.4&quot;).withNetwork(sharedNetwork)
          .withNetworkAliases(&quot;mongo&quot;).withExposedPorts(27017);
  
  public static MockServerContainer mockServerContainer = new MockServerContainer().withNetwork(sharedNetwork)
          .withNetworkAliases(&quot;mockserver&quot;).withExposedPorts(1080);
  
  public static int getMockPort() {
      return mockServerContainer.getMappedPort(1080);
  }
  
  public static int getMongoPort() {
      return mongoDBContainer.getMappedPort(27017);
  }
  
  public static void runAll() {
      List.of(mongoDBContainer, mockServerContainer).forEach(e -&gt; e.start());
  }
  
  public static void stopAll() {
      List.of(mongoDBContainer, mockServerContainer).forEach(e -&gt; e.stop());
  }
  </code></pre>
  <p>}</p>
  <p>And <strong>SomeControllerIntegrationTest.java</strong> class:</p>
  <pre><code>import io.restassured.RestAssured;
  import io.restassured.parsing.Parser;
  import org.junit.jupiter.api.AfterAll;
  import org.junit.jupiter.api.BeforeAll;
  import org.junit.jupiter.api.Test;
  
  import static io.restassured.RestAssured.given;
  
  public class RatingControllerIntegrationTest {
  
      @BeforeAll
      public static void setuo() {
          ContainerListener.runAll();
  
      }
  
      @AfterAll
      public static void tearDown() {
          ContainerListener.stopAll();
      }
  
      @Test
      public void detailsTest() throws Exception {
          RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
          RestAssured.defaultParser = Parser.JSON;
  
          given().log().all().when().get(&quot;http://localhost:8080/actuator/info/&quot;).then().log().all()
                  .statusCode(200);
      }
  
  }
  </code></pre>
  <p>Despite that after running the tests I get the following error:</p>
  <pre><code>org.testcontainers.containers.ContainerLaunchException: Container startup failed
  
  Caused by: org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=mongo:3.2.4, imagePullPolicy=DefaultPullPolicy())
      at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1279)
      at org.testcontainers.containers.GenericContainer.logger(GenericContainer.java:613)
      at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:320)
      ... 58 more
  Caused by: java.lang.IllegalStateException: Can not connect to Ryuk at localhost:32770
      at org.testcontainers.utility.ResourceReaper.start(ResourceReaper.java:176)
      at org.testcontainers.DockerClientFactory.client(DockerClientFactory.java:168)
      at org.testcontainers.LazyDockerClient.getDockerClient(LazyDockerClient.java:14)
      at org.testcontainers.LazyDockerClient.listImagesCmd(LazyDockerClient.java:12)
      at org.testcontainers.images.LocalImagesCache.maybeInitCache(LocalImagesCache.java:68)
      at org.testcontainers.images.LocalImagesCache.get(LocalImagesCache.java:32)
      at org.testcontainers.images.AbstractImagePullPolicy.shouldPull(AbstractImagePullPolicy.java:18)
      at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:59)
      at org.testcontainers.images.RemoteDockerImage.resolve(RemoteDockerImage.java:26)
      at org.testcontainers.utility.LazyFuture.getResolvedValue(LazyFuture.java:20)
      at org.testcontainers.utility.LazyFuture.get(LazyFuture.java:27)
      at org.testcontainers.containers.GenericContainer.getDockerImageName(GenericContainer.java:1277)
      ... 60 more
  </code></pre>