title: How to connect to a docker box running elasticsearch inside a vagrant guest os?
body: <p>I'm trying to start a vagrant box that in turn pulls in a docker elasticsearch image...</p>
  
  <pre><code>VAGRANTFILE_API_VERSION = "2"
  
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    # virtualbox provider for ububtu box
    config.vm.provider "virtualbox" do |v|
      v.memory = 1024
      v.cpus = 1
    end
  
    config.vm.provision "docker"
  
    #pull docker image from https://registry.hub.docker.com/u/library/elasticsearch/
    config.vm.provision "docker" do |d|
      d.pull_images "elasticsearch"
      d.run "elasticsearch"
    end
  
    config.vm.box = "ubuntu/trusty64"
  
    config.vm.network "private_network", ip: "192.168.33.150"
  
    config.vm.synced_folder ".", "/vagrant"
  
  end
  </code></pre>
  
  <p>I can then <code>vagrant ssh</code> into the vagrant box,
  run <code>docker inspect [image id]</code> to get the ip address of the running docker image and run this...</p>
  
  <pre><code>vagrant@vagrant-ubuntu-trusty-64:~$ curl -X GET http://172.17.0.2:9200
  {
    "status" : 200,
    "name" : "Nocturne",
    "cluster_name" : "elasticsearch",
    "version" : {
      "number" : "1.4.4",
      "build_hash" : "c88f77ffc81301dfa9dfd81ca2232f09588bd512",
      "build_timestamp" : "2015-02-19T13:05:36Z",
      "build_snapshot" : false,
      "lucene_version" : "4.10.3"
    },
    "tagline" : "You Know, for Search"
  }
  </code></pre>
  
  <p>So elasticsearch is running fine. The problem is the 172.17.0.2 ip is dynamic. So if I want to access elasticsearch from the guest OS I need to inspect the docker image to get it.</p>
  
  <p>Can I define the 172.17.0.x ip address with vagrant?
  Is there a better way to 'discover' elasticsearch in the docker image? </p>