Skip to content

Commit

Permalink
Fix advertised broker ip
Browse files Browse the repository at this point in the history
port 9092 is not exposed to the host, so we can not connect to it via host ip, but need to use the broker container ip
  • Loading branch information
khartld committed Dec 8, 2023
1 parent e983907 commit 96f033c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/kafka/kafka.go
Expand Up @@ -72,12 +72,17 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
return err
}

ip, err := c.ContainerIP(ctx)
if err != nil {
return err
}

port, err := c.MappedPort(ctx, publicPort)
if err != nil {
return err
}

scriptContent := fmt.Sprintf(starterScriptContent, host, port.Int(), host)
scriptContent := fmt.Sprintf(starterScriptContent, host, port.Int(), ip)

return c.CopyToContainer(ctx, []byte(scriptContent), starterScript, 0o755)
},
Expand Down

0 comments on commit 96f033c

Please sign in to comment.