[英]Container-to-container HTTP request within Docker Swarm (1 node): DNS Name does not resolve intermittently
[英]Docker swarm container cannot resolve address of container in another node
我在我的Vm上初始化了一個群集,並以管理員身份將另一個Vm加入到我的群集中。 然后我覆蓋網絡docker network create --attachable --driver overlay my-net
。
然后,我運行了docker stack deploy來部署我的服務。 但是,當我執行一個容器並嘗試從另一個節點nslookup一個容器時。 例如nslookup <container_name>
我有 :
Server: 127.0.0.11
Address: 127.0.0.11#53
** server can't find <container_name>: NXDOMAIN
nslookup可以在同一節點中使用容器。
我想我的DNS在解析另一個節點的地址時不起作用,我想知道為什么。
附加信息:
兩個節點的netstat -l:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:ssh *:* LISTEN
tcp6 0 0 [::]:2377 [::]:* LISTEN
tcp6 0 0 [::]:7946 [::]:* LISTEN
tcp6 0 0 [::]:30283 [::]:* LISTEN
tcp6 0 0 [::]:30284 [::]:* LISTEN
tcp6 0 0 [::]:30285 [::]:* LISTEN
tcp6 0 0 [::]:30289 [::]:* LISTEN
tcp6 0 0 [::]:30290 [::]:* LISTEN
tcp6 0 0 [::]:30291 [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
udp 0 0 *:bootpc *:*
udp 0 0 *:4789 *:*
udp6 768 0 [::]:7946 [::]:*
ufw狀態顯示為非活動。
碼頭工人檢查(部分結果)可能是我的對等IP 10.0.0.5不正確嗎?
"Peers": [
{
"Name": "c7feabf505ba",
"IP": "10.0.0.5"
},
{
"Name": "073e551404e8",
"IP": "137.116.149.79"
}
]
碼頭工人信息節點1:
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 15
Server Version: 18.06.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: ro2p9n7o33darkuylentq1nx0
Is Manager: true
ClusterID: 01q4hei9hzibq3x8m36pzqo8c
Managers: 2
Nodes: 2
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 168.63.239.163
Manager Addresses:
137.116.149.79:2377
168.63.239.163:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-1025-azure
Operating System: Ubuntu 16.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.853GiB
Name: blockcord-staging2
ID: UT5F:4ZFW:4PRT:LGFS:JIV4:3YAD:DK5I:BIYL:FU6P:ZFEB:3OD3:U5EX
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
碼頭工人信息節點2:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 15
Server Version: 18.06.0-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: osmwr2fcrcg8mazopkanf4gr7
Is Manager: true
ClusterID: 01q4hei9hzibq3x8m36pzqo8c
Managers: 2
Nodes: 2
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 10.0.1.6
Manager Addresses:
137.116.149.79:2377
168.63.239.163:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d64c661f1d51c48782c9cec8fda7604785f93587
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.15.0-1025-azure
Operating System: Ubuntu 16.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.885GiB
Name: doc2us-staging
ID: JG7Q:HZBH:7WIF:22GC:PZQQ:EXJC:ZDPT:C2SA:TDRM:XJ4M:KKX4:OAEI
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
原因是因為當我使用docker swarm join命令時,docker使用我的內部IP自動加入。
我要做的就是
docker swarm join --token ...... --advertise-addr。
歸功於https://github.com/docker/swarmkit/issues/1429#issuecomment-329325410
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.