Cannot map port for Docker

Hi guys,
I’m using Docker toolbox for Windows 7 and following the tutorial: https://docs.docker.com/get-started/part2/#share-your-image
I am able to create image and push it to my dockerhub.
However , when i run docker using command:
docker run -d -p 4000:80 friendlyhello
image
Its shows no error. however , when i direct to http://localhost:4000.
It say This site can’t be reached ( no result ).
Any help please

UPDATE : Although i cannot acces localhost:4000 . I can access 192.168.99.100:4000 and get my desired result . Anybody know the reason why ???

Yes, that’s how Docker Toolbox works: https://docs.docker.com/machine/reference/ip/

Just to give a bit more detail, when you install Docker Toolbox, you’re actually running a virtual machine that is running Docker. That means that your app is being exposed on port 4000 of that virtual machine.

So you need to use the ip address of the machine to access the service, since Docker is not running natively in your machine.

2 Likes