我正在努力学习Docker。我刚安装时能够发出docker
命令,但是重新启动工作站后,我就无法再运行docker
命令了。我注意到docker
守护进程/服务没有运行,所以我尝试启动它,但无法启动:
[alexus@wcmisdlin02 ~]$ sudo systemctl start docker
[sudo] password for alexus:
Job for docker.service failed. See 'systemctl status docker.service' and 'journalctl -xn' for details.
[alexus@wcmisdlin02 ~]$ sudo systemctl status docker
docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled)
Active: failed (Result: timeout) since Sun 2015-09-13 16:35:48 EDT; 49s ago
Docs: http://docs.docker.com
Main PID: 549
Sep 13 16:34:18 wcmisdlin02.uftmasterad.org docker[549]: time="2015-09-13T16:34:18.194322255-04:00" level=info msg="Listening for HTTP on unix (/var/run/docker.sock)"
Sep 13 16:34:18 wcmisdlin02.uftmasterad.org docker[549]: time="2015-09-13T16:34:18.379197462-04:00" level=error msg="WARNING: No --storage-opt dm.thinpooldev specified, using loopback; this configuration is strongly dis... production use"
Sep 13 16:34:18 wcmisdlin02.uftmasterad.org docker[549]: time="2015-09-13T16:34:18.731795504-04:00" level=info msg="[graphdriver] using prior storage driver \"devicemapper\""
Sep 13 16:34:18 wcmisdlin02.uftmasterad.org docker[549]: time="2015-09-13T16:34:18.782541438-04:00" level=warning msg="Running modprobe bridge nf_nat br_netfilter failed with message: , error: exit status 1"
Sep 13 16:35:48 wcmisdlin02.uftmasterad.org systemd[1]: docker.service operation timed out. Terminating.
Sep 13 16:35:48 wcmisdlin02.uftmasterad.org systemd[1]: Failed to start Docker Application Container Engine.
Sep 13 16:35:48 wcmisdlin02.uftmasterad.org systemd[1]: Unit docker.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
[alexus@wcmisdlin02 ~]$ journalctl -xn
No journal files were found.
[alexus@wcmisdlin02 ~]$ rpm -q docker docker-selinux
docker-1.7.1-108.el7.centos.x86_64
docker-selinux-1.7.1-108.el7.centos.x86_64
[alexus@wcmisdlin02 ~]$ cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
[alexus@wcmisdlin02 ~]$ uname -a
Linux wcmisdlin02.uftmasterad.org 3.10.0-229.11.1.el7.x86_64 #1 SMP Thu Aug 6 01:06:18 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[alexus@wcmisdlin02 ~]$
* 更新 *
[alexus@wcmisdlin02 ~]$ sudo modprobe bridge
[alexus@wcmisdlin02 ~]$ sudo modprobe nf_nat
[alexus@wcmisdlin02 ~]$ sudo modprobe br_netfilter
modprobe: FATAL: Module br_netfilter not found.
[alexus@wcmisdlin02 ~]$
*更新 #2*
[alexus@wcmisdlin02 ~]$ getenforce
Enforcing
[alexus@wcmisdlin02 ~]$ sudo setenforce 0
[alexus@wcmisdlin02 ~]$ sudo systemctl start docker
[alexus@wcmisdlin02 ~]$ sudo systemctl status docker
docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled)
Active: active (running) since Sun 2015-09-13 18:27:23 EDT; 4s ago
Docs: http://docs.docker.com
Main PID: 3317 (docker)
CGroup: /system.slice/docker.service
└─3317 /usr/bin/docker -d --selinux-enabled
Sep 13 18:27:22 wcmisdlin02.uftmasterad.org docker[3317]: time="2015-09-13T18:27:22.792673926-04:00" level=error msg="WARNING: No --storage-opt dm.thinpooldev specified, using loopback; this configuration is strongly dis...production use"
Sep 13 18:27:23 wcmisdlin02.uftmasterad.org docker[3317]: time="2015-09-13T18:27:23.139976126-04:00" level=info msg="[graphdriver] using prior storage driver \"devicemapper\""
Sep 13 18:27:23 wcmisdlin02.uftmasterad.org docker[3317]: time="2015-09-13T18:27:23.220898568-04:00" level=warning msg="Running modprobe bridge nf_nat br_netfilter failed with message: , error: exit status 1"
Sep 13 18:27:23 wcmisdlin02.uftmasterad.org docker[3317]: time="2015-09-13T18:27:23.245690245-04:00" level=info msg="Firewalld running: true"
Sep 13 18:27:23 wcmisdlin02.uftmasterad.org docker[3317]: time="2015-09-13T18:27:23.853155213-04:00" level=info msg="Loading containers: start."
Sep 13 18:27:23 wcmisdlin02.uftmasterad.org docker[3317]: ......
Sep 13 18:27:23 wcmisdlin02.uftmasterad.org docker[3317]: time="2015-09-13T18:27:23.920468550-04:00" level=info msg="Loading containers: done."
Sep 13 18:27:23 wcmisdlin02.uftmasterad.org docker[3317]: time="2015-09-13T18:27:23.920491990-04:00" level=info msg="Daemon has completed initialization"
Sep 13 18:27:23 wcmisdlin02.uftmasterad.org docker[3317]: time="2015-09-13T18:27:23.920513457-04:00" level=info msg="Docker daemon" commit="3043001/1.7.1" execdriver=native-0.2 graphdriver=devicemapper version=1.7.1
Sep 13 18:27:23 wcmisdlin02.uftmasterad.org systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
[alexus@wcmisdlin02 ~]$
答案1
这不是内核模块的问题,也与防火墙无关。解决方案是安装 docker-selinux 软件包并重新启动(可能在执行此操作之前使用 semodule -i 加载策略文件。)