Docker集群实验环境布署--swarm6 配置上层Nginx代理,让任意Docker client访问得到高可用的管理API
Posted 肖冲
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker集群实验环境布署--swarm6 配置上层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来测试方式
[[email protected] ~]# 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
[[email protected] ~]# docker -H docker-manager.venic.com:4000 run hello-world
[[email protected] ~]# 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
[[email protected] ~]# 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的挂载也是挂在对应的机器上的
以上是关于Docker集群实验环境布署--swarm6 配置上层Nginx代理,让任意Docker client访问得到高可用的管理API的主要内容,如果未能解决你的问题,请参考以下文章
Docker集群实验环境布署--swarm5 容器启动组件--node
Docker集群实验环境布署--swarm2 搭建本地镜像仓库