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

后端 未结 15 2119
日久生厌
日久生厌 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:26

    After adding local dns ip to default docker file it started working for me... please find the below steps...

    $ nm-tool # (will give you the dns IP)
    

    DNS : 172.168.7.2

    $ vim /etc/default/docker # (uncomment the DOCKER_OPTS and add DNS IP)
    DOCKER_OPTS="--dns 172.168.7.2 --dns 8.8.8.8 --dns 8.8.4.4"
    
    $ rm `docker ps --no-trunc -aq` # (remove all the containers to avoid DNS cache)
    
    $ docker rmi $(docker images -q) # (remove all the images)
    
    $ service docker restart #(restart the docker to pick up dns setting)
    

    Now go ahead and build the docker... :)

提交回复
热议问题