centos6.8升级内核安装docker

centos6.8默认的内核版本为2.6 而docker安装要求为系统64位 内核版本3以上 所以需要对内核版本进行更新

最好先看看系统的selinux是否关闭 如果没关闭先关闭 SELINUX设置为disabled

 vi /etc/selinux/config
 # SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.

SELINUX=disabled

首先更新key

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org  

再下载Elrepo 目前最新版本为6-8 如果下载不了可以进www.elrepo.org官网找最新的

rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm

之后使用yum在Elrepo升级内核

yum --enablerepo=elrepo-kernel install kernel-lt -y 

最后修改启动文件 把default=1修改为default=0

vi /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 do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/vda1
#          initrd /boot/initrd-[generic-]version.img
#boot=/dev/vda
default=0
timeout=5

使用reboot命令重启 内核就升级完毕了

可以使用命令查看内核版本 升级到了3.10

[root@blogforum ~]# uname -a
Linux blogforum 3.10.107-1.el6.elrepo.x86_64 #1 SMP Tue Jun 27 10:57:54 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

接下来开始安装docker

直接用yum安装

yum install docker-io

安装好 docker就安装完毕了

启动docker并且设置开机自动启动

[root@blogforum ~]# /etc/init.d/docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:                                           [  OK  ]
[root@blogforum ~]#  chkconfig --level 0123456 docker on

查看docker镜像命令 因为还没有下载镜像 还没有镜像显示

[root@blogforum ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

这里提下我安装完docker以后下载镜像提示无法下载

[root@blogforum ~]# docker pull centos
latest: Pulling from centos
d9cdac769794: Downloading [>                                                  ] 278.5 kB/72.25 MB
8b7794bcb4f9: Download complete
f3b88ddaed16: Download complete
Pulling repository centos
Repository not found

我在centos7上安装以后是可以直接下载镜像的 可6.8不行 后来我网上找了下资料 看到有一篇讲到docker pull和yum地址有点关系 我就把yum源换成阿里云的yum

下载阿里云yum配置文件

[root@blogforum yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@blogforum yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

更新yum

[root@blogforum yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * elrepo: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                            | 3.7 kB     00:00
base/group_gz                                                   | 226 kB     00:00
base/filelists_db                                               | 6.4 MB     00:06

然后就可以下载成功了

[root@blogforum yum.repos.d]# docker pull centos
latest: Pulling from centos
d9cdac769794: Pull complete
8b7794bcb4f9: Pull complete
f3b88ddaed16: Pull complete
Digest: sha256:acb3b91e930743331be14cd3c8154da9967e2a2fca2aad0e1f27efce6deb2884
Status: Downloaded newer image for centos:latest
[root@blogforum yum.repos.d]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos              latest              f3b88ddaed16        13 days ago         192.5 MB
[root@blogforum yum.repos.d]#

你可能感兴趣的:(运维,docker,centos内核升级)