在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. 【转】用VMware 8安装Ubuntu 12.04详细过程(图解)

    图解演示环境版本: 本机系统: WIN7 虚拟机:VMware Workstation 8 (英文版) 安装目标:Ubuntu Desktop 12.04 LTS  (请点击这里)先下载好iso镜像文 ...

  2. java8时间处理实例

    实例: package com.javaBase.time; import java.time.Clock; import java.time.LocalDate; import java.time. ...

  3. 【spring boot】【redis】spring boot 集成redis的发布订阅机制

    一.简单介绍 1.redis的发布订阅功能,很简单. 消息发布者和消息订阅者互相不认得,也不关心对方有谁. 消息发布者,将消息发送给频道(channel). 然后是由 频道(channel)将消息发送 ...

  4. Markdown温故知新(2):详解七大标准语法

    1.标题 2.强调(粗体 & 斜体) 3.列表 4.链接 & 图片 5.代码块 6.引用 7.分割线 8.总结 说明:在 Markdown 中,一行是指由换行符或回车符之外的字符构成的 ...

  5. Python【day 8】文件

    一.文件操作 open(文件路径,mode='模式',encoding='utf-8')模式:r w a rb wb ab r+ w+ a+ r+b w+b a+b常用的:r w ab表示字节,处理费 ...

  6. 基于YOLO3对图像加框的函数draw_image()

    def draw_bbox(image, bboxes, class_i, show_label=True): # 将中心点坐标与w,h通过变化为左上角与右下角坐标 bboxes_change = n ...

  7. vue+element省市县的二级联动功能

    项目中有选择省市县的需求,先选择省,再选择县 解决这个需求也不是很难,总体思路就是看后端接口, 一般后端接口都是请求参数为 0 返回省的数据,不为 0 的话返回相对应的市的数据 template代码: ...

  8. 易语言 MD5生成

    下载MD5脚本 https://download.csdn.net/download/zhangxuechao_/10573121 添加脚本组件 定义常量 生成MD5

  9. mongo find 时间条件过滤

    db.order.find({"order_time":{"$gte": new Date("Tue Jan 01 2017 00:00:00 GMT ...

  10. 综合架构之Rsync备份服务,服务端和客户端配置

    服务端配置(即备份服务器) ps:客户端配置见下方 配置一个新服务的步骤: 第一步:先将该服务下载 yum install -y rsync 第二步:编写服务配置文件 配置文件:/etc/rsyncd ...