Redhat/Centos6安装docker

  • A+
所属分类:Docker

Redhat 6 / Centos 6 安装

.升级内核(带aufs模块)

docker官方Linux kernel至少3.8以上,且只能运行在64位系统上,由于Redhat6 和Centos 6默认内核是2.6 ,因此必须先升级内核。我们用yum升级内核(为了图省事,源码包安装编译太麻烦)

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# wget http://www.hop5.in/yum/el6/hop5.repo

[root@localhost yum.repos.d]# yum install kernel-ml-aufs kernel-ml-aufs-devel  -y

.修改grub引导,默认以新内核启动

[root@localhost ~]# vim /etc/grub.conf

device (hd0) HD(1,800,64000,6f105e0e-1f49-4aac-af33-0c9a403aa942)
 default=0  #此处默认是1,改成0 其它地方不用动
 timeout=5
 splashimage=(hd0,2)/boot/grub/splash.xpm.gz
 hiddenmenu
 title Red Hat Enterprise Linux Server (3.10.5-3.el6.x86_64)
 root (hd0,2)
 kernel /boot/vmlinuz-3.10.5-3.el6.x86_64 ro root=UUID=19da20ce-6acc-475b-ae11-d4bf953303b2 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
 initrd /boot/initramfs-3.10.5-3.el6.x86_64.img
 title Red Hat Enterprise Linux (2.6.32-279.el6.x86_64)

重启系统,查看内核版本,可以看到内核升级到3.10了

[root@localhost ~]# uname -r

3.10.5-3.el6.x86_64

查看系统是否支持aufs

[root@localhost ~]# grep aufs /proc/filesystems
 nodev aufs

三.安装docker

1.关闭selinux

[root@localhost ~]# setenforce 0

2.安装libcgroup

rpm -ivh ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.5/x86_64/updates/fastbugs/libcgroup-0.40.rc1-6.el6_5.1.x86_64.rpm

3.更新yum源

对于Redhat/Centos来说,可以使用 EPEL 库安装 Docker,命令如下

[root@localhost ~]# yum install http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm

[root@localhost ~]# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

[root@localhost ~]# rpm -ivh epel-release-latest-6.noarch.rpm

 

两种更新yum源的方法都可以使用,其中redhat用yum安装可能报错

Error: Cannot retrieve repository metadata (repomd.xml) for repository: epel. Please verify its path and try aga...

解决方法:

[epel]
 name=Extra Packages for Enterprise Linux 6 - $basearch
 #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch  #把这一行的#去掉
 mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch     这一行前加#
 failovermethod=priority
 enabled=1
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

4.安装docker-io

[root@localhost ~]# yum install -y docker-io

5.启动docker

[root@localhost ~]# service docker start
 Starting cgconfig service: [确定]
 Starting docker: [确定]

6.查看docker版本

[root@localhost ~]# docker version

docker默认安装已创建docker开机项

[root@web02 yum.repos.d]# ll /etc/rc5.d/S95docker
 lrwxrwxrwx 1 root root 16 9月 21 14:16 /etc/rc5.d/S95docker -> ../init.d/docker

7.随系统自动启动

[root@localhost ~]# chkconfig docker on

 

 

 

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: