解决ubuntu容器缺少vim,且无法apt-get update问题,亲测可用

1.在宿主机上新建sources.list,拷贝到容器:

 

在宿主机新建 sources.list,内容如下(阿里的apt源)

docker cp sources.list  目标容器:/etc/apt

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

## Not recommended
# deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

2.在容器内运行apt-get update

如果有报错如下:

Err:1 http://mirrors.ustc.edu.cn/ubuntu xenial InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY **** NO_PUBKEY ****

Reading package lists... Done
W: GPG error: http://mirrors.ustc.edu.cn/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY **** NO_PUBKEY ****
E: The repository 'http://mirrors.ustc.edu.cn/ubuntu xenial InRelease' is not signed.

 

解决办法:等待1分钟

将公钥添加至服务器,即终端中输入

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys '公钥编码'

添加成功后终端输出为

gpg: key '公钥编码': public key "xxxxxx" imported

gpg: Total number processed: 1

gpg:                        imported: 1

 

然后运行apt-get update

 

3.最后 apt-get intsall vim 可用

 

 

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三尾鱼网络科技

如果对您有帮助,赠人玫瑰手留余

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值