美文网首页
Docker linux 安装记录

Docker linux 安装记录

作者: _大叔_ | 来源:发表于2020-06-15 18:32 被阅读0次

一、查看系统版本以及内核版本

lsb_release -a 命令查看系统
[root@localhost ~]# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.4 (Final)
Release:        6.4
Codename:       Final
uname -a 查看内核版本
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

内核版本为 2.6.32,Docker需要在内核版本至少在3.0以后的版本中运行,所以第一步工作则是升级Centos的内核版本。
centos 6 64
centos 7 64

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -ivh https://elrepo.org/linux/kernel/el6/x86_64/RPMS/kernel-lt-4.4.226-1.el6.elrepo.x86_64.rpm

升级完成后可以在文件/etc/grub.conf看到内核为 4.4.226 的配置信息,使用命令cat /etc/grub.conf即可查看

[root@localhost ~]# cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (4.4.226-1.el6.elrepo.x86_64)
        root (hd0,0)
        kernel /vmlinuz-4.4.226-1.el6.elrepo.x86_64 ro root=UUID=a33a775a-fefc-4702-bbf1-7691b23b3c91 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD LANG=zh_CN.UTF-8 rd_NO_LVM crashkernel=auto rhgb quiet rd_NO_DM rhgb quiet
        initrd /initramfs-4.4.226-1.el6.elrepo.x86_64.img
title CentOS (2.6.32-358.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=UUID=a33a775a-fefc-4702-bbf1-7691b23b3c91 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD LANG=zh_CN.UTF-8 rd_NO_LVM crashkernel=auto rhgb quiet rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-358.el6.x86_64.img

会看到 default=1,也就是指向 title CentOS (2.6.32-358.el6.x86_64),改成 0 指向 title CentOS (4.4.226-1.el6.elrepo.x86_64) 然后 reboot 重启 然后再查看内核

[root@localhost ~]# uname -a
Linux localhost.localdomain 4.4.226-1.el6.elrepo.x86_64 #1 SMP Tue Jun 2 10:06:03 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux

二、注意及升级记录

stop,发现centos 6.4根本不能运行docker,建议还是升级到 centos 7吧

1、更新源
vim /etc/yum.repos.d/upgrade.repo 并输入以下内容:
[upgrade]
name=upgrade
baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/
enable=1
gpgcheck=0

2、卸载6.x自带的较新的助手,并安装老版[否则会报错]
yum erase openscap -y
yum install http://dev.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm -y

3、安装助手
yum install redhat-upgrade-tool preupgrade-assistant-contents -y

4、检测版本升级的风险,如果控制台输出了错误信息,则需要查询下解决方案并解决
preupg -s CentOS6_7

5、导入CentOS7的key
rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7

6、开始升级
centos-upgrade-tool-cli --network 7 --instrepo=http://vault.centos.org/centos/7.2.1511/os/x86_64/

7、更新完后,重启服务器
reboot

重启之后等待时间会比较久,更新完毕如下:

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]#  lsb_release -a 
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.2.1511 (Core) 
Release:        7.2.1511
Codename:       Core

三、安装docker

至于安装docker 官方网站已经很清楚了,跟着做。 传送门

相关文章

网友评论

      本文标题:Docker linux 安装记录

      本文链接:https://www.haomeiwen.com/subject/ohfltktx.html