RHEL 6.5 安装Docker
二,下载依赖包
1.安装downloadonly插件使用yum下载rpm包
2.下载docker需要的依赖包
三,安装docker(离线节点)
1. 依次执行docker的安装包
2. 启动服务
3. 设置开机自动启动
三,问题
1. 运行docker -d命令报错如下:
2. 执行service docker restart报如下错误:
3. rhel 6.5 无法使用 yum epel
四,参考
基本思路就是找一台能联网的linux主机,把安装Docker所需要的包下载下来,然后上传到安装docker的服务器进行安装
主机要用CentOS,RHEL再使用EPEL yum源的时候报:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
原因见文末链接!
一,配置远程yum源
二,下载依赖包
1.安装downloadonly插件使用yum下载rpm包
yum-plugin-downloadonly
使用方法:
yum install --downloadonly``(只下载不安装)` `--downloaddir=rpm``包下载的目录 安装的组件名
2.下载docker需要的依赖包
2.1配置Fedora EPEL源
epel-release-latest软件包下载地址:https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
2.2 添加hop5.repo源
# cd /etc/yum.repos.d
# wget http://www.hop5.in/yum/el6/hop5.repo</pre>
2.3 下载依赖包
# mkdir /usr/local/docker
# yum install --downloadonly --downloaddir=/usr/local/docker docker-io
2.4 下载device-mapper-libs
不下载后面启动docker会报错,下载网
址:http://mirrors.aliyun.com/centos/6/os/x86_64/Packages/
# mkdir /usr/local/docker/device-mapper-libs
# yum install --downloadonly --downloaddir=/usr/local/docker/device-mapper-libs device-mapper-libs
下载到的lib截图如下:
三,安装docker(离线节点)
将整个docker目录拷贝到需要安装docker的离线的节点,可以放在/usr/local/src目录下
1. 依次执行docker的安装包
rpm -ivh lxc-libs-1.0.11-1.el6.x86_64.rpm
rpm -ivh lua-alt-getopt-0.7.0-1.el6.noarch.rpm
rpm -ivh lua-filesystem-1.4.2-1.el6.x86_64.rpm
rpm -ivh lua-lxc-1.0.11-1.el6.x86_64.rpm
rpm -ivh lxc-1.0.11-1.el6.x86_64.rpm
rpm -ivh libcgroup-0.40.rc1-24.el6_9.x86_64.rpm
rpm -ivh docker-io-1.7.1-2.el6.x86_64.rpm
如果执行rpm命令失败,尝试需要导入签名:
# rpm --import http://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-6
# rpm –import /etc/pki/rpm-gpg/RPM*
2. 启动服务
方式一:
# docker -d
方式二:
# /etc/init.d/cgconfig restart
# service docker restart
3. 设置开机自动启动
# chkconfig --list docker
# chkconfig --list cgconfig
# chkconfig cgconfig on
# chkconfig docker on
三,问题
1. 运行docker -d
命令报错如下:
# docker -d
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
WARN[0000] You are running linux kernel version 2.6.32-431.el6.x86_64, which might be unstable running docker. Please upgrade your kernel to 3.10.0.
docker: relocation error: docker: symbol dm_task_get_info_with_deferred_remove, version Base not defined in file libdevmapper.so.1.02 with link time reference
解决如下
进入device-mapper-libs目录,依此安装所有包。
方法一(在线方式):
# cd /usr/local/src/docker/device-mapper-libs
# yum -y install device-mapper*
方法二(离线方式):
# rpm -ivh device-mapper***.rpm –-force --nodeps
再次运行docker -d
命令,报错如下:
FATA[0000] Error mounting devices cgroup: mountpoint for devices not found</pre>
解决如下:
找到cgroup目录,然后对其进行挂载,我的安装环境cgroup目录在/cgroup
# vi /etc/fstab
#在结尾添加
none /cgroup cgroup defaults 0 0</pre>
使之挂载生效
# mount -a
再次运行docker -d
;放到后台运行
# mkidr /usr/local/docker
# cd /usr/local/docker
# nohup docker -d &
# tail -f nohup.out
2. 执行service docker restart报如下错误:
(1) 检查cgconfig的状态
# /etc/init.d/cgconfig status
如果没有启动,执行如下命令:
# /etc/init.d/cgconfig restart
执行如下命令,看看是否ok:
# service docker restart
(2) check cgconfig is on
# chkconfig --list cgconfig
cgconfig 0:off 1:off 2:off 3:off 4:off 5:off 6:off
if cgconfig is off, turn it on
(3) if still does not work, may be some cgroups modules is missing. In the kernel .config file, make menuconfig, add those modules into kernel and recompile and reboot
after that, it should be OK
3. rhel 6.5 无法使用 yum epel
Red Hat Enterprise Linux Server(RHEL) 的yum服务是付费的,因为没有付费,所以无法使用yum安装软件,如RHEL想安装LNMP必须要先按此教程设置好yum,并可以正常使用后才可以安装,会提示如下错误:This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 或如下错误信息:This system is not registered with RHN. RHN support will be disabled.
四,参考
http://www.cnblogs.com/hdulzt/p/7834312.html
官方文档: Red Hat Enterprise Linux - Docker Documentation - Docker Docs