当 运行 在 Docker Ubuntu 图像上执行 Confluent 启动命令时 Kafka 无法启动(名称或服务未知)

Kafka failed to start when running Confluent start command on Docker Ubuntu image (Name or service not known)

我正尝试在 运行ning docker 图像上为 ubuntu 启动 Confluent。这是命令的错误:

root@linuxkit-025000000001:/# /my/dir/path/confluent-4.0.0/bin/confluent start 

这是输出日志:

Starting zookeeper

zookeeper is [UP]

Starting kafka

|Kafka failed to start

kafka is [DOWN]

Cannot start Schema Registry, Kafka Server is not running. Check your deployment

我尝试使用以下方式启动 Kafka:

# cd confluent-4.0.0
# ./bin/kafka-server-start ./etc/kafka/server.properties

这是重要的错误日志:

Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer) java.net.UnknownHostException: linuxkit-025000000001: linuxkit-025000000001: Name or service not known

运行 Kafka 的解决方案是什么?

这里有一个解决方案的提示: https://github.com/ModernMT/MMT/issues/276

我应该将主机名添加到主机中。对于我自己的解决方案,我为 127.0.0.1 添加了一个新行 linuxkit-025000000001 因为它可以从主机名命令获得:

 # hostname 

然后我尝试编辑 /etc/hosts

# (printf "127.0.0.1  " ; hostname ) >> /etc/hosts

现在Confluent可以启动成功了!