Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Forward container ports to the host #51

Open
unwiredbrain opened this issue May 27, 2014 · 2 comments
Open

Forward container ports to the host #51

unwiredbrain opened this issue May 27, 2014 · 2 comments

Comments

@unwiredbrain
Copy link

Please, add the ability to automatically forward the exposed ports to the host.

Let's say I'm using dockerfile/elasticsearch. Its Dockerfile exposes ports 9200 and 9300.

Here's the Vagrantfile I'm using:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "elasticsearch" do |es|
    es.vm.provider "docker" do |container|
      container.image = "dockerfile/elasticsearch"
      container.ports = [ "9200:9200", "9300:9300" ]
      container.remains_running = true
    end
  end
end

On the boot2docker guest everything is fine

docker@boot2docker:~$ curl -sS -X GET http://127.0.0.1:9200/
{
  "status" : 200,
  "name" : "Sleepwalker",
  "version" : {
    "number" : "1.1.1",
    "build_hash" : "f1585f096d3f3985e73456debdc1a0745f512bbc",
    "build_timestamp" : "2014-04-16T14:27:12Z",
    "build_snapshot" : false,
    "lucene_version" : "4.7"
  },
  "tagline" : "You Know, for Search"
}

But no port is forwarded to the host

$ vagrant up elasticsearch --provider=docker
Bringing machine 'elasticsearch' up with 'docker' provider...
==> elasticsearch: Docker host is required. One will be created if necessary...
    elasticsearch: Docker host VM is already ready.
==> elasticsearch: Syncing folders to the host VM...
    elasticsearch: Rsyncing folder: <snip>/elasticsearch-docker/ => /var/lib/docker/docker_1401201151_90455
==> elasticsearch: Warning: When using a remote Docker host, forwarded ports will NOT be
==> elasticsearch: immediately available on your machine. They will still be forwarded on
==> elasticsearch: the remote machine, however, so if you have a way to access the remote
==> elasticsearch: machine, then you should be able to access those ports there. This is
==> elasticsearch: not an error, it is only an informational message.
==> elasticsearch: Creating the container...
    elasticsearch:   Name: elasticsearch-docker_elasticsearch_1401201153
    elasticsearch:  Image: dockerfile/elasticsearch
    elasticsearch: Volume: /var/lib/docker/docker_1401201151_90455:/vagrant
    elasticsearch:   Port: 2222:22
    elasticsearch:   Port: 9200:9200
    elasticsearch:   Port: 9300:9300
    elasticsearch:
    elasticsearch: Container created: ba322db5bdfe082a
==> elasticsearch: Starting container...
==> elasticsearch: Provisioners will not be run since container doesn't support SSH.

massimo@host ~/elasticsearch-docker $ curl -sS -X GET http://127.0.0.1:9200/
curl: (7) Failed connect to 127.0.0.1:9200; No error

Am I missing something?

@unwiredbrain
Copy link
Author

Forgot to mention:

  • Windows 7 x64
  • VirtualBox 4.3.12r93733
  • Vagrant 1.6.2
  • Cygwin 2.850 x64 (Bash 4.1.11-2, rsync 3.0.9-1)

I also tried setting up a host-only interface and use that instead, but still no luck

config.vm.network "private_network", ip: "10.0.0.10"
$ curl -sS -X GET http://10.0.0.10:9200/
curl: (7) Failed connect to 10.0.0.10:9200; No error

@adambiggs
Copy link

I'm also experiencing this problem...

  • OSX 10.9.5
  • VMWare Fusion 6.0.4
  • Vagrant 1.6.5

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants