make docker报错 Temporary failure resolving解决方法

make docker 时执行到命令RUN apt-get update && apt-get install -y netcat && rm -rf /var/cache/apt 时出现以下错误

Err:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu xenial InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'

网上大多的解决方案是修改/etc/resolv.conf ,添加nameserver。
在我的测试环境上实际上是不好使的。

修改以下文件

sudo vim  /etc/default/docker
将 DOCKER_OPTS前的#去掉,使
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4" 生效。

重启docker

sudo service docker restart

然后重新执行 make docker 。

你可能感兴趣的:(docker)