swarm
-
默认网络无法获取到客户端真实的ip,如果nginx/dns等服务需要真实ip,那么可以使用host模式
-p mode=host,target=80,published=80
-
以上使用host模式后只有容器所在的节点能够提供服务了,无法从任意节点定位,可以设置成全局每个节点都运行此服务来解决,最后设置vip,由vip的节点来提供服务
--mode=global
-
如果在多副本的创建过程中某个节点失败了,获取不到镜像,虽然手动拉取了,但是一直也不成功,这时候可以中断,其他节点是运行成功的,状态参考如下:
[root@node1 bind]# docker service ps bind9 ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS pvuko661l0di bind9.ef1dsojktw8h14ijgnvruuxn5 internetsystemsconsortium/bind9:9.18 node1 Running Running 19 minutes ago *:53->53/udp,*:53->53/udp,*:53->53/tcp,*:53->53/tcp 5vh5fqwy8lyi bind9.lp5ohtozpxy7uq3u3dbtysgaw internetsystemsconsortium/bind9:9.18 node5 Running Running 19 minutes ago *:53->53/tcp,*:53->53/tcp,*:53->53/udp,*:53->53/udp k6f6xnhpsmtk bind9.oow0gju8qlwr64jkd0r8l3283 internetsystemsconsortium/bind9:9.18 node4 Running Running 19 minutes ago *:53->53/udp,*:53->53/udp,*:53->53/tcp,*:53->53/tcp q14rzr9qfzrp bind9.pxf8dpz671vtbqv8gx8dw1tgl internetsystemsconsortium/bind9:9.18 node6 Running Running 19 minutes ago *:53->53/tcp,*:53->53/tcp,*:53->53/udp,*:53->53/udp jz81g74ok3bj bind9.rs1b1hsnc7zd7x081xuyahy8g internetsystemsconsortium/bind9:9.18 node7 Running Running 19 minutes ago *:53->53/tcp,*:53->53/tcp,*:53->53/udp,*:53->53/udp zacx3zxwyc2j bind9.yu17kuix56z3aemh63ij4hedy internetsystemsconsortium/bind9:9.18 node2 Shutdown Rejected 19 minutes ago "No such image: harbor.xxx.…" 5ry1tkgedliv bind9.zk4e1d1eyzn9kmarxx2c6yh5b internetsystemsconsortium/bind9:9.18 localhost.localdomain Running Running 9 minutes ago *:53->53/udp,*:53->53/udp,*:53->53/tcp,*:53->53/tcp
那么该如何让这个节点运行起来呢,经测试执行update即可
docker service update bind9
-
如果某个服务的配置文件更新,又不想重启docker,或者设置副本为0再启用,或者进入容器内重启服务,使用update又无效果,因为此服务本身的属性没有变化。则可以强制更新
docker service update bind9 --force