Ubuntu下docker容器中bash: vim(vi): command not found

 解决办法(所有的执行都要在docker终端里面)

  1. 正常情况下列代码可以解决
# apt-get update
# apt-get install vim

 

 2.我碰到的情况

#报错信息
Err http://security.debian.org jessie/updates/main amd64 Packages
  404  Not Found [IP: 151.101.194.132 80]
Get:3 http://archive.debian.org jessie/main amd64 Packages [9098 kB]
Err http://archive.debian.org jessie-updates/main amd64 Packages

Err http://archive.debian.org jessie-updates/main amd64 Packages

Err http://archive.debian.org jessie-updates/main amd64 Packages

Err http://archive.debian.org jessie-updates/main amd64 Packages

Err http://archive.debian.org jessie-updates/main amd64 Packages
  404  Not Found [IP: 209.87.16.41 80]
Fetched 9249 kB in 12s (725 kB/s)
W: GPG error: http://archive.debian.org jessie Release: The following signatures were invalid: KEYEXPIRED 1587841717
W: Failed to fetch http://security.debian.org/dists/jessie/updates/main/binary-amd64/Packages  404  Not Found [IP: 151.101.194.132 80]

W: Failed to fetch http://archive.debian.org/debian/dists/jessie-updates/main/binary-amd64/Packages  404  Not Found [IP: 209.87.16.41 80]

E: Some index files failed to download. They have been ignored, or old ones used instead.
root@6dc2842c0eef:/usr/src/app/_site# cat /etc/*release

 现在情况是vim 、vi、nano都用不了因为没有升级apt-get,因为签名无效、版本失效

然后chargpt说要填入

#  sh -c "echo 'deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse' >> /etc/apt/sources.list"
# sh -c "echo 'deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse' >> /etc/apt/sources.list"
# sh -c "echo 'deb http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse' >> /etc/apt/sources.list"

 

#  sh -c "echo 'deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse' >> /etc/apt/sources.list"

随后再次更新apt-get update报了以下错误:

#报错信息
W: GPG error: http://security.ubuntu.com bionic-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.ubuntu.com bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.ubuntu.com bionic-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
W: GPG error: http://archive.ubuntu.com bionic-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32
W: Duplicate sources.list entry http://archive.ubuntu.com/ubuntu/ bionic/main amd64 Packages (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_main_binary-amd64_Packages.gz)
W: Duplicate sources.list entry http://archive.ubuntu.com/ubuntu/ bionic/restricted amd64 Packages (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_restricted_binary-amd64_Packages.gz)

这些错误是由于没有公钥来验证Ubuntu软件包的签名而导致的。可以使用以下命令来解决此问题:

  1. 先获取丢失密钥的KEYID(例如3B4FE6ACC0B21F32): 【报错信息  because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32】  最后这个是KEYID

  2. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEYID
  3. 对于以上输出中的每个NO_PUBKEY,都执行相应的APT密钥操作。例如,对于“3B4FE6ACC0B21F32”,执行以下操作

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
  4. 最后再次运行更新

    sudo apt-get update

另外还要注意,在给定的/sources.list文件中不能有重复的条目,因为它会导致无法验证软件包的完整性。如果存在重复的条目,则可以删除其中一个以解决。

到这里apt-get update已经能够正常更新了,没有报错

但是下载vim还是失败的:

#报错信息
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libc6-dev : Breaks: binutils (< 2.26) but 2.25-5 is to be installed
W: Duplicate sources.list entry http://archive.ubuntu.com/ubuntu/ bionic/main amd64 Packages (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_main_binary-amd64_Packages.gz)
W: Duplicate sources.list entry http://archive.ubuntu.com/ubuntu/ bionic/restricted amd64 Packages (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_restricted_binary-amd64_Packages.gz)
W: You may want to run apt-get update to correct these problems
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

 解决办法1(对我没用):

可以使用 "apt-get install -f" 命令尝试修复该错误

解决办法2:

这将卸载较旧版本的 binutils 并安装 libc6-dev 软件包。

apt-get remove binutils
apt-get install libc6-dev

然后就再次执行

apt-get update

这个时候再次更新vim(不出意外来到这一步应该是可以正常用了)

apt-get install vim

 【我的比较阴间,来到这一步还是报没有找到。通过以下步骤才成功

"apt-get install -f" 命令尝试修复该错误
apt-get install vim

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值