Docker中的Cassandra无法从外部连接 [英] Cassandra in Docker cant connect from outside
问题描述
我是Docker和Cassandar一词的新手。我在从计算机上连接Docker中的Cassandra时遇到问题。
Hi I am new to word Docker and Cassandar. I have a problem connecting to Cassandra in Docker from my computer.
我运行了容器Cassandra,看到暴露的ips和端口是192.168.99.100:9042。(第一张图片) )在docker中,我什至可以看到测试群集正在运行,但是当我想通过NoSQL Manager for Cassandra连接到Cassandra时,总是出现错误消息尝试查询的主机均不可用。
I run container Cassandra and I see that exposed ips and ports are 192.168.99.100:9042.(first image) In docker I can even see that "Test cluster" is running but when I want to connect to Cassandra by NoSQL Manager for Cassandra there is always error message "None of the hosts tried for query are available".
谢谢。
推荐答案
您不公开端口。 9042是docker端口。
运行docker映像时,必须记住以下几点:
you don't expose a port. 9042 is docker port. When you run the docker image you must remember this:
docker run -p 9042:9042 image-name
第一个9042定义外部世界连接的端口号,第二个9042定义将绑定的docker端口号外部端口号为9042。
first 9042 define the port number where outer world will connect and 2nd 9042 defines docker's port number which will be bound with outer port number 9042.
这篇关于Docker中的Cassandra无法从外部连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!