Docker问题

记录在安装使用docker过程中遇到的一些问题。

问题一

首次安装以后,利用命令 sudo service docker start,出现以下问题:

Starting cgconfig service: Error: cannot mount memory to /cgroup/memory: No such file or directory
/sbin/cgconfigparser; error loading /etc/cgconfig.conf: Cgroup mounting failed
Failed to parse /etc/cgconfig.conf or /etc/cgconfig.d      [FAILED]
Starting docker:                                           [  OK  ]

修改

[jipeng@jpdb ~]$ sudo vi /etc/cgconfig.conf 
#
#  Copyright IBM Corporation. 2007
#
#  Authors:     Balbir Singh <balbir@linux.vnet.ibm.com>
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of version 2.1 of the GNU Lesser General Public License
#  as published by the Free Software Foundation.
#
#  This program is distributed in the hope that it would be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See man cgconfig.conf for further details.
#
# By default, mount all controllers to /cgroup/<controller>

mount {
        cpuset  = /cgroup/cpuset;
        cpu     = /cgroup/cpu;
        cpuacct = /cgroup/cpuacct;
#       memory  = /cgroup/memory;  #将该行注释掉
        devices = /cgroup/devices;
        freezer = /cgroup/freezer;
        net_cls = /cgroup/net_cls;
        blkio   = /cgroup/blkio;
}

问题二

在docker安装完成后,启动docker,然后查看状态,出现以下问题

[jipeng@coordinator ~]$ sudo service docker start
Starting docker:                                           [  OK  ]
[jipeng@coordinator ~]$ sudo service docker status
docker dead but subsys locked
[jipeng@coordinator ~]$ sudo docker -d
FATA[0000] Error starting daemon: open /var/run/docker.pid: permission denied 
[jipeng@coordinator subsys]$ sudo docker -d
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock) 
INFO[0000] [graphdriver] using prior storage driver "devicemapper" 
WARN[0000] Running modprobe bridge nf_nat failed with message: , error: exit status 1 
FATA[0000] Error starting daemon: Error initializing network controller: Error creating default "bridge" network: Failed to Setup IP tables: Unable to enable NAT rule: iptables failed: iptables -t nat -I POSTROUTING -s 172.17.42.1/16 ! -o docker0 -j MASQUERADE: iptables v1.4.7: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
 (exit status 3) 

出现上述问题的原因猜测是由于在编译内核的时候,没有把NAT相关的模块编译进内核或编译成模块。