centos6.5 安裝docker方法

一、升級內核,因爲默認內核不支持docker運行,docker通常要求內核版本在3.10以上linux

(1)查看內核版本docker

$ uname -r

(2)導入公鑰數字證書centos

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

須要注意的是,依據官網提供,centos6.x對應證書都是這樣安全

(3)安裝ELRepoapp

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

(4)安裝 kernel-lt(lt=long-term)socket

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

(5) 編輯grub.conf文件,修改Grub引導順序,確認剛安裝好的內核在哪一個位置,而後設置default值(從0開始),通常新安裝的內核在第一個位置,因此設置default=0。this

# 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)重啓系統,查看系統內核能夠發現內核已經更新了code

二、安裝dockerthree

(1)禁用selinux,由於selinux和LXC有衝突,故而須要禁用ci

# 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

三、建立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
相關文章
相關標籤/搜索