title: TestContainers cannot connect to opened ports
body: <p>In one of my tests using testcontainers, the container failed to start and the log is:</p>
  <pre><code>  [ERROR] 17:31:38,814 [Test worker] 1.1]. - Could not start container
       org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [49154, 49155, 49156, 49157] should be listening)
          at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:90) ~[testcontainers-1.16.2.jar:?]
  </code></pre>
  <p>However, when I notice it took so long to start up the container, I looked at the container status:</p>
  <pre><code>CONTAINER ID   IMAGE                       COMMAND                  CREATED         STATUS         PORTS                                                                                                                     NAMES
  a9b52c87cf48   corda-four-nodes:0.1.1      &quot;/bin/bash runnodes.…&quot;   2 minutes ago   Up 2 minutes   10030-10033/tcp, 0.0.0.0:49157-&gt;10010/tcp, 0.0.0.0:49156-&gt;10011/tcp, 0.0.0.0:49155-&gt;10012/tcp, 0.0.0.0:49154-&gt;10013/tcp   nice_merkle
  f1de539585cd   testcontainers/ryuk:0.3.3   &quot;/app&quot;                   2 minutes ago   Up 2 minutes   0.0.0.0:49153-&gt;8080/tcp                                                                                                   testcontainers-ryuk-69c9e72d-040b-4625-a82e-dbaf7d0a1cec
  </code></pre>
  <p>So clearly ports <code>10010-10013</code> have been mapped to <code>49154-49157</code>, and using <code>netcat</code>, these ports are reachable, but why did the error occur and the container cannot be started?</p>
  <p>Container definition:</p>
  <pre class="lang-java prettyprint-override"><code>    @Container
      @SuppressWarnings(&quot;rawtypes&quot;)
      public static GenericContainer network = new GenericContainer(DockerImageName.parse(IMAGE_NAME))
              .withFileSystemBind(getCordappPath(), &quot;/nodes/Notary/cordapps&quot;, BindMode.READ_WRITE)
              .withFileSystemBind(getCordappPath(), &quot;/nodes/PartyA/cordapps&quot;, BindMode.READ_WRITE)
              .withFileSystemBind(getCordappPath(), &quot;/nodes/PartyB/cordapps&quot;, BindMode.READ_WRITE)
              .withFileSystemBind(getCordappPath(), &quot;/nodes/PartyC/cordapps&quot;, BindMode.READ_WRITE)
              .withExposedPorts(10010, 10011, 10012, 10013)
              .withStartupTimeout(Duration.ofSeconds(180));
  </code></pre>
  <p>(The binding works correctly)</p>