testcontainers / testcontainers/testcontainers-java

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

Open
#4,360 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
8.7k
Forks
1.9k
Avg merge
2d 17h
Merged PRs (30d)
9

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the CassandraContainer failure on Linux with Docker 20.10.7, then compare it with the GenericContainer example. Inspect the container startup output and the reported port-wait timeout. Done means the Linux case has an identified, actionable cause and a confirmed startup result or workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
cassandra, docker, java
Domain
databases, devops, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.