关于linux:centos65-安装docker方法

7次阅读

共计 1780 个字符,预计需要花费 5 分钟才能阅读完成。

1、降级内核,因为默认内核不反对 docker 运行,docker 个别要求内核版本在 3.10 以上

(1)查看内核版本

$ uname -r

(2)导入公钥数字证书

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

须要留神的是,根据官网提供,centos6.x 对应证书都是这样

(3)装置 ELRepo

$ rpm -ivh http://www.elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm

(4)装置 kernel-lt(lt=long-term)

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

(5) 编辑 grub.conf 文件,批改 Grub 疏导程序,确认刚装置好的内核在哪个地位,而后设置 default 值(从 0 开始),个别新装置的内核在第一个地位,所以设置 default=0。

# 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/mapper/vg_eypdyf83-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (4.4.163-1.el6.elrepo.x86_64)

(6)重启零碎,查看零碎内核能够发现内核曾经更新了

2、装置 docker

(1)禁用 selinux,因为 selinux 和 LXC 有抵触,故而须要禁用

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled  # 此处进行批改即可
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

(2)装置 Fedora EPEL

$ yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

(3)装置 docker

$ yum install -y docker-io

(4)以守护模式运行 Docker

$ docker -d

(5)将 Docker 开机启动

$ chkconfig docker on

(6)启动 Docker

$ service docker start

3、创立 docker 用户组

默认状况下,docker 命令会应用 Unix socket 与 Docker 引擎通信。而只有 root 用户和 docker 组的用户才能够拜访 Docker 引擎的 Unix socket。出于平安思考,个别 Linux 零碎上不会间接应用 root 用户。因而,更好地做法是将须要应用 docker 的用户退出 docker 用户组。

(1)创立用户组

$ sudo groupadd docker

(2)将当期用户退出用户组

$ sudo usermod -aG docker $USER

(3)也能够创立一个新用户退出到 docker 用户组

$ sudo usermod -aG docker dockerio


正文完
 0