09_docker-ce安装启动:80分钟一口气学完docker+k8s!带你掌握docker+k8s所有核心知识点,全程干货,无废话!
使用docker首要就是获取镜像文件,默认下载是从Docker Hub下载,网速较慢,国内很多云服务商都提供了加速器服务,阿里云加速器,Daocloud加速器,灵雀云加速器。清除防火墙策略,并将getenforce改为Disabled;1、docker必须安装在Centos7平台,内核版本不低于3.10。更新两个epel和CentOS-Base.repo仓库。禁止开机自启防火墙,关闭防火墙服务。2
·
机器环境初始化:
1、防火墙
2、yum源
3、安装基础软件
更新两个epel和CentOS-Base.repo仓库
[root@Hadoop2 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
--2023-09-12 09:33:21-- http://mirrors.aliyun.com/repo/epel-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 116.207.144.117, 119.96.33.220, 113.125.228.118, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|116.207.144.117|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:664 [application/octet-stream]
正在保存至: “/etc/yum.repos.d/epel.repo”
100%[=========================================================================================================================>] 664 --.-K/s 用时 0s
2023-09-12 09:33:21 (216 MB/s) - 已保存 “/etc/yum.repos.d/epel.repo” [664/664])
[root@Hadoop2 ~]# ^C
[root@Hadoop2 ~]# cd /etc/yum.repos.d/
[root@Hadoop2 yum.repos.d]# ll
总用量 40
-rw-r--r--. 1 root root 0 9月 11 16:21 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 10月 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 10月 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 10月 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 10月 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 10月 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 10月 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 10月 23 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 664 8月 4 2022 epel.repo
[root@Hadoop2 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2023-09-12 10:02:11-- http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 118.213.94.118, 110.167.162.241, 110.167.162.238, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|118.213.94.118|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[=========================================================================================================================>] 2,523 --.-K/s 用时 0s
2023-09-12 10:02:11 (448 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
清空本地缓存、建立缓存
[root@Hadoop2 yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base epel extras updates
Cleaning up list of fastest mirrors
[root@Hadoop2 yum.repos.d]# yum makecache
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
base/7/x86_64/primary_db FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
正在尝试其它镜像。
(1/16): epel/x86_64/group_gz | 99 kB 00:00:00
(2/16): base/7/x86_64/group_gz | 153 kB 00:00:00
(3/16): base/7/x86_64/other_db | 2.6 MB 00:00:00
(4/16): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(5/16): epel/x86_64/prestodelta | 1.1 kB 00:00:00
(6/16): epel/x86_64/filelists_db | 12 MB 00:00:01
(7/16): extras/7/x86_64/filelists_db | 303 kB 00:00:00
(8/16): extras/7/x86_64/primary_db | 250 kB 00:00:00
(9/16): extras/7/x86_64/other_db | 150 kB 00:00:00
(10/16): epel/x86_64/other_db | 3.4 MB 00:00:00
(11/16): epel/x86_64/primary_db | 7.0 MB 00:00:01
(12/16): base/7/x86_64/primary_db | 6.1 MB 00:00:01
(13/16): updates/7/x86_64/filelists_db | 12 MB 00:00:02
(14/16): updates/7/x86_64/primary_db | 22 MB 00:00:03
base/7/x86_64/filelists_db FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/d6d94c7d406fe7ad4902a97104b39a0d8299451832a97f31d71653ba982c955b-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
(15/16): base/7/x86_64/filelists_db | 7.2 MB 00:00:00
updates/7/x86_64/other_db FAILED
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/0808ffa27434f694d97ba4cc05d65e2921dac75ba399ac956ddbec97ee1c36a1-other.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
(16/16): updates/7/x86_64/other_db | 1.4 MB 00:00:00
元数据缓存已建立
[root@Hadoop2 yum.repos.d]# ^C
[root@Hadoop2 yum.repos.d]#
清除防火墙策略,并将getenforce改为Disabled;jin
[root@Hadoop2 ~]# iptables -F
[root@Hadoop2 ~]# getenforce
Enforcing
[root@Hadoop2 ~]# vi /etc/selinux/config
[root@Hadoop2 ~]# getenforce
Enforcing
[root@Hadoop2 ~]# reboot
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(102-192.168.208.146) at 15:51:35.
Type `help' to learn how to use Xshell prompt.
[C:\~]$
Connecting to 192.168.208.146:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Tue Sep 12 15:38:23 2023 from 192.168.208.1
[root@Hadoop2 ~]# getenforce
Disabled
[root@Hadoop2 ~]#
禁止开机自启防火墙,关闭防火墙服务
[root@Hadoop2 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@Hadoop2 ~]# systemctl stop firewalld
[root@Hadoop2 ~]#
安装docker :
1、docker必须安装在Centos7平台,内核版本不低于3.10
[root@Hadoop2 ~]# uname -r
3.10.0-1160.el7.x86_64
2、开启Linux内核的流量转发
cat <<EOF> /etc/sysctl.d/docker.conf
170 net.bridge.bridge-nf-call-ip6tables = 1
171 net.bridge.bridge-nf-call-iptables =1
172 net.ipv4.conf.default.rp_filter = 0
173 net.ipv4.conf.all.rp_filer = 0
174 net.ipv4.ip_forward=1
175 EOF
#加载修改内核的参数,配置文件,sysctl命令 被用于在内核运行时动态地修改内核的运行参数,-p:从配置文件“/etc/sysctl.conf”加载内核参数设置
[root@Hadoop2 ~]# sysctl -p /etc/sysctl.d/docker.conf
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: 没有那个文件或目录
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: 没有那个文件或目录
net.ipv4.conf.default.rp_filter = 0
sysctl: cannot stat /proc/sys/net/ipv4/conf/all/rp_filer: 没有那个文件或目录
net.ipv4.ip_forward = 1
[root@Hadoop2 ~]#
利用yum快速安装docker
#提前准备好yum仓库
#1、阿里云自带仓库;2、阿里云提供的docker专属repo仓库。
查看所有仓库中所有docker版本,并选择特定版本安装
[root@Hadoop2 ~]# yum list docker-ce --showduplicates | sort -r
错误:没有匹配的软件包可以列出
已加载插件:fastestmirror, langpacks
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
* extras: mirrors.aliyun.com
* base: mirrors.aliyun.com
[root@Hadoop2 ~]#
#下载阿里源repo文件
[root@Hadoop2 ~]# curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2081 100 2081 0 0 12099 0 --:--:-- --:--:-- --:--:-- 12169
[root@Hadoop2 ~]# curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 18893 0 --:--:-- --:--:-- --:--:-- 18969
[root@Hadoop2 ~]#
#可以直接yum安装docker了
一、更新yum缓存
[root@Hadoop2 ~]# yum clean all && yum makecache
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
正在清理软件源: base docker-ce-stable epel extras updates
Cleaning up list of fastest mirrors
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/20): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/20): base/7/x86_64/primary_db | 6.1 MB 00:00:00
(3/20): base/7/x86_64/filelists_db | 7.2 MB 00:00:01
(4/20): base/7/x86_64/other_db | 2.6 MB 00:00:00
(5/20): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(6/20): docker-ce-stable/7/x86_64/filelists_db | 47 kB 00:00:00
(7/20): docker-ce-stable/7/x86_64/other_db | 134 kB 00:00:00
(8/20): docker-ce-stable/7/x86_64/primary_db | 117 kB 00:00:00
(9/20): epel/x86_64/group_gz | 99 kB 00:00:00
(10/20): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(11/20): epel/x86_64/prestodelta | 646 B 00:00:00
(12/20): epel/x86_64/primary_db | 7.0 MB 00:00:00
(13/20): epel/x86_64/filelists_db | 12 MB 00:00:01
(14/20): epel/x86_64/other_db | 3.4 MB 00:00:00
(15/20): extras/7/x86_64/filelists_db | 303 kB 00:00:00
(16/20): extras/7/x86_64/primary_db | 250 kB 00:00:00
(17/20): extras/7/x86_64/other_db | 150 kB 00:00:00
(18/20): updates/7/x86_64/filelists_db | 12 MB 00:00:01
(19/20): updates/7/x86_64/other_db | 1.4 MB 00:00:00
(20/20): updates/7/x86_64/primary_db | 22 MB 00:00:02
元数据缓存已建立
[root@Hadoop2 ~]#
二、查看源中可用版本
[root@Hadoop2 ~]# yum list docker-ce --showduplicates | sort -r
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
已加载插件:fastestmirror, langpacks
可安装的软件包
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
* extras: mirrors.aliyun.com
docker-ce.x86_64 3:24.0.6-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.5-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.4-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.3-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.2-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.1-1.el7 docker-ce-stable
docker-ce.x86_64 3:24.0.0-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.6-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.5-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.4-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.3-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.2-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.1-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.0-1.el7 docker-ce-stable
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 3:20.10.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.24-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.23-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.22-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.21-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.20-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.19-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.18-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.17-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.16-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-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
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
* base: mirrors.aliyun.com
三、安装指定版本docker
[root@Hadoop2 ~]# yum install docker-ce-20.10.6 -y
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.20.10.6-3.el7 将被 安装
--> 正在处理依赖关系 container-selinux >= 2:2.74,它被软件包 3:docker-ce-20.10.6-3.el7.x86_64 需要
--> 正在处理依赖关系 containerd.io >= 1.4.1,它被软件包 3:docker-ce-20.10.6-3.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-cli,它被软件包 3:docker-ce-20.10.6-3.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-20.10.6-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装
---> 软件包 containerd.io.x86_64.0.1.6.22-3.1.el7 将被 安装
---> 软件包 docker-ce-cli.x86_64.1.24.0.6-1.el7 将被 安装
--> 正在处理依赖关系 docker-buildx-plugin,它被软件包 1:docker-ce-cli-24.0.6-1.el7.x86_64 需要
--> 正在处理依赖关系 docker-compose-plugin,它被软件包 1:docker-ce-cli-24.0.6-1.el7.x86_64 需要
---> 软件包 docker-ce-rootless-extras.x86_64.0.24.0.6-1.el7 将被 安装
--> 正在处理依赖关系 fuse-overlayfs >= 0.7,它被软件包 docker-ce-rootless-extras-24.0.6-1.el7.x86_64 需要
--> 正在处理依赖关系 slirp4netns >= 0.4,它被软件包 docker-ce-rootless-extras-24.0.6-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 docker-buildx-plugin.x86_64.0.0.11.2-1.el7 将被 安装
---> 软件包 docker-compose-plugin.x86_64.0.2.21.0-1.el7 将被 安装
---> 软件包 fuse-overlayfs.x86_64.0.0.7.2-6.el7_8 将被 安装
--> 正在处理依赖关系 libfuse3.so.3(FUSE_3.2)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
--> 正在处理依赖关系 libfuse3.so.3(FUSE_3.0)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
--> 正在处理依赖关系 libfuse3.so.3()(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
---> 软件包 slirp4netns.x86_64.0.0.4.3-4.el7_8 将被 安装
--> 正在检查事务
---> 软件包 fuse3-libs.x86_64.0.3.6.1-4.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===================================================================================================================================================================
Package 架构 版本 源 大小
===================================================================================================================================================================
正在安装:
docker-ce x86_64 3:20.10.6-3.el7 docker-ce-stable 27 M
为依赖而安装:
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
containerd.io x86_64 1.6.22-3.1.el7 docker-ce-stable 34 M
docker-buildx-plugin x86_64 0.11.2-1.el7 docker-ce-stable 13 M
docker-ce-cli x86_64 1:24.0.6-1.el7 docker-ce-stable 13 M
docker-ce-rootless-extras x86_64 24.0.6-1.el7 docker-ce-stable 9.1 M
docker-compose-plugin x86_64 2.21.0-1.el7 docker-ce-stable 13 M
fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k
fuse3-libs x86_64 3.6.1-4.el7 extras 82 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
事务概要
===================================================================================================================================================================
安装 1 软件包 (+9 依赖软件包)
总下载量:109 M
安装大小:401 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/extras/packages/container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm 的公钥尚未安装
(1/10): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
警告:/var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 621e9f35: NOKEY:00:19 ETA
docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm 的公钥尚未安装
(2/10): docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm | 13 MB 00:00:01
(3/10): docker-ce-20.10.6-3.el7.x86_64.rpm | 27 MB 00:00:03
(4/10): containerd.io-1.6.22-3.1.el7.x86_64.rpm | 34 MB 00:00:05
(5/10): docker-ce-cli-24.0.6-1.el7.x86_64.rpm | 13 MB 00:00:01
(6/10): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(7/10): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(8/10): docker-ce-rootless-extras-24.0.6-1.el7.x86_64.rpm | 9.1 MB 00:00:01
(9/10): docker-compose-plugin-2.21.0-1.el7.x86_64.rpm | 13 MB 00:00:01
(10/10): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:01
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 14 MB/s | 109 MB 00:00:07
从 http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
来自 : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
从 https://mirrors.aliyun.com/docker-ce/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
用户ID : "Docker Release (CE rpm) <docker@docker.com>"
指纹 : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
来自 : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 1/10
setsebool: SELinux is disabled.
正在安装 : containerd.io-1.6.22-3.1.el7.x86_64 2/10
正在安装 : docker-buildx-plugin-0.11.2-1.el7.x86_64 3/10
正在安装 : slirp4netns-0.4.3-4.el7_8.x86_64 4/10
正在安装 : docker-compose-plugin-2.21.0-1.el7.x86_64 5/10
正在安装 : 1:docker-ce-cli-24.0.6-1.el7.x86_64 6/10
正在安装 : fuse3-libs-3.6.1-4.el7.x86_64 7/10
正在安装 : fuse-overlayfs-0.7.2-6.el7_8.x86_64 8/10
正在安装 : 3:docker-ce-20.10.6-3.el7.x86_64 9/10
正在安装 : docker-ce-rootless-extras-24.0.6-1.el7.x86_64 10/10
验证中 : fuse3-libs-3.6.1-4.el7.x86_64 1/10
验证中 : docker-compose-plugin-2.21.0-1.el7.x86_64 2/10
验证中 : 3:docker-ce-20.10.6-3.el7.x86_64 3/10
验证中 : slirp4netns-0.4.3-4.el7_8.x86_64 4/10
验证中 : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 5/10
验证中 : docker-ce-rootless-extras-24.0.6-1.el7.x86_64 6/10
验证中 : containerd.io-1.6.22-3.1.el7.x86_64 7/10
验证中 : docker-buildx-plugin-0.11.2-1.el7.x86_64 8/10
验证中 : fuse-overlayfs-0.7.2-6.el7_8.x86_64 9/10
验证中 : 1:docker-ce-cli-24.0.6-1.el7.x86_64 10/10
已安装:
docker-ce.x86_64 3:20.10.6-3.el7
作为依赖被安装:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 containerd.io.x86_64 0:1.6.22-3.1.el7 docker-buildx-plugin.x86_64 0:0.11.2-1.el7
docker-ce-cli.x86_64 1:24.0.6-1.el7 docker-ce-rootless-extras.x86_64 0:24.0.6-1.el7 docker-compose-plugin.x86_64 0:2.21.0-1.el7
fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8
完毕!
[root@Hadoop2 ~]#
#如果要卸载
yum remove -y docker-xxxx
配置docker加速器
使用docker首要就是获取镜像文件,默认下载是从Docker Hub下载,网速较慢,国内很多云服务商都提供了加速器服务,阿里云加速器,Daocloud加速器,灵雀云加速器。
[root@Hadoop2 ~]# vim /etc/docker/daemon.json
[root@Hadoop2 ~]# cat /etc/docker/daemon.json
{
"registry-mirrors" : [
"http://8xpk5wnt.mirror.aliyuncs.com"
]
}
[root@Hadoop2 ~]#
重启、设置开机自启
##设置开机自启
#启动docker
#因为修改了配置文件,这里重新读取一下配置信息
[root@Hadoop2 ~]# systemctl daemon-reload
#设置开机自启
[root@Hadoop2 ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@Hadoop2 ~]#
#启动docker
[root@Hadoop2 docker]# systemctl restart docker
[root@Hadoop2 docker]#
#验证是否启动docker
[root@Hadoop2 docker]# ps -ef|grep docker
root 3161 1985 0 20:43 pts/0 00:00:00 vim /etc/docker/daemon.json
root 4737 1 0 21:15 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 4877 4190 0 21:16 pts/2 00:00:00 grep --color=auto docker
[root@Hadoop2 docker]#
========================================================================================
#错误修改
[root@Hadoop2 ~]# systemctl restart docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@Hadoop2 ~]# systemctl restart docker
Job for docker.service failed because start of the service was attempted too often. See "systemctl status docker.service" and "journalctl -xe" for details.
To force a start use "systemctl reset-failed docker.service" followed by "systemctl start docker.service" again.
[root@Hadoop2 ~]# cd /etc/docker/
[root@Hadoop2 docker]# ll
总用量 4
-rw-r--r-- 1 root root 75 9月 12 20:57 daemon.json
[root@Hadoop2 docker]# mv daemon.json daemon.conf
[root@Hadoop2 docker]# ll
总用量 4
-rw-r--r-- 1 root root 75 9月 12 20:57 daemon.conf
[root@Hadoop2 docker]# systemctl restart docker
[root@Hadoop2 docker]# ps -ef|grep docker
root 3161 1985 0 20:43 pts/0 00:00:00 vim /etc/docker/daemon.json
root 4737 1 0 21:15 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 4877 4190 0 21:16 pts/2 00:00:00 grep --color=auto docker
[root@Hadoop2 docker]# docker ps
=========================================================================================查看各种信息
[root@Hadoop2 docker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@Hadoop2 docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@Hadoop2 docker]# docker version
Client: Docker Engine - Community
Version: 24.0.6
API version: 1.41 (downgraded from 1.43)
Go version: go1.20.7
Git commit: ed223bc
Built: Mon Sep 4 12:35:25 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 20.10.6
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 8728dd2
Built: Fri Apr 9 22:43:57 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[root@Hadoop2 docker]#
看到这个就表示已经正确启动了
更多推荐
已为社区贡献1条内容
所有评论(0)