相关疑难解决方法(0)

Docker群集与自定义网络

我正在尝试研究如何在Docker中正确使用swarm模式.首先,我尝试在我的2台工作人员和经理机器上运行容器,而没有指定自定义网络(所以我使用默认的入口覆盖网络).但是,如果我使用入口网络,由于某种原因我无法解决tasks.myservice.

所以我尝试像这样配置自定义网络:

docker network create -d overlay elasticnet
Run Code Online (Sandbox Code Playgroud)

所以现在,当我bash进入其中一个容器时,我可以成功解决,tasks.myservice但是我无法再访问我在--publish外部创建的服务中定义的端口(我可以在使用入口网络时).

有没有办法:

  1. 使用入口网络并能够解析tasks.myservice或指向我所有服务容器的任何其他DNS记录?

  2. 或者,使用自定义网络,但--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
Run Code Online (Sandbox Code Playgroud)

使用自定义网络:

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
Run Code Online (Sandbox Code Playgroud)

docker docker-swarm docker-networking

8
推荐指数
1
解决办法
905
查看次数

标签 统计

docker ×1

docker-networking ×1

docker-swarm ×1