Chinaunix首页 | 论坛 | 博客
  • 博客访问: 369184
  • 博文数量: 159
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 182
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-02 10:42
文章分类

全部博文(159)

文章存档

2015年(18)

2014年(132)

2013年(9)

分类: 云计算

2015-09-14 20:12:43

原文地址:在Centos6.3上折腾Docker 作者:frankzfz

1.    概述

         安装和运行Docker最好是在官方建议的Linux-kernel-3.8版本以上,通过在Centos6.3上安装和运行Docker的深刻体会就是不问题,Centos6.3的发行版的内核版本为2.6.32.279,对于Docker的一些支持不是很完善,内核出现panic的概率比较大。下面的仅仅记录一下其中折腾的过程。

1.1 安装

         centos6.3上安装docker,通过下面的命令查看我的发行版的版本信息,这里需要注意的是,docker现在只支持64位的操作系统,如果需要使用32位操作系统可以参考我的另外一篇博客(其实32位的操作系统对于docker已经没有意义,也完全没有必要折腾)。

         [root@centos ~]# cat /etc/redhat-release

CentOS release 6.3 (Final)

centos6.3上通过下面的两个命令进行安装docker,从下面的信息中可以看出安装的docker版本为1.4.1

sudo yum install

yum install docker-io

 

Installed size: 20 M

Is this ok [y/N]: y

Downloading Packages:

Setting up and reading Presto delta metadata

Processing delta metadata

Package(s) data still to download: 4.9 M

(1/6):docker-io-1.4.1-3.el6.x86_64.rpm              | 4.5 MB     00:00                                                              

(2/6):lua-alt-getopt-0.7.0-1.el6.noarch.rpm         | 6.9 kB     00:00                                                           

(3/6):lua-filesystem-1.4.2-1.el6.x86_64.rpm           |  24 kB     00:00                                                            

(4/6):lua-lxc-1.0.7-1.el6.x86_64.rpm               |  15 kB     00:00                                                               

(5/6):lxc-1.0.7-1.el6.x86_64.rpm             | 120 kB     00:00                                                                     

(6/6):lxc-libs-1.0.7-1.el6.x86_64.rpm              | 249 kB     00:00                                                               

--------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                  17 MB/s | 4.9 MB     00:00    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing:lxc-libs-1.0.7-1.el6.x86_64     1/6                                                                               

  Installing:lua-filesystem-1.4.2-1.el6.x86_64     2/6                                                                           

  Installing:lua-lxc-1.0.7-1.el6.x86_64    3/6                                                                                    

  Installing:lua-alt-getopt-0.7.0-1.el6.noarch     4/6                                                                            

  Installing:lxc-1.0.7-1.el6.x86_64        5/6                                                                                    

  Installing:docker-io-1.4.1-3.el6.x86_64          6/6                                                                             

  Verifying:lxc-1.0.7-1.el6.x86_64         1/6                                                                                    

  Verifying:lua-lxc-1.0.7-1.el6.x86_64            2/6                                                                            

  Verifying:lxc-libs-1.0.7-1.el6.x86_64        3/6                                                                                

  Verifying:docker-io-1.4.1-3.el6.x86_64                4/6                                                                      

  Verifying:lua-alt-getopt-0.7.0-1.el6.noarch      5/6                                                                            

  Verifying:lua-filesystem-1.4.2-1.el6.x86_64       6/6                                                                          

 

Installed:

  docker-io.x86_64 0:1.4.1-3.el6                                                                                                      

 

Dependency Installed:

  lua-alt-getopt.noarch 0:0.7.0-1.el6  lua-filesystem.x86_64 0:1.4.2-1.el6  lua-lxc.x86_64 0:1.0.7-1.el6  lxc.x86_64 0:1.0.7-1.el6

  lxc-libs.x86_64 0:1.0.7-1.el6      

 

Complete!

1.1.1 centos7.0安装

         centos7.0上安装和启动都很正常和顺利,没有出现centos6.3上的问题,主要是使用下面的命令。

yum install docker

安装之后启动并且在开机自动启动。

root@centos ~]# sudo service docker start

Redirecting to /bin/systemctl start  docker.service

 [root@centos~]# sudo chkconfig docker on

Note: Forwarding request to 'systemctl enable docker.service'.

