一、前提
安装一台Linux的主机(本人使用vmwere安装)
需要内核版本高于3.8
1 [root@localhost ~]# uname -r 2 3.10.0-1160.el7.x86_64
需要的系统版本(尽量使用centos7)
1 [root@localhost etc]# cat /etc/centos-release 2 CentOS Linux release 7.9.2009 (Core)
如果是需要连通网络,可以上网!!!
二、内核版本升级
1、下载安装内核(以6.5升级为例)
1 rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 2 rpm -ivh http://www.elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm 3 yum -y --enablerepo=elrepo-kernel install kernel-lt
2、修改配置文件
vi /etc/grub.conf
将default=1
修改为default=0
3、重启机器
reboot/init 6
三、配置网络yum源
网络yum源(阿里云)
1 # CentOS-Base.repo 2 # 3 # The mirror system uses the connecting IP address of the client and the 4 # update status of each mirror to pick mirrors that are updated to and 5 # geographically close to the client. You should use this for CentOS updates 6 # unless you are manually picking other mirrors. 7 # 8 # If the mirrorlist= does not work for you, as a fall back you can try the 9 # remarked out baseurl= line instead. 10 # 11 # 12 13 [base] 14 name=CentOS-$releasever - Base - mirrors.aliyun.com 15 failovermethod=priority 16 baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ 17 http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ 18 http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/ 19 gpgcheck=1 20 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 21 22 #released updates 23 [updates] 24 name=CentOS-$releasever - Updates - mirrors.aliyun.com 25 failovermethod=priority 26 baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ 27 http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ 28 http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/ 29 gpgcheck=1 30 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 31 32 #additional packages that may be useful 33 [extras] 34 name=CentOS-$releasever - Extras - mirrors.aliyun.com 35 failovermethod=priority 36 baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ 37 http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ 38 http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/ 39 gpgcheck=1 40 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 41 42 #additional packages that extend functionality of existing packages 43 [centosplus] 44 name=CentOS-$releasever - Plus - mirrors.aliyun.com 45 failovermethod=priority 46 baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ 47 http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ 48 http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/ 49 gpgcheck=1 50 enabled=0 51 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 52 53 #contrib - packages by Centos Users 54 [contrib] 55 name=CentOS-$releasever - Contrib - mirrors.aliyun.com 56 failovermethod=priority 57 baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ 58 http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ 59 http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/ 60 gpgcheck=1 61 enabled=0 62 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
四、docker安装
1、工具服务安装
yum install -y yum-utils
2、仓库加载
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.
3、docker安装
yum install docker-ce
4、docker镜像加速(163的加速,也可以使用其他加速)
a、创建加速文件
1 mkdir -p /etc/docker 2 touch /etc/docker/daemon.json
b、书写文件
{ "registry-mirrors": ["http://hub-mirror.c.163.com"] }
5、启动docker并查看状态
[root@localhost ~]# systemctl start docker.service [root@localhost ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2021-03-24 07:28:44 EDT; 14s ago Docs: https://docs.docker.com Main PID: 9983 (dockerd) Tasks: 8 Memory: 64.0M CGroup: /system.slice/docker.service └─9983 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock Mar 24 07:28:43 localhost.localdomain dockerd[9983]: time="2021-03-24T07:28:43.301482007-04:00" level=info msg="scheme "unix" not registered, fallbac...ule=grpc Mar 24 07:28:43 localhost.localdomain dockerd[9983]: time="2021-03-24T07:28:43.301523005-04:00" level=info msg="ccResolverWrapper: sending update to cc...ule=grpc Mar 24 07:28:43 localhost.localdomain dockerd[9983]: time="2021-03-24T07:28:43.301545201-04:00" level=info msg="ClientConn switching balancer to "pick...ule=grpc Mar 24 07:28:43 localhost.localdomain dockerd[9983]: time="2021-03-24T07:28:43.409787456-04:00" level=info msg="Loading containers: start." Mar 24 07:28:43 localhost.localdomain dockerd[9983]: time="2021-03-24T07:28:43.958929100-04:00" level=info msg="Default bridge (docker0) is assigned wi...address" Mar 24 07:28:44 localhost.localdomain dockerd[9983]: time="2021-03-24T07:28:44.357555441-04:00" level=info msg="Loading containers: done." Mar 24 07:28:44 localhost.localdomain dockerd[9983]: time="2021-03-24T07:28:44.924748381-04:00" level=info msg="Docker daemon" commit=363e9a8 graphdriv...=20.10.5 Mar 24 07:28:44 localhost.localdomain dockerd[9983]: time="2021-03-24T07:28:44.927455018-04:00" level=info msg="Daemon has completed initialization" Mar 24 07:28:44 localhost.localdomain systemd[1]: Started Docker Application Container Engine. Mar 24 07:28:45 localhost.localdomain dockerd[9983]: time="2021-03-24T07:28:45.040525036-04:00" level=info msg="API listen on /var/run/docker.sock" Hint: Some lines were ellipsized, use -l to show in full.
五、失败总结
1、防火墙阻拦
解决方法:关闭防火墙
2、拉起的docker镜像无法访问属主机(有的内核不支持)
解决方法:升级内核
3、加速文件配置
解决方法:a、加速文件不可以有空格