Docker中apt-update遇到Temporary failure resolving ‘deb.debian.org‘的解决方法

问题描述

最近运行一个docker服务,结果在apt-get update的时候出现了如下异常,换了sources.list中的源后也还是没有效果。

Err:1 http://deb.debian.org/debian buster/main amd64 perl-base amd64 5.28.1-6+deb10u1
  Temporary failure resolving 'deb.debian.org'
Ign:2 http://deb.debian.org/debian buster/main amd64 apt amd64 1.8.2.3
Err:3 http://deb.debian.org/debian buster/main amd64 libestr0 amd64 0.1.10-2.1
  Temporary failure resolving 'deb.debian.org'
Err:4 http://deb.debian.org/debian buster/main amd64 libfastjson4 amd64 0.99.8-2
  Temporary failure resolving 'deb.debian.org'
Err:5 http://deb.debian.org/debian buster/main amd64 liblognorm5 amd64 2.0.5-1
  Temporary failure resolving 'deb.debian.org'
Err:6 http://deb.debian.org/debian buster/main amd64 rsyslog amd64 8.1901.0-1
  Temporary failure resolving 'deb.debian.org'
Err:7 http://deb.debian.org/debian buster/main amd64 perl-modules-5.28 all 5.28.1-6+deb10u1
  Temporary failure resolving 'deb.debian.org'
Err:8 http://deb.debian.org/debian buster/main amd64 libgdbm-compat4 amd64 1.18.1-4
  Temporary failure resolving 'deb.debian.org'
Err:9 http://deb.debian.org/debian buster/main amd64 libperl5.28 amd64 5.28.1-6+deb10u1
  Temporary failure resolving 'deb.debian.org'
Err:10 http://deb.debian.org/debian buster/main amd64 perl amd64 5.28.1-6+deb10u1
  Temporary failure resolving 'deb.debian.org'
Err:11 http://deb.debian.org/debian buster/main amd64 libpython2.7-minimal amd64 2.7.16-2+deb10u1
  Temporary failure resolving 'deb.debian.org'

解决方法

出现这个问题的原因在于DNS服务解析异常,解决的方法也很简单,只需要修改/etc/docker/daemon.json加入如下内容即可(如果没有这个文件则创建之)

{                                                                          
    "dns": ["8.8.8.8", "114.114.114.114"]                                                                           
} 

最后重启docker服务,系统即可正常解析镜像网站并运行

systemctl restart docker

参考链接

  • docker内使用apt-get update时报Temporary failure resolving 'security.ubuntu.com错的解决方法

你可能感兴趣的:(Docker,问题排查,Linux,docker,容器,运维,debian)