-p 10000:80 option will set up a port forward. port 10000 on the host will forward to port 80 on the container. The 172.17.0.2 ip address looks like it is the ip address of the container, not the host. I would expect that you can use port 10000 on any host ip address, including the host’s 127.0.0.1/localhost.
Normally if you want to access a container’s service from the host or outside the host, you will want to use the port publishing feature, and connect to the published port, not the container’s IP.
If you want to connect to a container from another container,
--link helps make it easy to resolve the ip and figure out what port to make the connection on.
Additionally, if you have containers connected to a
docker network create custom network, they can find eachother by name.
docker network create test
docker run --name webtest --net=test -d nginx:alpine
docker run --rm -it --net=test alpine ping -c 1 webtest
PING webtest (172.22.0.2): 56 data bytes
64 bytes from 172.22.0.2: seq=0 ttl=64 time=0.142 ms
--- webtest ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.142/0.142/0.142 ms