vagrant-landrush / landrush

A Vagrant plugin that provides a simple DNS server for Vagrant guests
MIT License
666 stars 78 forks source link

Landrush and docker #293

Open ianmiell opened 7 years ago

ianmiell commented 7 years ago

I seem to be seeing issues using landrush when installing docker on guests.

No landrush - OK:

Vagrant.configure("2") do |config|
  #config.landrush.enabled = true
  config.vm.provider "virtualbox" do |vb|
    vb.gui = false
    vb.memory = "1024"
  end

  config.vm.define "swarm1" do |swarm1|
    swarm1.vm.box = "centos/7"
    swarm1.vm.hostname = "swarm1.vagrant.test"
  end
end
[root@swarm1 ~]# systemctl start docker
[root@swarm1 ~]# docker run -d alpine
Unable to find image 'alpine:latest' locally
Trying to pull repository docker.io/library/alpine ... 
latest: Pulling from docker.io/library/alpine
3690ec4760f9: Pull complete 
Digest: sha256:1354db23ff5478120c980eca1611a51c9f2b88b61f24283ee8200bf9a54f2e5c
Status: Downloaded newer image for docker.io/alpine:latest

Landrush - fails:

Vagrant.configure("2") do |config|
  config.landrush.enabled = true
  config.vm.provider "virtualbox" do |vb|
    vb.gui = false
    vb.memory = "1024"
  end

  config.vm.define "swarm1" do |swarm1|
    swarm1.vm.box = "centos/7"
    swarm1.vm.hostname = "swarm1.vagrant.test"
  end
end
[root@swarm1 ~]# systemctl start docker
[root@swarm1 ~]# docker run -d alpine
Unable to find image 'alpine:latest' locally
Trying to pull repository docker.io/library/alpine ... 
Get https://registry-1.docker.io/v2/library/alpine/manifests/latest: Get https://auth.docker.io/token?scope=repository%!A(MISSING)library%!F(MISSING)alpine%!A(MISSING)pull&service=registry.docker.io: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
docker: Get https://registry-1.docker.io/v2/library/alpine/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Falpine%3Apull&service=registry.docker.io: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See '/usr/bin/docker-current run --help'.

[root@swarm1 ~]# docker run -d alpine
Unable to find image 'alpine:latest' locally
Trying to pull repository docker.io/library/alpine ... 
latest: Pulling from docker.io/library/alpine
3690ec4760f9: Pulling fs layer 
Get https://registry-1.docker.io/v2/library/alpine/blobs/sha256:baa5d63471ead618ff91ddfacf1e2c81bf0612bfeb1daf00eb0843a41fbfade3: dial tcp: lookup registry-1.docker.io on 10.0.2.2:53: no such host
docker: Get https://registry-1.docker.io/v2/library/alpine/blobs/sha256:baa5d63471ead618ff91ddfacf1e2c81bf0612bfeb1daf00eb0843a41fbfade3: dial tcp: lookup registry-1.docker.io on 10.0.2.2:53: no such host.
See '/usr/bin/docker-current run --help'.

Interestingly, I get different errors - dial tcp sometimes, sometimes parts download (as per above). Sometimes, restarting docker can 'help' get a layer or two before it fails again.

I tried, per the troubleshooting steps:

[root@swarm1 ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=63 time=5.98 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=63 time=6.06 ms

I did a bit of googling and it looks like similar issues are seen with Docker on Mac, but pretty quickly I'm out of my comfort zone.

I'm using Linux and Virtualbox.

ianmiell commented 7 years ago

Tried on Mac and got same result:

[root@swarm1 ~]# docker pull swarm
Using default tag: latest
Trying to pull repository docker.io/library/swarm ... 
latest: Pulling from docker.io/library/swarm
220609e0bc51: Pulling fs layer 
b54bf338fe2f: Pulling fs layer 
d53aac5750d5: Pulling fs layer 
Get https://registry-1.docker.io/v2/library/swarm/blobs/sha256:942fd5fd357e2fe2fcecbaf3dd77c313f22ce18a84a5a4d288c0df407a61e623: dial tcp: lookup registry-1.docker.io on 10.0.2.3:53: no such host
Get https://registry-1.docker.io/v2/library/swarm/blobs/sha256:942fd5fd357e2fe2fcecbaf3dd77c313f22ce18a84a5a4d288c0df407a61e623: dial tcp: lookup registry-1.docker.io on 10.0.2.3:53: no such host
Bekt commented 7 years ago

Try disabling the DNS server on the guest:

config.landrush.guest_redirect_dns = false
ianmiell commented 7 years ago

Thanks - tried this but it did not work for me. Apologies I didn't retain the details. I ended up resolving with this code:


            # Workaround for docker networking issues + landrush.                                                                                                    
            shutit.send('''echo "$(host -t A index.docker.io | grep has.address | head -1 | awk '{print $NF}') index.docker.io" >> /etc/hosts''')                    
            shutit.send('''echo "$(host -t A registry-1.docker.io | grep has.address | head -1 | awk '{print $NF}') registry-1.docker.io" >> /etc/hosts''')  
hferentschik commented 5 years ago

@ianmiell, still an issue?