当Docker Swarm discovery 为file时,应该怎么创建集群

发布于 2022-09-04 19:13:25 字数 3526 浏览 24 评论 0

manage:192.168.5.5

node:192.168.5.3192.168.5.4

Docker Swarm discovery 为 file://path/to/file

cluster文件内容:

192.168.5.3:2375
192.168.5.4:2375

manage(192.168.5.5) command:
docker run -d -it -h node-m --name=node-m --restart=always -v $(pwd)/cluster:/tmp/cluster -p 3375:3375 swarm manage -H 0.0.0.0:3375 file:///tmp/cluster

node1(192.168.5.3) command:
docker run -d -it -h node-1 --name=node-1 -v $(pwd)/cluster:/tmp/cluster swarm join --addr=192.168.5.3:2375 file:///tmp/cluster

node2(92.168.5.4) command:
docker run -d -it -h node-2 --name=node-2 -v $(pwd)/cluster:/tmp/cluster swarm join --addr=192.168.5.4:2375 file:///tmp/cluster


manage(192.168.5.5) command:

[root@manage opt]# docker run --rm -v $(pwd)/cluster:/tmp/cluster swarm list file:///tmp/cluster                                                                          
192.168.5.3:2375
192.168.5.4:2375
[root@manage opt]# docker -H 0.0.0.0:3375 info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: swarm/1.2.6
Role: primary
Strategy: spread
Filters: health, port, containerslots, dependency, affinity, constraint, whitelist
Nodes: 2
 (unknown): 192.168.5.3:2375
  └ ID: 
  └ Status: Pending
  └ Containers: 0
  └ Reserved CPUs: 0 / 0
  └ Reserved Memory: 0 B / 0 B
  └ Labels: 
  └ Error: Cannot connect to the Docker daemon at tcp://192.168.5.3:2375. Is the docker daemon running?
  └ UpdatedAt: 2017-04-10T19:03:37Z
  └ ServerVersion: 
 (unknown): 192.168.5.4:2375
  └ ID: 
  └ Status: Pending
  └ Containers: 0
  └ Reserved CPUs: 0 / 0
  └ Reserved Memory: 0 B / 0 B
  └ Labels: 
  └ Error: Cannot connect to the Docker daemon at tcp://192.168.5.4:2375. Is the docker daemon running?
  └ UpdatedAt: 2017-04-10T19:03:37Z
  └ ServerVersion: 
Plugins:
 Volume: 
 Network: 
Swarm: 
 NodeID: 
 Is Manager: false
 Node Address: 
Security Options:
Kernel Version: 3.10.0-514.el7.x86_64
Operating System: linux
Architecture: amd64
Number of Docker Hooks: 2
CPUs: 0
Total Memory: 0 B
Name: node-m
Docker Root Dir: 
Debug Mode (client): false
Debug Mode (server): false
WARNING: No kernel memory limit support
Registries: 

manage、node1、node2 ps -a命令结果

[root@manage opt]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
18a246b46399        swarm               "/swarm manage -H 0.0"   3 minutes ago       Up 3 minutes        2375/tcp, 0.0.0.0:3375->3375/tcp   node-m

[root@node1 opt]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
df43c2cbfee0        swarm               "/swarm join --addr=1"   2 minutes ago       Up 2 minutes        2375/tcp            node-1

[root@node2 opt]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
a9b48c6d7be2        swarm               "/swarm join --addr=1"   3 minutes ago       Up 3 minutes        2375/tcp            node-2

其他信息:

swarm version: 1.2.6

docker version: 1.12.6

为什么会出现这样的问题呢"Cannot connect to the Docker daemon at tcp://192.168.5.x:2375. Is the docker daemon running?"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扎心 2022-09-11 19:13:25

如果为file的模式的话 你连join都不用起了, 因为join的功能很简单,就是用作服务发现的。 我在swarm上二次开发自己测试时就用的file,直接起个manager结束。
./swarm -l debug manage --cors -H :4001 file://my_cluster

cat my_cluster
10.1.86.201:2375
10.1.86.202:2375
10.1.86.203:2375
10.1.86.204:2375
10.1.86.205:2375
10.1.86.206:2375
10.1.86.207:2375
10.1.86.208:2375

确保你的docker engine可以通过ip访问, docker -H :4001 info

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文