0

I am new to docker and I have 2 windows machines on windows 10 . I wish to expose all ports as I am running multiple services and they are internally calling other NodeJS services .

SO I did on windows PowerShell

  docker run -dit -p 3000:3000 -p 6379:6379   --name manish1v  manish1:1.0

This exposed port 3000 of my service and redis port 6379 . however it needs another port which comes up randomly

Sometimes that port is 6000 and sometimes 6001 sometimes something ransom . When I had exposed -p 6000:6000 and internally it was 6000 everything works . If it does not match things goes for a toss.

How can I expose all ports mapped to same ports on windows .

I tried 2 things

  1. docker run --network host

unfortunately it is not supported on windows it seems

  1. docker run -P

unfortunately it is not working . Because it seems it exposes on random ports but I want them to be exposed on same ports

Please help .

MAG
  • 2,841
  • 6
  • 27
  • 47
  • 1
    The best approach would be to fix your service to use a known (or configurable) port, instead of picking something randomly. It's also pretty unusual for a single container to run both an Express service and Redis as you've shown it, you'd almost always run these two things in two separate containers (and each would have only one `docker run -p` option). – David Maze Sep 30 '20 at 15:49
  • It's as @David Maze says, imo. You could specify a range of ports ala https://stackoverflow.com/a/28721643/3080207, but it's not advisable if you don't even know the rage, there should be a way to designate what ports this is happening on the host side. – mikey Oct 01 '20 at 02:29

0 Answers0