服務器環境:Centos6.8 64位。內核信息如下:
Linux localhost.localdomain 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
操作docker啓動centos容器時提示錯誤如下:
FATAL: kernel too old
那麼就是docker認爲你的內核版本不適配,需要升級。
【1】更新nss
命令如下:
yum update nss
【2】安裝elrepo的yum源
升級內核需要使用elrepo的yum源,在安裝yum源之前還需要我們導入elrepo的key
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
【3】升級內核
在yum的elrepo源中有ml和lt兩種內核,其中ml(mainline)爲最新版本的內核,lt爲長期支持的內核。
安裝ml內核使用如下命令:
yum --enablerepo=elrepo-kernel -y install kernel-ml
安裝lt內核使用如下命令:
yum --enablerepo=elrepo-kernel -y install kernel-lt
此處選擇lt內核。
【4】修改grub.conf文件
內核升級完後需要修改內核的啓動順序
vim /etc/grub.conf
default=0
然後重啓系統:reboot
。
再次查看內核詳細信息:
[root@localhost ~]# uname -a
Linux localhost.localdomain 4.4.213-1.el6.elrepo.x86_64 #1 SMP Wed Feb 5 10:59:29 EST 2020 x86_64 x86_64 x86_64 GNU/Linux
再次啓動容器:
[root@localhost ~]# ps -ef|grep docker
root 16978 1 0 04:41 ? 00:00:00 /usr/bin/docker -d --registry-mirror=https://05hzrxh8.mirror.aliyuncs.com
root 17356 17324 0 04:43 pts/0 00:00:00 grep docker
[root@localhost ~]# docker run -it centos
[root@ca995caf8c80 /]#
#標明已經進入容器操作界面