Because you are not on the same network. Containers run on their own network by default, separate from the host network.
If you run:
docker run -it debian ping 172.17.0.15
You should find this to work. Even better, you can bind containers and access them by name:
$ docker run -d --name redis redis $ docker run --link redis:redis redis redis-cli -h redis ping PONG
If you really want to access redis from your host, just publish the port through the host:
$ docker run -d -p 6379:6379 redis
Now you can contact him on localhost:6379 on the host.
source share