Docker Community Forums

Share and learn in the Docker community.

Publish port for windows container not working


(Madhurbhardwaj) #1

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


(Madhurbhardwaj) #2

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 ?


(Madhurbhardwaj) #3

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


(Artisticcheese) #4

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


(Witsec) #5

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.


(Madhurbhardwaj) #6

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…


(Witsec) #7

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


(Madhurbhardwaj) #8

Any one help on this please…


(Xxradar) #9

Hi, take a look at Traefic


(Shahreza) #10

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?


(Loonison101) #11

@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.