我正在尝试在运行 debian stretch 的虚拟机中安装 Docker,我的公司为我提供了该虚拟机的访问权限。在论坛上搜索后,我看到许多帖子声称这是开箱即用的。
然而,按照安装指南(我尝试了Debian 官方 docker 安装指南以及ASAdigitalocean 的 docker 安装指南得到相同的结果)每次我使用 apt 安装 docker-ce 时都会遇到相同的错误。
错误如下所示(抱歉,该系统是德语版本):
update-alternatives: Warnung: Neuinstallation der Alternative /usr/bin/dockerd-ce ist erzwungen, weil Linkgruppe dockerd defekt ist
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2019-03-21 17:46:12 CET; 18ms ago
Docs: https://docs.docker.com
Process: 4481 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 4481 (code=exited, status=1/FAILURE)
CPU: 179ms
Mär 21 17:46:12 docker.example.com systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Mär 21 17:46:12 docker.example.com systemd[1]: Failed to start Docker Application Container Engine.
Mär 21 17:46:12 docker.example.com systemd[1]: docker.service: Unit entered failed state.
Mär 21 17:46:12 docker.example.com systemd[1]: docker.service: Failed with result 'exit-code'.
dpkg: Fehler beim Bearbeiten des Paketes docker-ce (--configure):
Unterprozess installiertes post-installation-Skript gab den Fehlerwert 1 zurück
Fehler traten auf beim Bearbeiten von:
docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)
当我运行 journalctl -xe 时,我收到一些错误行:
level=error msg="'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded." storage-driver=overlay2
level=error msg="AUFS was not found in /proc/filesystems" storage-driver=aufs
level=error msg="'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded." storage-driver=overlay
level=error msg="Failed to built-in GetDriver graph devicemapper /var/lib/docker"
...
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.4-example/modules.dep.bin'
modprobe: FATAL: Module ip_tables not found in directory /lib/modules/4.19.4-example
iptables v1.6.0: 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)
docker.service: Main process exited, code=exited, status=1/FAILURE
Failed to start Docker Application Container Engine.
在安装 docker 之前,我已经重启多次并检查 iptables 是否存在。
我怎样才能让它工作?
答案1
提供虚拟机的公司使用的是具有较新内核的 Debian。当 Docker 搜索模块时,它会锁定最新内核的模块,这些模块的版本号与 Debian 附带的模块不同。让公司安装所用内核版本的模块解决了该问题。