title: docker: connect to database container via dockerhost
body: <p>I am trying to connect from an application container to a database container in two situations, one succeeds, one doesn't.</p>
  
  <p>There are two containers on my dockerhost: </p>
  
  <ol>
  <li>mysql container with port 3306 connected to 3356 on dockerhost</li>
  <li>application container</li>
  </ol>
  
  <p>At work, dockerhost has IP-address 10.0.2.15, at home, dockerhost has IP-address 192.168.8.11 (hostname -I).<br>
  In both situations, I want to connect to the database container from the app container with host 10.0.2.15/192.168.8.11 and port 3356.</p>
  
  <p>When I do this at work (Windows network, Vagrant/Virtualbox dockerhost), this is no problem. I can 'telnet 10.0.2.15 3356' from the app container and connect to the db container.
  When I do this at home (Ubuntu), it is impossible to connect. The only way is to use the docker ip address of the db container (172.17.0.2) with port 3306. However, I can ping 192.168.8.11.</p>
  
  <p>The scripts to start the containers are identical; I do not use --add-host, so the dockerhost IP-address is not in /etc/hosts.</p>
  
  <p>Any suggestions?</p>