首页 > 其他分享 >docker apt-get update失败问题解决

docker apt-get update失败问题解决

时间:2023-06-02 13:56:50浏览次数:52  
标签:get list update apt etc sources ubuntu com

一、问题描述
docker容器相当于linux系统的精简版,内部很多指令是无法直接使用的,例如vim指令,为了使用vim指令,我们需要进入容器内部进行安装,安装步骤为:

apt-get update 
apt-get install vim 

很多时候我们发现安装会失败,这里是由于下载源问题。
二、解决方案
1.进入宿主机下
cd /etc/docker

编辑daemon.json文件,改为如下

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

2.重启docker
systemctl restart docker
3.进入需要安装指令的容器内部
docker exec -it xxx /bin/bash
4.执行apt-get update 命令可能会出错

执行apt-key adv添加
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
5.docker容器内部进入/etc/apt/目录

// 进入apt目录
cd /etc/apt/
// 备份 source.list
cp source.list source.list2
// 执行下面命令添加apt镜像源
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list

6.再次执行以下命令,如果失败多执行几次

apt-get update 
apt-get install vim

标签:get,list,update,apt,etc,sources,ubuntu,com
From: https://www.cnblogs.com/xiaojianwen/p/17451567.html

相关文章

  • VMware vSphere 8.0 Update 1a 正式版发布 - 企业级工作负载平台
    VMwarevSphere8.0Update1a正式版发布-企业级工作负载平台ESXi8.0U1&vCenterServer8.0U1请访问原文链接:https://sysin.org/blog/vmware-vsphere-8-u1/,查看最新版。原创作品,转载请保留出处。作者主页:sysin.org2023-06-01,VMwarevSphere8.0U1a发布。ESXi8.0......
  • 使用you-get下载网站视频
    使用you-get下载网站视频you-get是一个跨平台命令行视频、音频与图像下载工具,支持常用的各种多媒体网站。文章目录使用you-get下载网站视频一、安装先决条件1.pip安装2.通过[Antigen](https://github.com/zsh-users/antigen)安装(适用于Zsh用户)3.GitHub下载4.GitHub克隆5.升级二......
  • mapState 与 mapGetters
    1.mapState方法:用于映射state中的数据为计算属性computed:{...mapState({sum:'sum',school:'school'}),...mapState(['sum','school']),}2.mapGetters方法:用于映射getters中的数据为计算属性computed:{...mapGetters({bigSum:......
  • 07 Adapter 模式 - Class Adapter
    DesignPattern:Adapter模式-ClassAdapterAdapter模式的另一种作法是ClassAdapter模式,在这个模式下,Adapter直接继承Adaptee(要引进的新类别),以拥有当中的成员及方法,在C++中的话可以这么作: C++中可以多重继承,但在Java中不行,所以在Java中若要采用ClassAdapter,必须作点修改,一方......
  • shell命令:getevent和sendevent
    1.getevent输出所有event设备的基本信息 输出格式:设备名:事件type事件code事件value注意:这里的数字都是16进制。getevent-c10//输出10条信息后退出getevent-l//将type、code、value以对应的常量名称显示使用getevent-l命令后输出结果格式为:  对应的数字代码转......
  • Get请求
     GET不支持GetRequestStream(),所以不能写进去:stringbaseUrl="http://";stringtoken="";try{HttpWebRequestrequest=(HttpWebRequest)HttpWebRequest.Create(......
  • Arc get_mut
    ///Returnsamutablereferenceintothegiven`Arc`,ifthereare///noother`Arc`or[`Weak`]pointerstothesameallocation.//////Returns[`None`]otherwise,becauseitisnotsafeto///mutateasharedvalue.//////See......
  • Spring boot 使用 jpa 动态插入@DynamicInsert和动态更新@DynamicUpdate(动态指部分或
    @DynamicInsert属性:设置为true,设置为true,表示insert对象的时候,生成动态的insert语句,如果这个字段的值是null就不会加入到insert语句当中.默认false。比如希望数据库插入日期或时间戳字段时,在对象字段为空的情况下,表字段能自动填写当前的sysdate。@DynamicUpdate属性:设置为tru......
  • MyBatis+Sharding-JDBC实体类LocalDateTime类型字段查询报SQLFeatureNotSupportedExce
    问题最近协助渠道组开发新需求,封装实现了一个公共模块供不同渠道项目使用。以前各个渠道项目有很多相似的菜单和功能,各自项目里自己的代码实现,本公共模块对新需求的功能点进行抽象,减少重复代码,提高模块复用性和可维护性。目前有2个渠道项目接入了该公共模块,自测时发现其中1个运......
  • 9. 子查询/INSERT/UPDATE/DELETE/REPLACE(未完成)
    一.子查询子查询就是指在一个select语句中嵌套另外一个select语句。同时子查询必须包含括号。MySQL5.6之前,子查询的性能较差,但是从5.6开始,不存在性能差的问题。selectafromt1wherea>any(selectafromt2);1.selectafromt1是外部查询(outerquery)2.(selectafro......