尝试使用Swarm独立版和docker-compose版本“2”在不同的虚拟机上运行群集应用程序.设置覆盖网络.但是想强制某些容器在特定主机上运行.
在文档中有以下建议,但使用此参数我根本无法启动任何容器:
environment:
- "constraint:node==node-1"
ERROR: for elasticsearch1 Cannot create container for service elasticsearch1: Unable to find a node that satisfies the following conditions
[available container slots]
[node==node-1]
我们应该将主机注册为node-1 node-2 …还是默认完成.
[root@ux-test14 ~]# docker node ls
Error response from daemon: 404 page not found
[root@ux-test14 ~]# docker run swarm list
[root@ux-test14 ~]#
[root@ux-test14 ~]# docker info
Containers: 8
Running: 6
Paused: 0
Stopped: 2
Images: 8
Server Version: swarm/1.2.5
Role: primary
Strategy: spread
Filters: health,port,containerslots,dependency,affinity,constraint
Nodes: 2
ux-test16.rs: 10.212.212.2:2375
â ID: JQPG:GKFF:KJZJ:AY3N:NHPZ:HD6J:SH36:KEZR:2SSH:XF65:YW3N:W4DG
â Status: Healthy
â Containers: 4 (4 Running,0 Paused,0 Stopped)
â Reserved cpus: 0 / 2
â Reserved Memory: 0 B / 3.888 GiB
â Labels: kernelversion=3.10.0-327.28.3.el7.x86_64,operatingsystem=CentOS Linux 7 (Core),storagedriver=devicemapper
â UpdatedAt: 2016-09-05T11:11:31Z
â ServerVersion: 1.12.1
ux-test17.rs: 10.212.212.3:2375
â ID: Z27V:T5NU:QKSH:DLNK:JA4M:V7UX:XYGH:UIL6:WFQU:FB5U:J426:7XIR
â Status: Healthy
â Containers: 4 (2 Running,2 Stopped)
â Reserved cpus: 0 / 2
â Reserved Memory: 0 B / 3.888 GiB
â Labels: kernelversion=3.10.0-327.28.3.el7.x86_64,storagedriver=devicemapper
â UpdatedAt: 2016-09-05T11:11:17Z
â ServerVersion: 1.12.1
Plugins:
Volume:
Network:
Swarm:
NodeID:
Is Manager: false
Node Address:
Security Options:
Kernel Version: 3.10.0-327.28.3.el7.x86_64
Operating System: linux
Architecture: amd64
cpus: 4
Total Memory: 7.775 GiB
Name: 858ac2fdd225
Docker Root Dir:
Debug Mode (client): false
Debug Mode (server): false
WARNING: No kernel memory limit support
最佳答案
我的第一个答案是关于“群模式”.您已经澄清了您正在使用旧版Swarm并添加了更多信息,所以这里:
原文链接:https://www.f2er.com/docker/436206.html您列出的约束假定您有一个名为node-1的主机.您的主机名为ux-test16.rs和ux-test17.rs.只需在约束中使用它而不是node-1.例如:
environment:
- "constraint:node==ux-test16.rs"