title: Problems getting docker containers to see (ping) each other by name
body: <p>I have three docker containers, </p>
  
  <ol>
  <li>java container (JC): for my java application (spring boot)</li>
  <li>elasticsearch container (EC): for ElasticSearch</li>
  <li>test container (TC): testing container to troubleshoot with ping test</li>
  </ol>
  
  <p>Currently, the JC cannot see the EC by "name". And when I say "see" I mean if I do a ping on the JC to EC, I get a <code>ping: unknown host</code>. Interestingly, if I do a ping on the TC to EC, I do get a response.</p>
  
  <p>Here is how I start the containers.</p>
  
  <ol>
  <li><code>docker run -dit --name JC myapp-image</code></li>
  <li><code>docker run -d --name EC elasticsearch:1.5.2 elasticsearch -Des.cluster.name=es</code></li>
  <li><code>docker run --rm --name TC -it busybox:latest</code></li>
  </ol>
  
  <p>Then, to ping EC from JC, I issue the following commands.</p>
  
  <pre><code>docker exec JC ping -c 2 EC
  </code></pre>
  
  <p>I get a <code>ping: unknown host</code></p>
  
  <p>With the TC, since I am already at the shell, I can just do a <code>ping -c 2 EC</code> and I get 2 replies.</p>
  
  <p>I thought maybe this had something to do with my Java application, but I doubt it because I modified my <code>Dockerfile</code> to just stand up the container. The <code>Dockerfile</code> looks like the following.</p>
  
  <pre><code>FROM java:8
  VOLUME /tmp
  </code></pre>
  
  <p>Note that you can create the above docker image by <code>docker build -no-cache -t myapp-image .</code>.</p>
  
  <p>Also note that I have Docker Weave Net installed, and this does not seem to help getting the JC to see the EC by name. On the other hand, I tried to find the IP address of each container as follows.</p>
  
  <ol>
  <li><code>docker inspect -f '{{ .NetworkSettings.IPAddress }}' JC</code> --> <code>172.17.0.4</code></li>
  <li><code>docker inspect -f '{{ .NetworkSettings.IPAddress }}' EC</code> --> <code>172.17.0.2</code></li>
  <li><code>docker inspect -f '{{ .NetworkSettings.IPAddress }}' TC</code> --> <code>172.17.0.3</code></li>
  </ol>
  
  <p>I can certainly ping EC from JC by IP address: <code>docker exec JC ping -c 2 172.17.0.2</code>. But getting the containers to see each other by IP address does not help as my Java application needs a hostname reference as a part of its configuration. </p>
  
  <p>Any ideas on what's going on? Is it the container images themselves? Why would the busybox container image be able to ping the ElasticSearch container by name but the java container not? </p>
  
  <p>Some more information.</p>
  
  <ul>
  <li>VirtualBox 5.0.10</li>
  <li>Docker 1.9.1</li>
  <li>Weave 1.4.0</li>
  <li>CentOS 7.1.1503</li>
  <li>I am running docker inside a CentOS VM on a Windows 10 desktop as a staging environment before deployment to AWS</li>
  </ul>
  
  <p>Any help is appreciated. </p>