在本地 Windows Server 2016 VM 中生成 Docker EE Swarm 服务
Spawn Docker EE Swarm service in Local Windows Server 2016 VM
我想在本地 Windows Server 2016 虚拟机中演示 运行 Docker 集群,其中包含一个简单的 Asp.Net 核心网站。该网站运行在5000端口。但是,当我初始化一个swarm并添加一个服务时,我无法访问指定端口的网站地址。导航到 http://localhost:5000, http://127.0.0.1:5000,或任何服务容器 IP 都不会打开该站点。为什么蜂群会出现这种情况?
Windows 防火墙已禁用。
Dockerfile.build
FROM microsoft/aspnetcore:2.0.0-nanoserver
WORKDIR /
COPY /bin/Release/netcoreapp2.0/win7-x64/publish ./
EXPOSE 5000
ENTRYPOINT ["AspNetCoreHelloWorld.exe", "--urls", "http://*:5000"]
初始化集群
docker swarm init --advertise-addr 127.0.0.1:2377 --listen-addr 0.0.0.0:2377
创建服务
docker service create --name helloworld --publish 5000:5000 --replicas 3 myazureregistry.azurecr.io/aspnetcore-hello-world:v2
我可以确认该服务在我的节点中复制了三个实例。为什么即使我映射了端口 5000,端口列还是空的?
docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
y7i6pn9dcgtk helloworld.1 myazureregistry.azurecr.io/aspnetcore-hello-world:v2 WIN-QL7AIOPATIH Running Starting 16 seconds ago
vpc3naln3q2l helloworld.2 myazureregistry.azurecr.io/aspnetcore-hello-world:v2 WIN-QL7AIOPATIH Running Starting 16 seconds ago
w88cwnj7omo7 helloworld.3 myazureregistry.azurecr.io/aspnetcore-hello-world:v2 WIN-QL7AIOPATIH Running Starting 16 seconds ago
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
66h9usj0xxiq helloworld replicated 3/3 myazureregistry.azurecr.io/aspnetcore-hello-world:v2 *:5000->5000/tcp
"Currently, DNS Round-Robin is the only load balancing strategy supported on Windows.Routing mesh for Windows docker hosts is not yet supported, but will be coming soon. Users seeking an alternative load balancing strategy today can setup an external load balancer (e.g. NGINX) and use Swarm’s publish-port mode to expose container host ports over which to load balance."
https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/swarm-mode
我想在本地 Windows Server 2016 虚拟机中演示 运行 Docker 集群,其中包含一个简单的 Asp.Net 核心网站。该网站运行在5000端口。但是,当我初始化一个swarm并添加一个服务时,我无法访问指定端口的网站地址。导航到 http://localhost:5000, http://127.0.0.1:5000,或任何服务容器 IP 都不会打开该站点。为什么蜂群会出现这种情况?
Windows 防火墙已禁用。
Dockerfile.build
FROM microsoft/aspnetcore:2.0.0-nanoserver
WORKDIR /
COPY /bin/Release/netcoreapp2.0/win7-x64/publish ./
EXPOSE 5000
ENTRYPOINT ["AspNetCoreHelloWorld.exe", "--urls", "http://*:5000"]
初始化集群
docker swarm init --advertise-addr 127.0.0.1:2377 --listen-addr 0.0.0.0:2377
创建服务
docker service create --name helloworld --publish 5000:5000 --replicas 3 myazureregistry.azurecr.io/aspnetcore-hello-world:v2
我可以确认该服务在我的节点中复制了三个实例。为什么即使我映射了端口 5000,端口列还是空的?
docker service ps helloworld
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
y7i6pn9dcgtk helloworld.1 myazureregistry.azurecr.io/aspnetcore-hello-world:v2 WIN-QL7AIOPATIH Running Starting 16 seconds ago
vpc3naln3q2l helloworld.2 myazureregistry.azurecr.io/aspnetcore-hello-world:v2 WIN-QL7AIOPATIH Running Starting 16 seconds ago
w88cwnj7omo7 helloworld.3 myazureregistry.azurecr.io/aspnetcore-hello-world:v2 WIN-QL7AIOPATIH Running Starting 16 seconds ago
docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
66h9usj0xxiq helloworld replicated 3/3 myazureregistry.azurecr.io/aspnetcore-hello-world:v2 *:5000->5000/tcp
"Currently, DNS Round-Robin is the only load balancing strategy supported on Windows.Routing mesh for Windows docker hosts is not yet supported, but will be coming soon. Users seeking an alternative load balancing strategy today can setup an external load balancer (e.g. NGINX) and use Swarm’s publish-port mode to expose container host ports over which to load balance."
https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/swarm-mode