【Docker】Linux安装Docker(极简版)
2023-02-25 18:21:59 时间
概览
整个配置大致分为下面的步骤:
- 检查LInux内核版本,不能太老
- root权限更新yum
- 清理旧版本。
- 更换Docker镜像地址
- 安装Docker
1. 检查Linux内核版本
建议使用centerOs 7.9 以上的版本,内核基本上可以满足Docker的需求。
[zxd@localhost ~]$ uname -r
3.10.0-1160.el7.x86_64
2. root权限更新yum
个人Linux虚拟机使用了具备sudo权限的普通用户,所以命令有些许不同。
[zxd@localhost ~]$ sudo yum -y update
....
....
如果内核的版本低于3.1,则建议使用下面的命令升级到最新版的内核。
yum -y update:升级所有包同时也升级软件和系统内核;
yum -y upgrade:只升级所有包,不升级软件和系统内核
3. 清理旧版本
如果之前Linux安装过Docker,则需要先进行卸载。
卸载旧版本(如果之前安装过的话)
[zxd@localhost ~]$ sudo yum remove docker docker-common docker-selinux docker-engine
[sudo] password for zxd:
y[然后按回车]
4. 更换Docker镜像
如果Docker下载或者更新过慢,可以使用下面的镜像进行替换,第一个为中央镜像,第二个为阿里镜像。
yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
5. 安装Docker
5.1 安装依赖包
安装需要的软件包,可以使用yum-util
提供yum-config-manager
功能。我们可以执行下面的命令:
[zxd@localhost ~]$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
[sudo] password for zxd:
提示:device-mapper-persistent-data lvm2是驱动所需要的依赖
5.2 选择docker版本并安装
使用下面的命令选择合适的版本安装。
> yum list docker-ce --showduplicates | sort -r
* updates: mirrors.aliyun.com
This system is not registered with an entitlement server. You can use subscription-manager to register.
: manager
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-
* extras: mirrors.aliyun.com
docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable
......
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
这选择了18.03.1.ce-1.el7.centos
版本进行安装,具体的安装命令如下:
yum -y install docker-ce-18.03.1.ce
具体的运行日志如下,如果出现类似下面的日志,说明安装成功
setsebool: SELinux is disabled.
Installing : pigz-2.3.3-1.el7.centos.x86_64 2/4
Installing : libtool-ltdl-2.4.2-22.el7_3.x86_64 3/4
Installing : docker-ce-18.03.1.ce-1.el7.centos.x86_64 4/4
Verifying : libtool-ltdl-2.4.2-22.el7_3.x86_64 1/4
Verifying : pigz-2.3.3-1.el7.centos.x86_64 2/4
Verifying : docker-ce-18.03.1.ce-1.el7.centos.x86_64 3/4
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 4/4
Installed:
docker-ce.x86_64 0:18.03.1.ce-1.el7.centos
Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 libtool-ltdl.x86_64 0:2.4.2-22.el7_3 pigz.x86_64 0:2.3.3-1.el7.centos
Complete!
5.3 开机自启
为了方便可以设置开机自启,当然也可以手动开启
# 开机启动
systemctl start docker
# 停止docker
systemctl stop docker
# 自动启动docker
sytemctl enable docker
操作过程如下:
[zxd@localhost ~]$ sudo systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
相关文章
- 【面试高频题】难度 3/5,状态压缩 DP 及其优化
- 内网直播(局域网直播)系统的搭建
- BUU UPLOAD COURSE 1 1 解题思路
- 【面试高频题】难度 2/5,回溯算法经典运用
- 全文检索工具solr:第二章:安装配置
- 事业 - 人生感悟
- 延迟和IOPS到底哪个决定固态硬盘性能?
- 蓝盘紫盘黑盘都是啥意思?一文看懂
- 大型网站架构演化发展历程
- 【综合笔试题】难度 2.5/5,状态机序列 DP 运用题
- 【综合笔试题】难度 4.5/5,扫描线的特殊运用(详尽答疑)
- 终于弄明白了 RocketMQ 的存储模型
- 【综合笔试题】难度 3.5/5,常见序列 DP 题目及其优化思路
- 软件设计的六大原则剖析
- 资本家和企业家的区别 - 人生感悟
- 我的电脑防护安全软件
- 【综合笔试题】难度 2/5,常见栈运用模拟题
- 深度网络CTR建模
- 7、后记 - 软件能力的成熟度的模型
- 6、成熟度等级5:持续优化级 - 软件能力的成熟度的模型