为什么在与同一桥接networking中的其他Docker容器交谈时,我正在进行NAT

嘿家伙,所以我目前正在试验一个洪stream跟踪器服务器和两个使用Docker的客户端。 我的设置是我创build了一个名为torrent-net的自己的networking。

docker network create -d bridge noto-network 

然后,我继续为客户端创build三个容器,一个使用ctorrent,另一个是自定义代码。 第三个容器安装了opentracker服务器。 networkingconfiguration如下:

 Gateway: ip_address: 172.18.0.1/16 Opentracker: ip_address: 172.18.0.2/16 announce_port: 6969 GoCode: ip_address: 172.18.0.3/16 torrent_port: 6881 cTorrent ip_address: 172.18.0.4/16 torrent_port: 2706 

我开始我的追踪器和ctorrent。 当我从我的代码发送一个请求到跟踪器时,我会发回这两个同伴:

 - ip: 172.18.0.1 port: 6881 - ip: 172.18.0.1 port: 2706 

我有两个问题:

  • 所有三个容器都在同一个networking中,所以为什么要互相交谈需要NAT?
  • 作为客户端,我怎么知道这个NAT IP是否代表我? 这是为了避免试图与自己说话。