我应用了docker教程来建立一个集群。 我使用了docker工具箱,因为我使用的是Windows 10系列。
我执行所有语句,但是最后,语句“ curl ip_adress”没有运行。网址访问也出错。
$ docker --version
Docker version 18.03.0-ce, build 0520e24302
docker-compose.yml,位于名为“ myvm1”的虚拟机的/ home / docker中:
version: "3"
services:
web:
# replace username/repo:tag with your name and image details
image: 12081981/friendlyhello:part1
deploy:
replicas: 5
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "80:80"
networks:
- webnet
networks:
webnet:
群体:
$ docker-machine ssh myvm1 "docker stack ps getstartedlab"
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
blmx8mldam52 getstartedlab_web.1 12081981/friendlyhello:part1 myvm1 Running Running 9 seconds ago
04ctl86chp6o getstartedlab_web.2 12081981/friendlyhello:part1 myvm3 Running Running 6 seconds ago
r3qyznllno9j getstartedlab_web.3 12081981/friendlyhello:part1 myvm3 Running Running 6 seconds ago
2twwicjssie9 getstartedlab_web.4 12081981/friendlyhello:part1 myvm1 Running Running 9 seconds ago
o4rk4x7bb3vm getstartedlab_web.5 12081981/friendlyhello:part1 myvm3 Running Running 6 seconds ago
“ docker-machine ls”的结果:
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Running tcp://192.168.99.100:2376 v18.09.0
myvm1 * virtualbox Running tcp://192.168.99.102:2376 v18.09.0
myvm3 - virtualbox Running tcp://192.168.99.103:2376 v18.09.0
卷曲测试
$ curl 192.168.99.102
curl: (7) Failed to connect to 192.168.99.102 port 80: Connection refused
我该如何调试?
如果您愿意,我可以提供更多信息。
谢谢。
答案 0 :(得分:1)
在Windows中使用路由网格现在似乎只是EE功能。您可以监视this docker for windows issue以获得更多详细信息。当前的解决方法是在内部使用DNSRR并将端口直接发布到主机,而不是通过路由网格发布。如果您希望从群集中的任何节点都可以访问应用程序,则意味着您需要在群集中的所有主机上都有一项服务,该服务是全局调度的,侦听请求的端口。例如
version: "3.2"
services:
web:
# replace username/repo:tag with your name and image details
image: 12081981/friendlyhello:part1
deploy:
# global runs 1 on every node, instead of the replicated variant
mode: global
# DNSRR skips the VIP normally assigned to services
endpoint_mode: dnsrr
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- target: 80
published: 80
protocol: tcp
# host publishes the port directly from the container without the routing mesh
mode: host
networks:
- webnet
networks:
webnet: