Docker ubuntn 使用apt-get update报错
在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报错的更多相关文章
- 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" 出现此问题的原因可能是有另外一个程序在运 ...
- kali linux 2.0配置更新源后apt-get update 报错
这个是我/etc/apt/sources.list的更新源: deb http://http.kali.org/kali kali-rolling main contrib non-free deb ...
- 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:// ...
- mysql执行update报错1175解决方法
mysql执行update报错 update library set status=true where 1=1 Error Code: 1175. You are using safe update ...
- 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 今天开发的同事发来如下错误信息,最最简 ...
- 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 ...
- ROS的安装-> rosdep init /update报错2022.02.24实测有效
ROS的安装-> rosdep init /update报错2022.02.24实测有效 一. 解决rosdep_init问题 正常执行sudo rosdep init会报错,如下: ERR ...
- ubuntu 执行apt-get update报错Failed to fetch
在ubuntu下执行sudo apt-get update时,经常会遇到报错: Err http://security.ubuntu.com precise-security InRelease Er ...
- 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 ...
随机推荐
- 笔记本CPU性能排行
截图如下: 1. 图1 2. 图2 3. 4. 5. 6. 7. 8. 谢谢浏览!
- 浅谈mongodb内存
本文仅限于mongodb3.0.0(wiredtiger引擎) 一.mongodb内存使用 1.热数据 这一点是SQL和nosql之间的巨大差距,将热数据存在内存相当于自带cache,若wiredti ...
- SCCM+WSUS的方式分发补丁
简单来说,System Center Configuration Manager(SCCM/ConfigMgr)由SMS(Systems Management Server)发展而来,其作为一款针对企 ...
- JavaScript变量与数据类型
变量 javascript的变量很松散,每个变量初始仅仅用于保存一个占位符而已.定义变量的操作符是 var, var 后面跟着一个标识符--当作变量的名字. 比如: var myname;//定义了一 ...
- 转 Sqlserver_left join 、right join、 inner join 用法
https://www.cnblogs.com/ingstyle/p/4368064.html left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right joi ...
- netty框架概述
概述 最近在学习netty的相关知识,也在看netty的源码,光看不练假把式,所以也正好利用自己学习的机会写几篇netty的分析文章,主要还是一些源码解析的文章,一方面有输出会促使自己在看源码,学习原 ...
- SpringMVC-拦截器做一个登录认证的小Demo
拦截器 拦截器的定义 处理器拦截器类似于servlet开发中的filter,用于对处理器进行预处理和后处理. 定义拦截器,实现HandlerInterceptor这个接口 接口的实现需要导入包impo ...
- Kaldi语音识别快速入门
一.简介 Kaldi是使用C++编写的语音识别工具包,Apache License v2.0许可.主要供语音识别研究人员使用.Kaldi的目标和范围与HTK类似.目标是拥有易于修改和扩展的现代而灵活的 ...
- Windows上安装运行Spark
1.下载Scala: https://www.scala-lang.org/download/ ①注意:必须下载官方要求的JDK版本,并设置JAVA_HOME,否则后面将出现很多麻烦! ②Scala当 ...
- windows 给mysql安装innodb引擎
1.启用InnoDB 打开my.ini文件,找到[skip-innodb],在前面加# 2.更改数据库默认引擎为InnoDB 打开my.ini文件,更改[default-storage-e ...