Ssh – Installing Docker with Vagrant fails because of ssh command behind proxy

dockerPROXYsshvagrant

I'm playing around with a Vagrant file on a machine which is behind a proxy.

At the moment I stick in an issue where I'm assuming that has to do with the proxy server between.

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

docker build  --tag=java /vagrant/java

Stdout from the command:

Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon 

Stderr from the command:

time="2015-03-11T16:14:47Z" level="fatal" msg="Error: 404 page not found"

In the Vagrant file I found out this line d.build_image –tag=java /vagrant/java" is not working. I could not really find out what happens behind the scenes. My assumption is that the reason could be the proxy between the virtual machine.

Here is the Vagrant file:

Vagrant.configure("2") do |config|
  config.vm.box = "chef/ubuntu-14.04"
  config.vm.synced_folder "../user-registration-application/target", "/target", create: true
  config.vm.network "forwarded_port", guest: 8080, host: 8080
  config.vm.network "forwarded_port", guest: 8081, host: 8081
  config.vm.network "forwarded_port", guest: 9200, host: 9200

  if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http     = "http://10.1.3.3:3128/"
    config.proxy.https    = "http://10.1.3.3:3128/"
    config.proxy.no_proxy = "localhost,127.0.0.1"
  end

  config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"

  config.vm.provision "docker" do |d|
    d.build_image "--tag=java /vagrant/java"
    d.build_image "--tag=tomcat /vagrant/tomcat"
    d.build_image "--tag=kibana /vagrant/kibana"
    d.build_image "--tag=elasticsearch /vagrant/elasticsearch"
    d.build_image "--tag=logstash /vagrant/logstash"
    d.build_image "--tag=user-registration /vagrant/user-registration"
    d.run "elasticsearch",
      args: "-p 9200:9200"
    d.run "kibana",
      args: "-p 8080:8080"
    d.run "logstash",
      args: "--link elasticsearch:elasticsearch"
    d.run "user-registration",
      args: "-p 8081:8080 -v /target:/target --volumes-from logstash"
  end
end

Does anybody know to whom tries Docker to build up a connection? Is this happening over ssh?

Best Answer

Ok, that was now really hard work. ;-)

I could found the solution here https://github.com/tmatilai/vagrant-proxyconf/issues/109.

Modifying the Vagrant no proxy variable to:

config.proxy.no_proxy = "localhost,127.0.0.1,/var/run/docker.sock 

solves the problem.