question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timed out waiting for container port to open (localhost ports: [] should be listening)

See original GitHub issue

Hi Team, TestContainers is unable to start Cassandra image in linux servers, however same code works fine on docker 20.10.7 in Mac.

I tried changing to use GenericContainer instead of CassandraContainer but same error. I am using TestContainers version 1.16.0 Appreciate your help here.

//dockerImage = cassandra:latest
//Cassandra_port = 9042

GenericContainer<?> cassandraContainer = new CassandraContainer<>(dockerImageName);
////GenericContainer<?> cassandraContainer = new GenericContainer<>(dockerImageName).withExposedPorts(CASSANDRA_PORT);

cassandraContainer.withExposedPorts(CASSANDRA_PORT);
////cassandraContainer.setPortBindings(List.of(String.format("%d:%d", CASSANDRA_PORT, CASSANDRA_PORT)));
cassandraContainer.start();
cassandraContainer.waitingFor(Wait.forLogMessage("Startup Complete",1));

Error -

Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed [15:27:42] [Step 6/8] Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception [15:27:42] [Step 6/8] Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container [15:27:42] [Step 6/8] Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [49329] should be listening) [15:27:42] [Step 6/8]

Docker#version

Client: Docker Engine - Community
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:58:10 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:56:35 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
jxblumcommented, Aug 11, 2021

I recently ran into a similar issue in our Jenkins environment.

The SBDG project forks a Cassandra based Testcontainer (in the configuration of the test, here, then here), where the build itself is running inside a Docker container (see here) on Jenkins (builds).

I am not certain whether the SBDG main Jenkins build is accessible to the outside world, but essentially, the build started failing after our sysadmin(s) upgraded to the following configuration on the Jenkins CI servers (worker nodes):

  • docker-ce (5:20.10.8~3-0~ubuntu-bionic)
  • containerd.io (1.4.9-1)

I tried adding the configuration (commit) suggested by @bsideup above and that worked!

It seems the root cause of the issue is related to the Docker engine upgrade:

From:

20.10.6 (20.10.6~3-0~ubuntu-bionic_amd64)

To:

20.10.8 (docker-ce (5:20.10.8~3-0~ubuntu-bionic)

I experienced this issue with Testcontainers 1.15.3 (see here).

Hope this additional information helps.

Testcontainers (and the community of people) have been absolutely invaluable.

Thank you!

2reactions
bsideupcommented, Aug 12, 2021

@jxblum thank you John for this detailed analysis! My guess would be that the memory config is what made it work, as otherwise Cassandra tried to allocate all available memory. We will release a version of Testcontainers with these optimizations soon. Meanwhile, please let us know if the problem returns with a new Docker update or something like that 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Timed out waiting for container port to open (localhost ports
It seems that you do not have docker running. Try sudo systemctl status docker to check if the daemon is running and if...
Read more >
Timed out waiting for container port to open #4125 - GitHub
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [49187] ...
Read more >
Waiting for containers to start or be ready - Testcontainers
Wait Strategies. Ordinarily Testcontainers will wait for up to 60 seconds for the container's first mapped network port to start listening. This simple...
Read more >
Testcontainers timed out waiting for container port to open ...
[Solved]-Testcontainers timed out waiting for container port to open, with Elasticsearch docker image-docker ... Although the former should redirect to the later.
Read more >
org.testcontainers.containers.ContainerLaunchException java ...
throw new ContainerLaunchException(String.format( "Timed out waiting for URL ... () + " ports: " + externalLivenessCheckPorts + " should be listening)"); } }....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found