Can not ping docker in macOS

I have docker installed on my local but I can not ping it in Mac but I can ping on Ubuntu for same thing.

$ docker inspect -f '{{ .NetworkSettings.IPAddress }}' n1
172.17.0.2

$ ping 172.17.0.2
PING 172.17.0.2 (172.17.0.2): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
^C
--- 172.17.0.2 ping statistics ---
7 packets transmitted, 0 packets received, 100.0% packet loss

I installed docker on mac following https://docs.docker.com/docker-for-mac/

  • debug docker deamon with gdb or cgdb
  • .Net Core with Docker on EC2 tutorial problems
  • What are possible STATUS of docker nodes?
  • Asp.net 5 - Docker
  • Windows Image on Docker
  • Dockerfile: is it necessary to specify which user before perform a RUN?
  • Docker, Registrator and Consul by example
  • Error response from daemon: Container CONTAINER_NAME is not running
  • How do you manage permissions when developing in a Docker container?
  • Cannot delete files on docker host
  • build Docker images from GitLab
  • Docker plugin : java.io.FileNotFoundException: /src/main/docker/Dockerfile gradle-docker fails
  • 2 Solutions collect form web for “Can not ping docker in macOS”

    It is not just ping. As commented in issue 155

    xhyve vm inside Docker for Mac hasn’t no Network Adapter. Or routable IP like boot2docker (192.168.100.99 like that)

    With boot2docker and a route command its possible to Route all the Container ips to the vm Network.

    We need this for xhyve.

    (there are a lot of threads on this topic in Docker for Mac forum)

    That’s normal.

    Take a look at your Mac’s interface config – there is no 172.x.x.x network on the Mac itself. Those live in the xhyve Linux VM that is actually hosting Docker.

    Network connections are mapped through when you use port maps (e.g. docker run -p ...) but ping will not work like this.

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