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 Jan 12, 2024
1 parent 1934eb2 commit ba9ada0
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 ba9ada0

Please sign in to comment.