Docker群服务端口未公开
我无法连接到在docker swarm上运行的服务。群似乎还可以,因为我可以连接到在其上运行的其他容器。我使用 docker stack deploy -c docker-compose.yaml nifi
运行服务,而docker compose文件是:
I cannot connect to a service running on docker swarm. The swarm seems ok because I can connect to other containers running on it. I running the service with docker stack deploy -c docker-compose.yaml nifi
and the docker compose file is:
version: "3.3"
services:
registry:
image: apache/nifi-registry:0.3.0
ports:
- "18080:18080"
deploy:
replicas: 1
restart_policy:
condition: on-failure
当我运行时没有大群,例如 docker-compose -f docker-compose.yaml up
我可以浏览到它。当我使用 docker stack deploy -c docker-compose.yaml nifi
运行它时,我看到了该服务的相同日志条目,但是无法浏览到它。
When I run this without the swarm i.e. docker-compose -f docker-compose.yaml up
it works fine and I can browse to it. When I run it with docker stack deploy -c docker-compose.yaml nifi
I see the same log entries for the service but cannot browse to it.
$ docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Wed Jun 20 21:43:51 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Wed Jun 20 21:42:00 2018
OS/Arch: linux/amd64
Experimental: false
有人对这个问题有解决的建议吗?
Does anyone have suggestions for fixing or troubleshooting this?
群聚
ports:
- "18080:18080"
wil l在所有群集节点上公开端口,如果其他服务在某些节点上使用端口,则可能会出现问题
will expose port on all swarm nodes and in case of use of the port on some of the nodes by another service you can have problems
您只能在主机上公开端口容器
you can expose port only on host with container
services:
registry:
ports:
- target: 18080
published: 18080
mode: host