How can I run a docker container on localhost over the default IP?

OS Version: Windows Server 2016
Docker Version:

PS C:\Users\Administrator> docker version
Client:
 Version:      17.03.1-ee-3
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   3fcee33
 Built:        Thu Mar 30 19:31:22 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.03.1-ee-3
 API version:  1.27 (minimum version 1.24)
 Go version:   go1.7.5
 Git commit:   3fcee33
 Built:        Thu Mar 30 19:31:22 2017
 OS/Arch:      windows/amd64
 Experimental: false

Hi, i’m new to docker . i’m trying to run docker container on localhost and some port by default on windows machine. how would i do that? Any advise on this would be helpful.

With the default NAT network you cannot access mapped ports on localhost. Not sure whether Microsoft will fix/improve that. You can access from another host, or directly at the container’s IP address.

If my containers ip is 172.20.x.x so i tried running docker using below command

docker run -p 172.20.x.x:2000 image_name

i get shown the below error

PS C:\Users\Administrator> docker run -p  172.20.x.x:2000 474614/my_repo:javaprogram
C:\Program Files\Docker\docker.exe: Invalid hostPort: 172.20.x.x

Could you please help me with any example or any advise on this would be helpful

You don’t need to map ports if you are directly accessing the container at its IP address. Just hit it directly at whatever port it is bound on.

-p is for mapping container port to host port:
E.G 80:8000

you don’t specify IP here