tmatilai / vagrant-proxyconf

Vagrant plugin that configures the virtual machine to use proxies
MIT License
531 stars 74 forks source link

support setting proxy for yet-to-be-provisioned docker #98

Closed dkoper closed 9 years ago

dkoper commented 9 years ago

This comes from #97: Vagrant-proxyconf acts before, and is unaware of config.vm.provision('docker') in Vagrantfile, so it doesn't set the proxy in docker's environment file on vagrant up (it will after a vagrant reload). This is a feature request for vagrant-proxyconf to detect the config.vm.provision('docker') in the Vagrantfile and set the proxy for it without the user needing to do an implicit vagrant reload.

otahi commented 9 years ago

I have merged this modification. Thank you for your cooperation.

pfmoore commented 5 years ago

This doesn't appear to be working for me.

My Vagrantfile:

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

Vagrant.configure("2") do |config|
    config.vm.box = "bento/ubuntu-18.04"

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

    config.vm.provision "docker"
end

Log file:

>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/ubuntu-18.04'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/ubuntu-18.04' version '201812.27.0' is up to date...
==> default: Setting the name of the VM: test_default_1556014504591_55616
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection aborted. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 5.2.22
    default: VirtualBox Version: 6.0
==> default: Configuring proxy for Apt...
==> default: Configuring proxy environment variables...
==> default: Configuring proxy for Git...
==> default: Mounting shared folders...
    default: /vagrant => C:/Work/Scratch/vagrant/test
==> default: Running provisioner: docker...
    default: Installing Docker onto machine...

Note that it doesn't mention "Configuring proxy for docker", and I can confirm that docker doesn't work due to lack of proxy configuration.

vagrant reload appears to fix the issue (in that I get "Configuring proxy for Docker") but it doesn't seem to work - checking the VM, /etc/systemd/system/docker.service.d doesn't appear to exist (which is what I have to create if I'm fixing the issue manually, see here).

Edit: I should have said, I have

>vagrant plugin list
vagrant-proxyconf (2.0.1, global)
>vagrant version
Installed Version: 2.2.4
Latest Version: 2.2.4

You're running an up-to-date version of Vagrant!

on Windows 7.