在docker 容器中执行apt-get update有时候会报错,当然造成错误的原因有很多情况,具体情况具体分析,

APT Hash sum mismatch错误的常见解决方法总结这篇博客写的不错,在此感谢博主提供的思路。

以下是本人解决docker容器中执行apt-get update报错的解决办法(踩了好多坑,血淋淋的阿,终于好用了。):

root@33c5b2ae7edc:/# apt-get update
Err:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu xenial-security InRelease
Temporary failure resolving 'security.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'
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
<1> 首先配置docker容器的DNS

cat /etc/resolv.conf       该命令查看容器和宿主机的DNS设置,容器和宿主机的DNS设置应该一致。

docker DNS的设置可以通过启动容器时添加参数  --dns  8.8.8.8  来设置(本次有效)

或者通过 /etc/default/docker的DNS参数来进行永久设置,然后重启DOCKER生效,

export http_proxy="http://10.1.9.100:808/"
   DOCKER_OPTS="--dns 210.83.210.155 --dns 127.0.1.1"

sudo service docker restart

<2> 查看容器 /etc/apt/目录中是否有apt.conf文件,该文件配置了代理:

Acquire::http::proxy "http://10.1.9.100:8080/";
Acquire::ftp::proxy "ftp://10.1.9.100:8080/";
Acquire::https::proxy "https://10.1.9.100:8080/";
如果没有该文件,可以将宿主机中的apt.conf文件拷贝到容器对应目录中。

<3>对代理服务器进行设置:

还有些开发者遇到的问题,是因为公司的Proxy的设置。
如果读者朋友使用了Proxy,那么可以尝试,在容器的 /etc/apt/apt.conf.d/ 目录下创建一个名称为99fixbadproxy 的文件

$ sudo gedit /etc/apt/apt.conf.d/99fixbadproxy
把以下文本复制到上述文件中,然后保存退出:

Acquire::http::Pipeline-Depth 0;
Acquire::http::No-Cache true;
Acquire::BrokenProxy true;
<4> 清cache缓存:

$ sudo apt-get clean
$ sudo apt-get update --fix-missing
<5> 可以更改APT源,网上有挺多的国内源,可以搜索更改办法。

Docker ubuntn 使用apt-get update报错的更多相关文章

  1. Ubuntu遇到apt-get update报错:"E: Could not get lock /var/lib/apt/lists/lock"

    sudo apt-get update报错:"E: Could not get lock /var/lib/apt/lists/lock" 出现此问题的原因可能是有另外一个程序在运 ...

  2. kali linux 2.0配置更新源后apt-get update 报错

    这个是我/etc/apt/sources.list的更新源: deb http://http.kali.org/kali kali-rolling main contrib non-free deb ...

  3. apt-get update 报错 W: Unknown Multi-Arch type 'no' for package 'compiz-core'

    源 #deb包 deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http:// ...

  4. mysql执行update报错1175解决方法

    mysql执行update报错 update library set status=true where 1=1 Error Code: 1175. You are using safe update ...

  5. mysql执行update报错 Err] 1055 - 'information_schema.PROFILING.SEQ' isn't in GROUP BY

    mysql执行update报错 Err] 1055 - 'information_schema.PROFILING.SEQ' isn't in GROUP BY 今天开发的同事发来如下错误信息,最最简 ...

  6. docker Failed to get D-Bus connection 报错 docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash

    docker Failed to get D-Bus connection 报错 原创憬薇2016-01-15 11:25:26评论(10)40278人阅读   在centos7的容器里面出现了一个B ...

  7. ROS的安装-> rosdep init /update报错2022.02.24实测有效

    ROS的安装-> rosdep init /update报错2022.02.24实测有效   一. 解决rosdep_init问题 正常执行sudo rosdep init会报错,如下: ERR ...

  8. ubuntu 执行apt-get update报错Failed to fetch

    在ubuntu下执行sudo apt-get update时,经常会遇到报错: Err http://security.ubuntu.com precise-security InRelease Er ...

  9. Linux - Ubuntu下执行apt-get update报错:Some index files failed to download. They have been ignored, or old ones used instead.

    报错命令 root@ubuntu:/etc/apt# apt-get update Err: http://mirrors.aliyun.com/ubuntu trusty InRelease Cou ...

随机推荐

  1. Failed to instantiate [org.elasticsearch.client.transport.TransportClient]

    Springboot 集成 ElasticSearch,springboot报错如下: Error starting ApplicationContext. To display the auto-c ...

  2. pack URI

    WPF使用pack URI语法寻找资源. URI负责搜索如下位置的资源: 当前程序集 引用的程序集 相对于程序集的某个位置 应用程序的源站点 pack URI的格式:pack://机构/路径 机构指定 ...

  3. WebSocket实现Web端即时通信

    前言 WebSocket 是HTML5开始提供的一种在浏览器和服务器间进行全双工通信的协议.目前很多没有使用WebSocket进行客户端服务端实时通信的web应用,大多使用设置规则时间的轮询,或者使用 ...

  4. vue项目进入mui.js报错 typeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode .....

    在做项目时,引用mui报错如下 看样子就是不支持严格模式吧. 解决方法是在根目录 下的.babelrc文件里面添加过滤掉.不用严格模式

  5. c# 读取数据库得到dateset

    public DataSet GetCraftInformation(string connectionString, string opName, string productType)       ...

  6. Linux从入门到放弃、零基础入门Linux(第三篇):在虚拟机vmware中安装linux(二)超详细手把手教你安装centos6分步图解

    一.继续在vmware中安装centos6.9 本次安装是进行最小化安装,即没有图形化界面的安装,如果是新手,建议安装带图形化界面的centos, 具体参考Linux从入门到放弃.零基础入门Linux ...

  7. 基于开源博客系统(mblog)搭建网站

    基于开源博客系统(mblog)搭建网站 上一章讲了基于jpress部署的博客系统,这一章了解一下 mblog这个开源的基于springboot的博客系统,相比与jpress 的热度fork数量要少一些 ...

  8. 【会话技术】Cookie技术 案例:访问时间

    创建时间:6.30 代码: package cookie; import java.io.IOException; import java.text.SimpleDateFormat; import ...

  9. CodeForces 150E: Freezing with Style

    题目传送门:CF150E. 据说这个傻逼题还有一个 \(\log\) 的做法,但是我还不会. 题意简述: 给定一棵 \(n\)(\(2\le n\le 10^5\))个点的树,边有边权. 定义一条路径 ...

  10. 201871010123-吴丽丽《面向对象程序设计(Java)》第四周学习总结

    201871010123-吴丽丽<面向对象程序设计(Java)>第四周学习总结 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这 ...