docker内安装vim报错,Unable to correct problems, you have held broken packages.

我用Dockerfile创建完镜像,运行容器,在容器内安装vim命令的时候会报错,错误如下:

The following packages have unmet dependencies:
 vim : Depends: libpython3.5 (>= 3.5.0~b1) but it is not going to be installed
       Depends: libtinfo5 (>= 6) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

解决:
说明容器内缺少依赖,按照提示安装需要的依赖即可,之后可能还会提示缺少其他的依赖,提示缺少什么,安装什么即可.

apt-get install libtinfo5  
apt-get install libpython3.5

刚进入容器时,使用apt-get install vim的时候会提示: E: Unable to locate package vim
这个错误更新一下下载源.
步骤:
(1) source.list 文件添加到 /et/apt目录下
(2)执行下面的三个命令,添加公钥,在没有添加公钥的时候,执行apt-get update的命令时会报错,提示缺少公钥,所以要添加公钥.

apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com EF0F382A1A7B6500

(3)更新下载源apt-get update

source.list的内容:

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

你可能感兴趣的:(docker)