why I can't ping my docker container?

I run a docker container, which is named “redis”. I want to use the “redis” container redis service, but I can’t ping the container!

As the picture shows, my “redis” container is IP address is 172.17.0.15, but I can’t connect to it.

  • How can I restart docker service using puppet…?
  • Access to Docker Container Port
  • Simple Docker networking — not sure where to even start
  • writing docker file for 32-bit ubuntu
  • How to mimic '--volumes-from' in Kubernetes
  • How do I start a group of containers, keep them running, then begin an identical process in each container
  • I want to use the redis services. What is wrong with my configuration?

    enter image description here

  • Openshift v3 - update image stream to fetch changes from external docker registry
  • How to display the docker current configuration?
  • Access to Docker Container Port
  • Why does docker stop immediately after starting and how to prevent it from stopping?
  • HTTP 504 Gateway Time-out when serving static file with Django (Nginx + Gunicorn)
  • Docker php set up installing pdo extension
  • One Solution collect form web for “why I can't ping my docker container?”

    Because you’re not on the same network. Containers are started on their own network by default, separate to the host’s network.

    If you run:

    docker run -it debian ping 172.17.0.15
    

    You should find it works. Even better, you can link containers and refer to 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 a port through to the host:

    $ docker run -d -p 6379:6379 redis
    

    You should now be able to reach it at localhost:6379 on the host.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.