title: Accessing other machines on a vagrant/virtual box host only network from within a docker container
body: <p>I have a lab environment I have setup using vagrant. It consists of 3 machines, two application servers with docker 1.4.1 installed and one database server with postgres 9.3 installed. All machines are running Centos 6.6.</p>
  
  <p>The environment is setup using a host-only private network. Here's the vagrant file</p>
  
  <pre><code>Vagrant.configure('2') do |config|
    config.vm.box = "centos-6.0-updated"
  
    {
      'db'    =&gt; '10.17.33.10',
      'app1'   =&gt; '10.17.33.11',
      'app2' =&gt; '10.17.33.12',
    }.each do |short_name, ip|
      config.vm.define short_name do |host|
        host.vm.network 'private_network', ip: ip
        host.vm.hostname = "#{short_name}.my.dev"
      end
    end
  end
  </code></pre>
  
  <p>I'm finding that when I'm inside of a container on app1 or app2 I cannot access the db server. I believe the issue is that vagrant/virtualbox's host only private network uses addresses in the 127.0.0.x range. On the host, vagrant configures the loopback interface to handle sending requests to each machine on the network. However in the container, because this interface is not configured the container treats all 127.0.0.x requests as requests for localhost and just sends them back to itself.</p>
  
  <p>Is there any alternative configuration I can setup on the vagrant side, or the docker side that will alleviate this issue? In short, I want to have a vagrant environment where containers on my app server can talk to the db server. Note the db is installed directly on the db-host, not running inside a docker container. Also, this is meant to mimic a production environment that will not use vagrant, so I'd want any docker changes to work in a more normal networking scenario as well.</p>