注意:
docker容器最早受到RHEL完善的支持是从最近的CentOS 7.0开始的,官方说明是只能运行于64位架构平台,内核版本为2.6.32-431及以上(即>=CentOS 6.5,运行docker时实际提示3.8.0及以上),升级内核请参考CentOS 6.x 内核升级,请参考CentOS 6.x 内核升级(2.6.32 -> 3.10.58)过程记录。
系统是centos 6
[hadoop@tongjibi54 yum.repos.d]$ sudo yum install docker Loaded plugins: fastestmirror, priorities, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.sina.cn * extras: mirrors.163.com * updates: mirrors.sina.cn Setting up Install Process No package docker available.原来CentOS-6上docker的安装包叫docker-io,不叫docker;并且来源于Fedora epel库,这个仓库维护了大量的没有包含在发行版中的软件,所以先要安装EPEL,而CentOS-7的docker直接包含在官方镜像源的Extras仓库(CentOS-Base.repo下的[extras]节enable=1启用)。
安装epel:
yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
终于可以安装docker了,,没想到又报错:
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
处理方法,修改文件“/etc/yum.repos.d/epel.repo”, 将baseurl的注释取消, mirrorlist注释掉。即可。
sudo yum install docker-io
一路”y“即可。
没想到又报错了:
FATA[0000] Get http:///var/run/docker.sock/v1.17/info: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
lsmod | grep bridge
没有bridge模块;
sudo yum install bridge-utils
[hadoop@tongjibi54 yum.repos.d]$ lsmod|grep bridge bridge 79790 0 stp 2173 1 bridge llc 5642 2 bridge,stp
如果不启动docker服务也会报错:
执行以下命令:
sudo docker -d -H unix:///var/run/docker.sock
[hadoop@tongjibi54 yum.repos.d]$ sudo docker -d -H unix:///var/run/docker.sock INFO[0000] +job serveapi(unix:///var/run/docker.sock) INFO[0000] WARNING: You are running linux kernel version 2.6.32-220.el6.x86_64, 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
提示linux内核太低建议升级,偶这个只是个警告,关键应该是最后的报错;
解决办法:
执行:yum upgrade device-mapper-libs
又有了新的报错:
[hadoop@tongjibi54 yum.repos.d]$ sudo docker -d -H unix:///var/run/docker.sock INFO[0000] +job serveapi(unix:///var/run/docker.sock) INFO[0000] WARNING: You are running linux kernel version 2.6.32-220.el6.x86_64, 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算是安装成功了,但是启动服务报错,这个是缺失依赖模块导致的,由于机器跑的有业务搞到这里不敢继续搞了,以下列出缺失模块:
运行 check-config.sh
warning: /proc/config.gz does not exist, searching other paths for kernel config... info: reading kernel config from /boot/config-2.6.32-220.el6.x86_64 ... Generally Necessary: - cgroup hierarchy: nonexistent?? (see https://github.com/tianon/cgroupfs-mount) - 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_CPUSETS: 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_MEMCG_SWAP_ENABLED: missing - CONFIG_RESOURCE_COUNTERS: enabled - CONFIG_CGROUP_PERF: enabled - CONFIG_CFS_BANDWIDTH: 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: missing - CONFIG_EXT4_FS: enabled - CONFIG_EXT4_FS_POSIX_ACL: enabled - CONFIG_EXT4_FS_SECURITY: enabled - "overlay": - CONFIG_OVERLAY_FS: missing - CONFIG_EXT4_FS_SECURITY: enabled - CONFIG_EXT4_FS_POSIX_ACL: enabled
经过这次折腾发现在centos 6.2上安装docker就是个噩梦啊!!强烈建议升级内核,享受一键安装的乐趣~
check-config.sh 代码:
#!/usr/bin/env bash set -e # bits of this were adapted from lxc-checkconfig # see also https://github.com/lxc/lxc/blob/lxc-1.0.2/src/lxc/lxc-checkconfig.in possibleConfigs=( '/proc/config.gz' "/boot/config-$(uname -r)" "/usr/src/linux-$(uname -r)/.config" '/usr/src/linux/.config' ) if [ $# -gt 0 ]; then CONFIG="$1" else : ${CONFIG:="${possibleConfigs[0]}"} fi if ! command -v zgrep &> /dev/null; then zgrep() { zcat "$2" | grep "$1" } fi is_set() { zgrep "CONFIG_$1=[y|m]" "$CONFIG" > /dev/null } # see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors declare -A colors=( [black]=30 [red]=31 [green]=32 [yellow]=33 [blue]=34 [magenta]=35 [cyan]=36 [white]=37 ) color() { color=() if [ "$1" = 'bold' ]; then color+=( '1' ) shift fi if [ $# -gt 0 ] && [ "${colors[$1]}" ]; then color+=( "${colors[$1]}" ) fi local IFS=';' echo -en '\033['"${color[*]}"m } wrap_color() { text="$1" shift color "$@" echo -n "$text" color reset echo } wrap_good() { echo "$(wrap_color "$1" white): $(wrap_color "$2" green)" } wrap_bad() { echo "$(wrap_color "$1" bold): $(wrap_color "$2" bold red)" } wrap_warning() { wrap_color >&2 "$*" red } check_flag() { if is_set "$1"; then wrap_good "CONFIG_$1" 'enabled' else wrap_bad "CONFIG_$1" 'missing' fi } check_flags() { for flag in "$@"; do echo "- $(check_flag "$flag")" done } if [ ! -e "$CONFIG" ]; then wrap_warning "warning: $CONFIG does not exist, searching other paths for kernel config..." for tryConfig in "${possibleConfigs[@]}"; do if [ -e "$tryConfig" ]; then CONFIG="$tryConfig" break fi done if [ ! -e "$CONFIG" ]; then wrap_warning "error: cannot find kernel config" wrap_warning " try running this script again, specifying the kernel config:" wrap_warning " CONFIG=/path/to/kernel/.config $0 or $0 /path/to/kernel/.config" exit 1 fi fi wrap_color "info: reading kernel config from $CONFIG ..." white echo echo 'Generally Necessary:' echo -n '- ' cgroupSubsystemDir="$(awk '/[, ](cpu|cpuacct|cpuset|devices|freezer|memory)[, ]/ && $3 == "cgroup" { print $2 }' /proc/mounts | head -n1)" cgroupDir="$(dirname "$cgroupSubsystemDir")" if [ -d "$cgroupDir/cpu" -o -d "$cgroupDir/cpuacct" -o -d "$cgroupDir/cpuset" -o -d "$cgroupDir/devices" -o -d "$cgroupDir/freezer" -o -d "$cgroupDir/memory" ]; then echo "$(wrap_good 'cgroup hierarchy' 'properly mounted') [$cgroupDir]" else if [ "$cgroupSubsystemDir" ]; then echo "$(wrap_bad 'cgroup hierarchy' 'single mountpoint!') [$cgroupSubsystemDir]" else echo "$(wrap_bad 'cgroup hierarchy' 'nonexistent??')" fi echo " $(wrap_color '(see https://github.com/tianon/cgroupfs-mount)' yellow)" fi if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then echo -n '- ' if command -v apparmor_parser &> /dev/null; then echo "$(wrap_good 'apparmor' 'enabled and tools installed')" else echo "$(wrap_bad 'apparmor' 'enabled, but apparmor_parser missing')" echo -n ' ' if command -v apt-get &> /dev/null; then echo "$(wrap_color '(use "apt-get install apparmor" to fix this)')" elif command -v yum &> /dev/null; then echo "$(wrap_color '(your best bet is "yum install apparmor-parser")')" else echo "$(wrap_color '(look for an "apparmor" package for your distribution)')" fi fi fi flags=( NAMESPACES {NET,PID,IPC,UTS}_NS DEVPTS_MULTIPLE_INSTANCES CGROUPS CGROUP_CPUACCT CGROUP_DEVICE CGROUP_FREEZER CGROUP_SCHED CPUSETS MACVLAN VETH BRIDGE NF_NAT_IPV4 IP_NF_FILTER IP_NF_TARGET_MASQUERADE NETFILTER_XT_MATCH_{ADDRTYPE,CONNTRACK} NF_NAT NF_NAT_NEEDED # required for bind-mounting /dev/mqueue into containers POSIX_MQUEUE ) check_flags "${flags[@]}" echo echo 'Optional Features:' { check_flags MEMCG_SWAP check_flags MEMCG_SWAP_ENABLED if is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then echo " $(wrap_color '(note that cgroup swap accounting is not enabled in your kernel config, you can enable it by setting boot option "swapaccount=1")' bold black)" fi } flags=( RESOURCE_COUNTERS CGROUP_PERF CFS_BANDWIDTH ) check_flags "${flags[@]}" echo '- Storage Drivers:' { echo '- "'$(wrap_color 'aufs' blue)'":' check_flags AUFS_FS | sed 's/^/ /' if ! is_set AUFS_FS && grep -q aufs /proc/filesystems; then echo " $(wrap_color '(note that some kernels include AUFS patches but not the AUFS_FS flag)' bold black)" fi check_flags EXT4_FS_POSIX_ACL EXT4_FS_SECURITY | sed 's/^/ /' echo '- "'$(wrap_color 'btrfs' blue)'":' check_flags BTRFS_FS | sed 's/^/ /' echo '- "'$(wrap_color 'devicemapper' blue)'":' check_flags BLK_DEV_DM DM_THIN_PROVISIONING EXT4_FS EXT4_FS_POSIX_ACL EXT4_FS_SECURITY | sed 's/^/ /' echo '- "'$(wrap_color 'overlay' blue)'":' check_flags OVERLAY_FS EXT4_FS_SECURITY EXT4_FS_POSIX_ACL | sed 's/^/ /' } | sed 's/^/ /' echo #echo 'Potential Future Features:' #check_flags USER_NS #echo
reference:
http://segmentfault.com/a/1190000000735011
在 CentOS 6.x上安装 docker.io成功:http://www.aixchina.net/home/space.php?uid=59140&do=blog&id=143237