tmatilai / vagrant-proxyconf

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

dind proxy in vagrant #174

Closed ozbillwang closed 5 years ago

ozbillwang commented 5 years ago

Thanks to make this plugin, I can run docker in vagrant behind corporate's proxy.

But there is a project I used, I need run docker in docker (dind), I found I can't access registry server properly

root@ubuntu-xenial:/etc# docker ps
CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS              PORTS                       NAMES
b8d438b51411        mirantis/kubeadm-dind-cluster:v1.11   "/sbin/dind_init sys…"   2 minutes ago       Up 2 minutes        127.0.0.1:32769->8080/tcp   kube-master

root@ubuntu-xenial:/etc# docker exec -ti b8 bash
root@kube-master:/#

root@kube-master:/# docker pull node
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 10.192.0.2:53: no such host
root@kube-master:/#

Any hints for me? I run with ./dind-cluster-v1.11.sh up

By the way, internet access is fine

root@kube-master:/# curl -s -I www.google.com
HTTP/1.1 200 OK
Date: Tue, 30 Oct 2018 05:12:16 GMT
Expires: -1
Cache-Control: private, max-age=0
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Set-Cookie: 1P_JAR=2018-10-30-05; expires=Thu, 29-Nov-2018 05:12:16 GMT; path=/; domain=.google.com
Set-Cookie: NID=144=Y51HQzOx7gJeNXSNU0mhJGGyhMRh6Yr-dazmAHdJCvc3SOOFuPlVdd5WSBXhWWeoAoD6bVKUzy7wvA1Dj5g1cIYwilatoeMj_oU2ltRVzJP6Y4JZT9vVMT4vKUxZlSGeos-Ag21yWg5lmkHsPBBe_A-aAqEM_WC1I8vA7psGfIA; expires=Wed, 01-May-2019 05:12:16 GMT; path=/; domain=.google.com; HttpOnly
Accept-Ranges: none
Vary: Accept-Encoding
Content-Type: text/html; charset=ISO-8859-1
Connection: keep-alive
Proxy-Connection: keep-alive

root@kube-master:/# env |grep -i proxy
HTTP_PROXY=http://10.0.2.2:8079
FTP_PROXY=http://10.0.2.2:8079
https_proxy=http://10.0.2.2:8079
http_proxy=http://10.0.2.2:8079
no_proxy=localhost,127.0.0.*,10.*,192.168.*,*.local
NO_PROXY=localhost,127.0.0.*,10.*,192.168.*,*.local
HTTPS_PROXY=http://10.0.2.2:8079
ftp_proxy=http://10.0.2.2:8079
root@kube-master:/#
codylane commented 5 years ago

I'm not sure I have enough info to help based off the information provided but I'd love to know if the 2.0.0 version of this plugin solves this issue? If you are using docker-ce and and one of the more recent builds of docker I believe I've sorted out this issue. I'd love know for sure though, so please do try installing the newest release and report back.

For your convenience I've implemented the docker feature in th into the 2.0.0 release of this plugin based of these docs https://docs.docker.com/network/proxy/#configure-the-docker-client

ozbillwang commented 5 years ago

Thanks @rlaveycal

I got new error now

root@94082d0cf3d5:/# docker pull alpine
Using default tag: latest
Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I can access internet in dind

root@ubuntu-xenial:~# docker exec -ti 94 bash
root@94082d0cf3d5:/# curl -s -I www.google.com
HTTP/1.1 200 OK
Date: Wed, 09 Jan 2019 05:45:26 GMT
Expires: -1
Cache-Control: private, max-age=0
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."

I can pull image on vagrant box

root@94082d0cf3d5:/# exit
exit
vagrant@ubuntu-xenial:~$ docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
cd784148e348: Pull complete
Digest: sha256:46e71df1e5191ab8b8034c5189e325258ec44ea739bba1e5645cff83c9048ff1
Status: Downloaded newer image for alpine:latest
vagrant@ubuntu-xenial:~$
codylane commented 5 years ago

Hello - I'm sorry to hear that you are still having problems with docker in docker inside of Vagrant. I've honestly not had much experience doing docker in docker and I'm not sure that the way this was originally implemented will support this setup. I remember trying to get it to work but ran into issues but I cannot remember specific issue however. :(

I do know that using the docker provider does work if docker-ce is installed on the vagrant VM and you fire off a container inside that VM. I've also implemented support for the docker client to use the newer features of docker so that you don't have to use docker run --env http_proxy.... according to the docs I provided in my last response.

But yeah if you can share your Vagrantfile and how you have docker setup as well as how you are provisioning your container it might help. I cannot promise a fix but I'll do the best I can to help.

ozbillwang commented 5 years ago

the Vagrantfile is

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  config.proxy.http     = "http://10.0.2.2:8079"
  config.proxy.https    = "http://10.0.2.2:8079"
  config.proxy.ftp      = "http://10.0.2.2:8079"
  config.proxy.no_proxy = "localhost,127.0.0.*,10.*,192.168.*,*.local"
end
codylane commented 5 years ago

Thank you for sending this along.

I am making some assumptions that you are firing up this ubuntu box, then installing docker-ce manually inside the VM? If so, could you please provide a gist of all the steps you take to get docker installed inside this vagrant box? Without this information I cannot provide much help.

codylane commented 5 years ago

No further information received and I cannot reproduce this behavior. Closing this issue.