Have you tired to change ConfluentKafkaContainer by KafkaContainer?
import org.testcontainers.containers.KafkaContainer;
@Container
@ServiceConnection
static KafkaContainer kafka = new KafkaContainer(
DockerImageName.parse("confluentinc/cp-kafka:7.7.0")
);
By switching to the base KafkaContainer, Spring Boot's KafkaContainerConnectionDetailsFactory will execute, read the container's getBootstrapServers() method, and correctly configure the spring.kafka.bootstrap-servers property for you.