Docker集群实验环境布署--swarm【6 配置上层Nginx代理,让任意Docker client访问得到高可用的管理API】
10.40.42.10上,也就是对应的VRRP中的10.40.42.1和2上,配置nginx tcp代理
# cat 4000_manager.venic.com_10.40.100.141-142_4000.conf
upstream manager.venic.com {
server 10.40.100.141:4000;
server 10.40.100.142:4000;
}
server {
listen 4000;
proxy_pass manager.venic.com;
}
重启上层nginx代理服务
最终在有docker CLI命令行的机器上使用 docker-manager.venic.com:4000来测试方式
[root@docker-registry ~]# docker -H docker-manager.venic.com:4000 ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2cf7f3288ead docker-registry.venic.com:5000/swarm:latest "/swarm join --advert" 9 minutes ago Up 9 minutes 2375/tcp docker-node1.venic.com/node1
36679f016f7b docker-registry.venic.com:5000/swarm:latest "/swarm join --advert" 9 minutes ago Up 9 minutes 2375/tcp docker-node0.venic.com/node0
[root@docker-registry ~]# docker -H docker-manager.venic.com:4000 run hello-world
[root@docker-registry ~]# docker -H docker-manager.venic.com:4000 ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
350684df98bf hello-world "/hello" 9 seconds ago Exited (0) 8 seconds ago docker-node0.venic.com/sick_shannon
2cf7f3288ead docker-registry.venic.com:5000/swarm:latest "/swarm join --advert" 10 minutes ago Up 10 minutes 2375/tcp docker-node1.venic.com/node1
36679f016f7b docker-registry.venic.com:5000/swarm:latest "/swarm join --advert" 10 minutes ago Up 10 minutes 2375/tcp docker-node0.venic.com/node0
[root@docker-registry ~]# docker -H docker-manager.venic.com:4000 run -it docker-registry.venic.com:5000/ubuntu:latest /bin/sh
#
#
#
#
# uname -a
Linux f078e8079bca 3.10.0-514.2.2.el7.x86_64 #1 SMP Tue Dec 6 23:06:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
#
# docker -H docker-manager.venic.com:4000 ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f078e8079bca docker-registry.venic.com:5000/ubuntu:latest "/bin/sh" 38 seconds ago Up 34 seconds docker-node0.venic.com/ecstatic_visvesvaraya
85209ebc93b7 docker-registry.venic.com:5000/ubuntu:latest "-it /bin/sh" 53 seconds ago Created docker-node1.venic.com/romantic_mcclintock
350684df98bf hello-world "/hello" About a minute ago Exited (0) About a minute ago docker-node0.venic.com/sick_shannon
2cf7f3288ead docker-registry.venic.com:5000/swarm:latest "/swarm join --advert" 11 minutes ago Up 11 minutes 2375/tcp docker-node1.venic.com/node1
36679f016f7b docker-registry.venic.com:5000/swarm:latest "/swarm join --advert" 12 minutes ago Up 12 minutes 2375/tcp docker-node0.venic.com/node0
只是这个 -it后,容器CMD命令行不够单机友好,那些tab补全和回退删键用不了,另外有个惊喜之处就是它的 Name会记录是在哪台宿主机上启动的容器。-v的挂载也是挂在对应的机器上的
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,负责保留追究法律责任的权利。