Publish port for windows container not working

I created a simple container image (asp.net core web api) and tried to create service on swarm cluster
with 3 replicas , it show all three instances running but not accessible on published port from outside.

I checked the service inspect also and it does not have published port information , what I’m missing…

command I’m using to create service is …

docker service create --name web --publish 8080:80 --replicas=3 madhurbhardwaj/web

any help pls

Madhur

Now I’m able to see the published port information in service inspect , but still not able to access service outside cluster.
But when I create a container for the same image using docker run command with some random ports 9090 , I’m able to access this from out side…

Is it related to docker network , all my swarm service are running on default swarm network, do I need to create a new network for this ?

checked the docker service ps and found following error
"HNS failed with error : Catastrophic failure " , any help pls

Check Get-netnatstaticmapping and see if those ports are already mapped

Unfortunately, on Windows you can’t use the ingress routing mesh, so you can’t publish the ports on the network. Instead, you have to publish the ports on the host. You can do that by using --publish mode=host,target=80

This works fine, but only the nodes that run the particular service will have the port(s) published. You can’t go to a random swarm node on port X and expect it to proxy your request to a node that runs the service, it doesn’t work like that on Windows - yet :).

Hope this helps.

1 Like

Many Thanks , that was helpful…

But as you know I’m running containers on windows server 2016, Could you please share some information on how to enable reverse proxy using Nginx running as separate container with automatic update when scaling my service containers…

Sorry, I’m afraid I can’t help you there…

Any one help on this please…

Hi, take a look at Traefic

Hi
I am having the same problem. If I use the host mode then how do I scale? That’s the whole purpose of swarm.
Or shall we say docker on Windows is not mature yet?

1 Like

@witsec - Your simple post helped me immensely. Although I can only have one instance of my service on Docker for Windows, I am happy it is working and it helps my deployment process out a lot.

1 Like