Docker containers not using host DNS in boot2docker

前端 未结 2 828
庸人自扰
庸人自扰 2021-01-18 12:23

I am running boot2docker on my Mac. OSX version 10.9.3 boot2docker version 4.3.12 Docker version 0.12.0

The boot2docker image is a vagrant box, using virtualbox. I

相关标签:
2条回答
  • 2021-01-18 12:35

    I found a fix. It appears that the boot2docker image runs the docker daemon before it pulls the DNS from the host. So boot2docker thinks the DNS is set to 127.0.0.1 when it boots, then the machine changes it to the correct nameserver.

    The fix is to restart the docker daemon after the image has booted. In vagrant, I did this by adding the below command in the appropriate place in my Vagrantfile:

    config.vm.provision :shell, inline: "/etc/init.d/docker restart"
    

    It looks like this is a known issue in boot2docker that will be fixed in an upcoming version: https://github.com/boot2docker/boot2docker/issues/357

    0 讨论(0)
  • 2021-01-18 12:54

    credit to @oillio for the issue link and the discussion inside.

    It happens in Windows 7 environment as well using boot2docker 1.0.1, I follow the suggestion in https://github.com/boot2docker/boot2docker/issues/357

    $ sudo udhcpc   # refresh the DHCP 
    $ sudo /etc/init.d/docker restart # restart the service
    
    0 讨论(0)
提交回复
热议问题