我在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"
}
]
docker info节点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
docker info节点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
答案 0 :(得分:1)
原因是因为当我使用docker swarm join命令时,docker使用我的内部IP自动加入。
我必须照做
docker swarm join --token ...... --advertise-addr。
贷记https://github.com/docker/swarmkit/issues/1429#issuecomment-329325410