手机
当前位置:查字典教程网 >操作系统 >RedHat/Centos >在CentOS系统中安装Docker的教程
在CentOS系统中安装Docker的教程
摘要:最近折腾centos6,需要在其上配置docker,而以前都是在ubuntu上玩的,网上的文章没有找到一个让我直接能配成功的,多少都会有些坑...

最近折腾centos6,需要在其上配置docker,而以前都是在ubuntu上玩的,网上的文章没有找到一个让我直接能配成功的,多少都会有些坑,综合了几篇文章,折腾了老久,终于成功了。

我保证你按我下面的步骤一步步做,一定能一次成功!

1、因为selinux和LXC有冲突,所以需要禁用

# vi /etc/selinux/config

SELINUX=disabled

2、配置Fedora EPEL 源

# yum install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm

3、配置hop5.in源

# cd /etc/yum.repos.d

# wget http://www.hop5.in/yum/el6/hop5.repo

# yum install kernel-ml-aufs kernel-ml-aufs-devel (yum安装带aufs模块的3.10内核)

4、安装docker-io

# yum install docker-io

6、要想docker正常运行还需要在/etc/fstab里增加cgroup文件系统

# echo "none /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab

# mount /sys/fs/cgroup

只有重新启动才能挂载/sys/fs/cgroup(因为当前运行的内核不支持cgroup),所以上面挂载的命令也可以不执行,但系统需要重新启动。

7、重启系统,选择“3.10.5-3.el6.x86_64”内核

8、系统启动后,确认当前运行的内核

# uname -r

3.10.5-3.el6.x86_64

# grep aufs /proc/filesystems

nodev aufs

9、以守护模式运行docker.io(在一个新的终端里)

# docker -d

10、重置docker的运行环境,从而解决上述问题。

# pkill docker

# iptables -t nat -F

# ifconfig docker0 down

# brctl delbr docker0

# docker -d

安装了新的内核,就存在启动时的选择问题,这个要通过修改/boot/grub/grub.conf文件来实现。

grub.conf 文件参数意义

default=1 # 默认启动的内核title, 0 表示是第一个

timeout=5 # 默认等待时间

splashimage=(hd0,0)/grub/splash.xpm.gz # 指定菜单的背景图片的路径。为xpm格式,采用gzip压缩,只能为14bits色

hiddenmenu # 隐藏菜单

title CentOS (2.6.32-358.el6.x86_64) # 标题名,用户可自定义

root (hd0,0) # 指定 grub 的根位置

# 指定 kernel 文件的位置,还要指出 root(系统启动后) 的位置,挂载方式 ro,这项很关键。

# 加载后会启动 init 进程。

kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/vg0-root rd_NO_LUKS rd_NO_DM LANG=en_US.UTF-8 rd_LVM_LV=vg0/swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=vg0/root KEYBOARDTYPE=pc KEYTABLE=us rhgb crashkernel=auto quiet rhgb quiet

# 在内核启动过程中装载根文件系统时有用

initrd /initramfs-2.6.32-358.el6.x86_64.img

常见错误解决范例:

例1

执行yum就开始报错:

Error: Cannot retrieve metalink for repository: epel. Please ...

解决办法都是编辑/etc/yum.repos.d/epel.repo,把基础的恢复,镜像的地址注释掉

#baseurl 改成 baseurl

mirrorlist 改成 #mirrorlist

例2

"DNS/Networking Errors inside the docker"

[root@localhost ~]# docker -dns="8.8.8.8" run centos:6.4 yum install hiphop-php

2013/08/21 07:53:05 POST /v1.4/containers/create

2013/08/21 07:53:05 POST /v1.4/containers/6d9fef14bd1a/start

2013/08/21 07:53:05 POST /v1.4/containers/6d9fef14bd1a/attach?logs=1&stderr=1&stdout=1&stream=1

Loaded plugins: fastestmirror

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

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was

14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"

可以执行下面的命令来重置docker的运行环境,从而解决上述问题。

pkill docker

iptables -t nat -F

ifconfig docker0 down

brctl delbr docker0

docker -d

【在CentOS系统中安装Docker的教程】相关文章:

利用Kickstart自动化安装CentOS的教程

CentOS系统中使用pptp架设vpn的方法

在 CentOS 7 系统上安装 Kernel 4.0的方法

在CentOS系统挂载U盘的解决方案网上没有的

在CentOS系统中使用yum命令升级插件的方法

在CentOS系统中编译安装Hiawatha服务器的教程

Linux系统中查找文件的方法

CentOS中net-snmpd的安装和基本配置教程

CentOS系统中常用查看系统信息和日志命令小结

在CentOS系统下安装SVN服务器的教程

精品推荐
分类导航