Virtual-Machines

在執行 debian stretch 的虛擬機中安裝 Docker 是否有特殊的先決條件?

  • March 23, 2019

我正在嘗試將 Docker 安裝在執行 debian 拉伸的虛擬機中,我的公司提供了訪問權限。通過論壇搜尋,我閱讀了許多聲稱這是開箱即用的文章。

但是,當遵循安裝指南(我嘗試了debian 的官方 docker 安裝指南以及digitalocean 的 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 是否存在。

我怎樣才能讓它工作?

提供 VM 的公司正在使用帶有更新核心的 debian。當 docker 搜尋模組時,它鎖定了最新核心的模組,這些模組的版本號與 debian 附帶的模組不同。讓公司為使用的核心版本安裝模組解決了這個問題。

引用自:https://serverfault.com/questions/959378