docker 启动kafka宿主机无法访问

先看我启动命令:

docker run -e TZ="Asia/Shanghai" --privileged -itd -h single.com -p 127.0.0.1:9092:9092 -p 127.0.0.1:2181:2181 -v D:\soft:/var/soft  --name single.com test/kaf:v1 /usr/sbin/init

我这里是给了域名的.然后我外网127.0.0.1:9092连接时总报没响应。最后在host里配:
127.0.0.1 single.com
再把代码里的连接改为:
single.com:9092

其实我也是云看zookeeper里的记录:
bin/zookeeper-shell.sh localhost:2181 <<< "get /brokers/ids/0"
内容如下:
{"listener_security_protocol_map":{"PLAINTEXT":"PLAINTEXT"},"endpoints":["PLAINTEXT://single.com:9092"],"jmx_port":-1,"h
ost":"single.com","timestamp":"1582264923144","port":9092,"version":4}

参考链接:

https://blog.csdn.net/jyxgood/article/details/81131369

你可能感兴趣的:(docker)