telnetを使用して、あるDockerコンテナから別のDockerコンテナへの接続を確立しようとしていますが、「telnet:リモートホストに接続できません:接続が拒否されました」というエラーが常に表示されます。
これまでに実行したコマンド:
docker run -dit --name nA --net mynet -p 8081:80 -p 1001:443 test_image:1.0 bash
docker run -dit --name nB --net mynet -p 8080:80 -p 1000:443 test_image:1.0 bash
これがdockerinspectmynetからの出力です
"Containers": {
"1df3f3821710b3f8103fe79e338d709a93baf301dafc015bb5f1e162bca206de": {
"Name": "nB",
"EndpointID": "bf7cbc2e60ddb99cd3b8bd416b066787840ced6de74eb1961b4f9663a28fdd80",
"MacAddress": "02:42:ac:13:00:03",
"IPv4Address": "172.19.0.3/16",
"IPv6Address": ""
},
"7aea617e121eda0884ae7ce46e1534800af2d30822f3899f69c4165a40c1370d": {
"Name": "nA",
"EndpointID": "7a60026517ff0b1b337a5af9ccf8d7dc9c896606196bcb1bafe537e6fddaa8dc",
"MacAddress": "02:42:ac:13:00:02",
"IPv4Address": "172.19.0.2/16",
"IPv6Address": ""
}
},
pingは完全に機能します。
root@1df3f3821710:/# ping nA
PING nA (172.19.0.2) 56(84) bytes of data.
64 bytes from nA.mynet (172.19.0.2): icmp_seq=1 ttl=64 time=0.141 ms
64 bytes from nA.mynet (172.19.0.2): icmp_seq=2 ttl=64 time=0.261 ms
次に、公開されているポートを使用して、あるコンテナから別のコンテナに接続しようとしています。
root@1df3f3821710:/# telnet nA 8081
Trying 172.19.0.2...
telnet: Unable to connect to remote host: Connection refused
root@1df3f3821710:/# telnet nA 1001
Trying 172.19.0.2...
telnet: Unable to connect to remote host: Connection refused
root@1df3f3821710:/# telnet nA 80
Trying 172.19.0.2...
telnet: Unable to connect to remote host: Connection refused
root@1df3f3821710:/# telnet nA 443
Trying 172.19.0.2...
telnet: Unable to connect to remote host: Connection refused
他のコンテナから接続する場合も同様です。
root@7aea617e121e:/# telnet nB 8080
Trying 172.19.0.3...
telnet: Unable to connect to remote host: Connection refused
root@7aea617e121e:/# telnet nB 80
Trying 172.19.0.3...
telnet: Unable to connect to remote host: Connection refused
root@7aea617e121e:/# telnet nB 1000
Trying 172.19.0.3...
telnet: Unable to connect to remote host: Connection refused
root@7aea617e121e:/# telnet nB 443
Trying 172.19.0.3...
telnet: Unable to connect to remote host: Connection refused
ここでの問題は何ですか?
Dockerバージョン:17.09.0 OS:MacおよびWindows
公開されたポートはホストから利用でき、コンテナ間の通信には使用されません。
イメージに定義されているコマンドをオーバーライドし、代わりにbashを開始するため、コンテナーで実行されている唯一のプロセスとコンテナー内のアプリケーションがまったく開始されません。
あなたがやろうとしていたことは次のとおりです
docker run -d --name nA --net mynet -p 8081:80 -p 1001:443 test_image:1.0
docker run -d --name nB --net mynet -p 8080:80 -p 1000:443 test_image:1.0
次に、実行中のコンテナに接続します
$ docker exec -it nA bash
$ docker exec -it nB bash
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加