ln -s '/usr/lib/systemd/system/docker.service' '/etc/systemd/system/multi-user.target.wants/docker.service'

1.2 启动docker

         安装完docker后,可以使用下面的命令启动,

root@centos~]# service docker start

Starting cgconfig service:                                 [  OK  ]

Starting docker:                                          [  OK  ]

         在运行docker时,出现下面的错误信息:

[root@centos ~]# docker -d

INFO[0000] +job serveapi(unix:///var/run/docker.sock)  

INFO[0000] WARNING: You are running linux kernel version 2.6.32, which might be unstable running docker. Please upgrade your kernel to 3.8.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

根据提示,使用下面的命令安装缺少的数据包,

yum upgrade device-mapper-libs

然后,再次运行,还是出现错误信息,但是错误的提示信息已经发送了变化,

[root@10-10-62-234 ~]# docker -d

INFO[0000] +job serveapi(unix:///var/run/docker.sock)  

INFO[0000] WARNING: You are running linux kernel version 2.6.32, which might be unstable running docker. Please upgrade your kernel to 3.8.0.

INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)

FATA[0000] Error running DeviceCreate (CreatePool) dm_task_run failed

         在网上查找到有对该问题的讨论,可以参考下面的链接信息:

         docker的官网上有一个脚本可以检查当前内核中的.config文件中的必要选项是否开启,check-config.sh,下面的信息列出了那些是必须的模块,那些已经进行使能,那些是miss的。

         ./check-config.sh /usr/src/kernels/2.6.32/.config

Generally Necessary:

- cgroup hierarchy: properly mounted [/cgroup]

- CONFIG_NAMESPACES: enabled

- CONFIG_NET_NS: enabled

- CONFIG_PID_NS: enabled

- CONFIG_IPC_NS: enabled

- CONFIG_UTS_NS: enabled

- CONFIG_DEVPTS_MULTIPLE_INSTANCES: enabled

- CONFIG_CGROUPS: enabled

- CONFIG_CGROUP_CPUACCT: enabled

- CONFIG_CGROUP_DEVICE: enabled

- CONFIG_CGROUP_FREEZER: enabled

- CONFIG_CGROUP_SCHED: enabled

- CONFIG_MACVLAN: enabled

- CONFIG_VETH: enabled

- CONFIG_BRIDGE: enabled

- CONFIG_NF_NAT_IPV4: missing

- CONFIG_IP_NF_FILTER: enabled

- CONFIG_IP_NF_TARGET_MASQUERADE: enabled

- CONFIG_NETFILTER_XT_MATCH_ADDRTYPE: missing

- CONFIG_NETFILTER_XT_MATCH_CONNTRACK: enabled

- CONFIG_NF_NAT: enabled

- CONFIG_NF_NAT_NEEDED: enabled

- CONFIG_POSIX_MQUEUE: enabled

 

Optional Features:

- CONFIG_MEMCG_SWAP: missing

- CONFIG_RESOURCE_COUNTERS: enabled

- CONFIG_CGROUP_PERF: enabled

- Storage Drivers:

  - "aufs":

    - CONFIG_AUFS_FS: missing

    - CONFIG_EXT4_FS_POSIX_ACL: enabled

    - CONFIG_EXT4_FS_SECURITY: enabled

  - "btrfs":

    - CONFIG_BTRFS_FS: enabled

  - "devicemapper":

    - CONFIG_BLK_DEV_DM: enabled

    - CONFIG_DM_THIN_PROVISIONING: enabled

    - CONFIG_EXT4_FS: enabled

    - CONFIG_EXT4_FS_POSIX_ACL: enabled

    - CONFIG_EXT4_FS_SECURITY: enabled

  - "overlay":

    - CONFIG_OVERLAY_FS: missing

根据上面的讨论,在Linux 内核中的.config文件中把下面的选项打开,CONFIG_DM_THIN_PROVISIONING=m  修改为CONFIG_DM_THIN_PROVISIONING=y,重新编译内核OK

[root@centos docker]# ps aux | grep docker

root      1312  0.7  1.0 608964 39120 ?        Sl   16:44   0:20 /usr/bin/docker -d

root      2182  0.0  0.0 103236   844 pts/0    R+   17:26   0:00 grep docker

         centos6.3上使用docker的过程中多次产生下面的panic信息,在centos6.3上对于该版本的docker并不是很稳定。

阅读(1277) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~