Empty /etc/resolver.conf
lox opened this issue · comments
When I've booted my VM, I see an empty /etc/resolver.conf and I can't resolve DNS addresses inside my VM.
This is the bug: https://bugs.busybox.net/show_bug.cgi?id=6788
This seems to be the fix: boot2docker/boot2docker#129 (comment)
Hrm, odd. I wonder why my /etc/resolver.conf
is empty.
I've known that issue, because a few users have reported to me on Twitter.
But I've never seen that on my side and never tried the fix.
Let me investigate for a while.
For now, please put the following at the top of Vagrantfile and try it.
config.vm.provision :shell do |s|
s.inline = <<-EOT
sudo /sbin/udhcpc
cat /etc/resolv.conf
EOT
end
Thanks.
0.9.0, with the latest VirtualBox and Docker 1.6.2.
That works nicely, thank you.
Thanks. That's nice to hear.
Anyway I will comment here when I get something.
VM created by init does not have DNS set up correctly · Issue #102 · boot2docker/boot2docker-cli
boot2docker/boot2docker-cli#102
jpetazzo/pipework
https://github.com/jpetazzo/pipework
If you use VirtualBox, you will have to update your VM network settings. Open the settings panel for the VM, go the the "Network" tab, pull down the "Advanced" settings. Here, the "Adapter Type" should be pcnet (the full name is something like "PCnet-FAST III"), instead of the default e1000 (Intel PRO/1000). Also, "Promiscuous Mode" should be set to "Allow All". If you don't do that, bridged containers won't work, because the virtual NIC will filter out all packets with a different MAC address. If you are running VirtualBox in headless mode, the command line equivalent of the above is modifyvm --nicpromisc1 allow-all. If you are using Vagrant, you can add the following to the config for the same effect:
config.vm.provider "virtualbox" do |v|
v.customize ['modifyvm', :id, '--nicpromisc1', 'allow-all']
end
Ooops, I closed accidentally. Re-opened.
https://bugs.busybox.net/show_bug.cgi?id=6788
However, using scripts which rewrite resolv.conf
only based on DHCP data is bound to be problematic
in a lot of non-trivial networking setups.
You can't fix the script to work well for everybody.Please read http://busybox.net/~vda/no_ifup.txt
In conclusion, I think the best solution for now is
config.vm.provision :shell do |s|
s.inline = <<-EOT
sudo /sbin/udhcpc
cat /etc/resolv.conf
EOT
end
Final version
# Fix busybox/udhcpc issue
config.vm.provision :shell do |s|
s.inline = <<-EOT
if ! grep -qs ^nameserver /etc/resolv.conf; then
sudo /sbin/udhcpc
fi
cat /etc/resolv.conf
EOT
end
Wrapup
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "yungsang/boot2docker"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.synced_folder ".", "/vagrant", type: "nfs"
# Fix busybox/udhcpc issue
config.vm.provision :shell do |s|
s.inline = <<-EOT
if ! grep -qs ^nameserver /etc/resolv.conf; then
sudo /sbin/udhcpc
fi
cat /etc/resolv.conf
EOT
end
# Adjust datetime after suspend and resume
config.vm.provision :shell do |s|
s.inline = <<-EOT
sudo /usr/local/bin/ntpclient -s -h pool.ntp.org
date
EOT
end
end
boot2docker/boot2docker#468
Confirmed, it won't need sudo /usr/local/bin/ntpclient -s -h pool.ntp.org
any more on resume