欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 会展 > 在Ubuntu上安装指定版本Docker

在Ubuntu上安装指定版本Docker

2024/10/23 15:23:17 来源:https://blog.csdn.net/weixin_52582573/article/details/143097936  浏览:    关键词:在Ubuntu上安装指定版本Docker

在Ubuntu上安装指定版本Docker

1. 删除原有docker

sudo apt-get remove docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
sudo rm -rf /etc/docker
sudo rm /etc/systemd/system/docker.service
sudo rm /etc/systemd/system/docker.socket

2. 更新现有的包

首先,确保你的系统包是最新的:

sudo apt update
sudo apt upgrade

2. 安装依赖包

Docker需要一些依赖包来正常运行,先安装这些依赖包:

sudo apt-get install ca-certificates curl gnupg

3. 信任 Docker 的 GPG 公钥并添加仓库

install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \tee /etc/apt/sources.list.d/docker.list > /dev/null

4. 安装Docker

更新APT包索引并安装Docker:

sudo apt update
apt-cache madison docker-ce #查看可提供docker版本
sudo apt install docker-ce=5:20.10.10~3-0~ubuntu-focal docker-ce-cli=5:20.10.10~3-0~ubuntu-focal containerd.io
sudo apt-mark hold docker-ce docker-ce-cli containerd.io #防止docker更新升级

6. 验证Docker安装

安装完成后,可以通过以下命令验证Docker是否正确安装:

sudo docker --version

7. 启动并设置Docker开机启动

使用以下命令启动Docker并设置它在系统启动时自动启动:

sudo systemctl start docker
sudo systemctl enable docker

8. 运行Docker测试镜像

通过运行一个测试镜像来验证Docker是否正常运行:

sudo docker run hello-world

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com