我正试图解决如何在Docker中正确使用群集模式。首先,我尝试在我的2个工作人员和经理机器上运行容器,而没有指定自定义网络(所以我使用默认的入口覆盖网络)。但是,如果我使用入口网络,出于某种原因,我无法解析tasks.myservice
。具有自定义网络的Docker群体
所以,我想配置自定义网络是这样的:
docker network create -d overlay elasticnet
所以现在,当我bash
到容器之一,我能够成功地解决tasks.myservice
但我不能再访问我定义的端口在我的服务创建--publish
外部(我可以当我使用入口网络)。
有没有什么办法之一:
使用入口网络和能够解决
tasks.myservice
或将直接向我的所有服务容器的任何其他DNS记录?或者,使用自定义网络,但
--publish
端口正确,所以我可以从外部访问它们?
编辑
这是我创造我的服务,
没有自定义网络:
docker service create --replicas 3 --label elasticsearch --endpoint-mode vip --name elastic -e ES_HOSTS="tasks.elastic" --publish 9200:9200 --mount type=bind,source=/tmp/es,destination=/usr/share/elasticsearch/config --update-delay 10s es:latest
通过自定义网络:
docker service create --replicas 3 --network elasticnet --label elasticsearch --endpoint-mode vip --name elastic -e ES_HOSTS="tasks.elastic" --publish 9200:9200 --mount type=bind,source=/tmp/es,destination=/usr/share/elasticsearch/config --update-delay 10s es:latest
你可以发布你正在运行的所有命令的列表吗?而用户定义的覆盖网络就是要走的路。 – johnharris85
@ johnharris85请参阅我的编辑。 –