简体   繁体   中英

Spawn Docker EE Swarm service in Local Windows Server 2016 VM

I want to demonstrate running Docker swarm with a simple Asp.Net Core website within a local Windows Server 2016 VM. The website runs on port 5000. However, when I initialize a swarm and add a service, I'm unable to visit the website address at the specified port. Navigating to http://localhost:5000 , http://127.0.0.1:5000 , or any of the service container IPs does not bring up the site. Why is this the case with a swarm?

The Windows firewall is disabled.

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"]

Initialize the swarm

docker swarm init --advertise-addr 127.0.0.1:2377 --listen-addr 0.0.0.0:2377

Create a service

docker service create --name helloworld --publish 5000:5000 --replicas 3 myazureregistry.azurecr.io/aspnetcore-hello-world:v2

I can confirm the service replicates three instances in my node. Why is the ports column empty even though I mapped port 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 (eg 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM