Docker build “Could not resolve 'archive.ubuntu.com'” apt-get fails to install anything

后端 未结 15 2123
日久生厌
日久生厌 2020-11-28 17:45

I\'ve been trying to run Docker build on various files which previously worked before, which are now no longer working.

As soon as the Docker file included any line

15条回答
  •  春和景丽
    2020-11-28 18:24

    I just wanted to add a late response for anyone coming across this issue from search engines.

    Do NOT do this: I used to have an option in /etc/default/docker to set iptables=false. This was because ufw didn't work (everything was opened even though only 3 ports were allowed) so I blindly followed the answer to this question: Uncomplicated Firewall (UFW) is not blocking anything when using Docker and this, which was linked in the comments

    I have a very low understanding of iptables rules / nat / routing in general, hence why I might have done something irrational.

    Turns out that I've probably misconfigured it and killed DNS resolution inside my containers. When I ran an interactive container terminal: docker run -i -t ubuntu:14.04 /bin/bash

    I had these results:

    root@6b0d832700db:/# ping google.com
    ping: unknown host google.com
    
    root@6b0d832700db:/# cat /etc/resolv.conf
    search online.net
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    
    root@6b0d832700db:/# 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=56 time=1.76 ms
    64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=1.72 ms
    

    Reverting all of my ufw configuration (before.rules), disabling ufw and removing iptables=false from /etc/default/docker restored the DNS resolution functionality of the containers.

    I'm now looking forward to re-enable ufw functionality by following these instructions instead.

提交回复
热议问题