Skip to content

Commit cfd6b12

Browse files
robin-wayvetillahoffmann
authored andcommitted
use container_host_ip in KAFKA_ADVERTISED_LISTENERS
1 parent 6fb1a68 commit cfd6b12

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

testcontainers/kafka.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ def _connect(self):
4343
raise KafkaError("Unable to connect with kafka container!")
4444

4545
def tc_start(self):
46+
host = self.get_container_host_ip()
4647
port = self.get_exposed_port(self.port_to_expose)
47-
listeners = 'PLAINTEXT://localhost:{},BROKER://$(hostname -i):9092'.format(port)
48+
listeners = 'PLAINTEXT://{}:{},BROKER://$(hostname -i):9092'.format(host, port)
4849
data = (
4950
dedent(
5051
"""

0 commit comments

Comments
 (0)