docker-compose报错 、apt-get update 报错

在Ubuntu上安装docker-compose和docker时遇到依赖错误,如containerd.io无法安装。解决方案包括指定版本安装和更换为清华大学源。更改源文件,删除旧的docker安装,然后更新源并安装所需依赖。通过这些步骤,可以解决apt-get update的报错问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

之前很懒,加上工作忙,最近每天晚上都会更新
今天安装docker-compose 和docker 报了很多错,真的是绞尽脑汁
来个链接,
Ubuntu安装docker时出现 依赖: containerd.io (>= 1.2.2-3) 但是它将不会被安装 错误
这个连接,很棒,为了防止作者删除,copy一份

作者实测,还是第二个比较彻底,我自己就是阿里源,但是不咋好用

解决办法1(推荐大家使用解决办法2):

查看自己能安装的版本

apt-cache madison docker-ce

安装指定版本
=后面为你的版本号

sudo apt-get install docker-ce=17.12.0~ce-0~ubuntu

查看是否成功

sudo docker run hello-world

解决办法2

以上方法可以安装指定版本的,但是如果你还要安装最新版本的不行,下面就提供另一种方法,我是参考清华大学源网站安装的https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/

先把你Ubuntu的源修改为清华大学的源
这个网上有很多教程
我把我使用的源分享给大家,大家的/etc/apt/sources.list源文件可以改为以下:

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

如果你过去安装过 docker,先删掉:

sudo apt-get remove docker docker-engine docker.io

更新源

  sudo apt-get update

安装依赖:

sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common

信任 Docker 的 GPG 公钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

对于 amd64 架构的计算机,添加软件仓库:
我是Ubuntu16.04,同房时设置下载仓库路径为清华大学的,提高下载速度,好多人安装失败就是因为下载速度不行,因为你的下载路径可能是:"deb [arch=amd64] https://download.docker.com/linux/ubuntu "

  sudo add-apt-repository \
       "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
       $(lsb_release -cs) \
       stable"

如果你是树莓派或其它ARM架构计算机,请运行:

echo "deb [arch=armhf] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
     $(lsb_release -cs) stable" | \
    sudo tee /etc/apt/sources.list.d/docker.list

最后安装

sudo apt-get update
sudo apt-get install docker-ce

真的很神奇,换完源安装成功。

ok完事一个,下一个错比较简单

用阿里源,很容易报错 11 和 50 的错

root@ubuntu:/# apt-get remove docker docker-engine docker.io containerd runc
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

还有一个,找不到了
我一般就是,删除

sudo rm  /var/lib/dpkg/lock
sudo rm  /var/lib/dpkg/lock-frontend
sudo rm  /var/lib/dpkg/updates/*

然后再运行,apt-get update 就好使了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值