linux - 在 Ubuntu 上安装/运行 Docker 时出现问题(dockerd 错误)/守护进程运行?内核升级?

标签 linux docker ubuntu installation

我使用的是 Ubuntu 18.04(运行模拟 Windows),并且是个新手。我按照以下步骤安装了 Docker,但无法让它运行

我用来安装的命令( https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04 ):

  882  sudo apt update
  883  sudo apt install apt-transport-https ca-certificates curl software-properties-common
  884  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  885  sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
  886  sudo apt update
  887  apt-cache policy docker-ce
  888  sudo apt install docker-ce
  889  sudo systemctl status docker
  890  sudo /etc/init.d/docker start

到目前为止一切顺利。现在要检查是否可以从 Docker Hub 访问和下载镜像,我运行:

sudo docker run hello-world

我收到以下错误:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

运行sudo dockerd返回:

INFO[2020-02-22T11:09:04.509355900+08:00] Starting up
INFO[2020-02-22T11:09:04.516510800+08:00] libcontainerd: started new containerd process  pid=3705
INFO[2020-02-22T11:09:04.516870500+08:00] parsed scheme: "unix"                         module=grpc
INFO[2020-02-22T11:09:04.517102600+08:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-02-22T11:09:04.517288800+08:00] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-02-22T11:09:04.517495400+08:00] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2020-02-22T11:09:04.547297900+08:00] starting containerd                           revision=b34a5c8af56e510852c35414db4c1f4fa6172339 version=1.2.10
INFO[2020-02-22T11:09:04.548738200+08:00] loading plugin "io.containerd.content.v1.content"...  type=io.containerd.content.v1
INFO[2020-02-22T11:09:04.548914900+08:00] loading plugin "io.containerd.snapshotter.v1.btrfs"...  type=io.containerd.snapshotter.v1
WARN[2020-02-22T11:09:04.549228300+08:00] failed to load plugin io.containerd.snapshotter.v1.btrfs  error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter"
INFO[2020-02-22T11:09:04.549457200+08:00] loading plugin "io.containerd.snapshotter.v1.aufs"...  type=io.containerd.snapshotter.v1
WARN[2020-02-22T11:09:04.553575600+08:00] failed to load plugin io.containerd.snapshotter.v1.aufs  error="modprobe aufs failed: "modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.0-17763-Microsoft/modules.dep.bin'\nmodprobe: FATAL: Module aufs not found in directory /lib/modules/4.4.0-17763-Microsoft\n": exit status 1"
INFO[2020-02-22T11:09:04.553871800+08:00] loading plugin "io.containerd.snapshotter.v1.native"...  type=io.containerd.snapshotter.v1
INFO[2020-02-22T11:09:04.554049900+08:00] loading plugin "io.containerd.snapshotter.v1.overlayfs"...  type=io.containerd.snapshotter.v1
INFO[2020-02-22T11:09:04.554470800+08:00] loading plugin "io.containerd.snapshotter.v1.zfs"...  type=io.containerd.snapshotter.v1
INFO[2020-02-22T11:09:04.554711200+08:00] skip loading plugin "io.containerd.snapshotter.v1.zfs"...  type=io.containerd.snapshotter.v1
INFO[2020-02-22T11:09:04.555303000+08:00] loading plugin "io.containerd.metadata.v1.bolt"...  type=io.containerd.metadata.v1
WARN[2020-02-22T11:09:04.556436000+08:00] could not use snapshotter btrfs in metadata plugin  error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter"
WARN[2020-02-22T11:09:04.578612300+08:00] could not use snapshotter aufs in metadata plugin  error="modprobe aufs failed: "modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.0-17763-Microsoft/modules.dep.bin'\nmodprobe: FATAL: Module aufs not found in directory /lib/modules/4.4.0-17763-Microsoft\n": exit status 1"
WARN[2020-02-22T11:09:04.585873300+08:00] could not use snapshotter zfs in metadata plugin  error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.zfs must be a zfs filesystem to be used with the zfs snapshotter: skip plugin"
INFO[2020-02-22T11:09:04.597785400+08:00] loading plugin "io.containerd.differ.v1.walking"...  type=io.containerd.differ.v1
INFO[2020-02-22T11:09:04.605886800+08:00] loading plugin "io.containerd.gc.v1.scheduler"...  type=io.containerd.gc.v1
INFO[2020-02-22T11:09:04.609171800+08:00] loading plugin "io.containerd.service.v1.containers-service"...  type=io.containerd.service.v1
INFO[2020-02-22T11:09:04.628196600+08:00] loading plugin "io.containerd.service.v1.content-service"...  type=io.containerd.service.v1
INFO[2020-02-22T11:09:04.645164600+08:00] loading plugin "io.containerd.service.v1.diff-service"...  type=io.containerd.service.v1
INFO[2020-02-22T11:09:04.664083400+08:00] loading plugin "io.containerd.service.v1.images-service"...  type=io.containerd.service.v1
INFO[2020-02-22T11:09:04.670739700+08:00] loading plugin "io.containerd.service.v1.leases-service"...  type=io.containerd.service.v1
INFO[2020-02-22T11:09:04.689722900+08:00] loading plugin "io.containerd.service.v1.namespaces-service"...  type=io.containerd.service.v1
INFO[2020-02-22T11:09:04.705680600+08:00] loading plugin "io.containerd.service.v1.snapshots-service"...  type=io.containerd.service.v1
INFO[2020-02-22T11:09:04.724497600+08:00] loading plugin "io.containerd.runtime.v1.linux"...  type=io.containerd.runtime.v1
INFO[2020-02-22T11:09:04.743291500+08:00] loading plugin "io.containerd.runtime.v2.task"...  type=io.containerd.runtime.v2
INFO[2020-02-22T11:09:04.747424800+08:00] loading plugin "io.containerd.monitor.v1.cgroups"...  type=io.containerd.monitor.v1
INFO[2020-02-22T11:09:04.767781500+08:00] loading plugin "io.containerd.service.v1.tasks-service"...  type=io.containerd.service.v1
INFO[2020-02-22T11:09:04.783546000+08:00] loading plugin "io.containerd.internal.v1.restart"...  type=io.containerd.internal.v1
INFO[2020-02-22T11:09:04.803609700+08:00] loading plugin "io.containerd.grpc.v1.containers"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.806843900+08:00] loading plugin "io.containerd.grpc.v1.content"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.824845300+08:00] loading plugin "io.containerd.grpc.v1.diff"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.825514100+08:00] loading plugin "io.containerd.grpc.v1.events"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.844268300+08:00] loading plugin "io.containerd.grpc.v1.healthcheck"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.862309200+08:00] loading plugin "io.containerd.grpc.v1.images"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.868008900+08:00] loading plugin "io.containerd.grpc.v1.leases"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.868593000+08:00] loading plugin "io.containerd.grpc.v1.namespaces"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.887239600+08:00] loading plugin "io.containerd.internal.v1.opt"...  type=io.containerd.internal.v1
INFO[2020-02-22T11:09:04.904976000+08:00] loading plugin "io.containerd.grpc.v1.snapshots"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.909043500+08:00] loading plugin "io.containerd.grpc.v1.tasks"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.926997400+08:00] loading plugin "io.containerd.grpc.v1.version"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.927696200+08:00] loading plugin "io.containerd.grpc.v1.introspection"...  type=io.containerd.grpc.v1
INFO[2020-02-22T11:09:04.964084500+08:00] serving...                                    address="/var/run/docker/containerd/containerd-debug.sock"
INFO[2020-02-22T11:09:04.976438300+08:00] serving...                                    address="/var/run/docker/containerd/containerd.sock"
INFO[2020-02-22T11:09:04.995872500+08:00] containerd successfully booted in 0.449319s
INFO[2020-02-22T11:09:05.008892100+08:00] parsed scheme: "unix"                         module=grpc
INFO[2020-02-22T11:09:05.011750500+08:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-02-22T11:09:05.033549900+08:00] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-02-22T11:09:05.051284400+08:00] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2020-02-22T11:09:05.055568500+08:00] parsed scheme: "unix"                         module=grpc
INFO[2020-02-22T11:09:05.055766700+08:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-02-22T11:09:05.073081000+08:00] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-02-22T11:09:05.090749400+08:00] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2020-02-22T11:09:05.104871000+08:00] [graphdriver] using prior storage driver: overlay2
WARN[2020-02-22T11:09:05.152741200+08:00] Your kernel does not support cgroup memory limit
WARN[2020-02-22T11:09:05.153377200+08:00] Unable to find cpu cgroup in mounts
WARN[2020-02-22T11:09:05.153980700+08:00] Unable to find blkio cgroup in mounts
WARN[2020-02-22T11:09:05.154573200+08:00] Unable to find cpuset cgroup in mounts
WARN[2020-02-22T11:09:05.155169600+08:00] mountpoint for pids not found
INFO[2020-02-22T11:09:05.155932100+08:00] Loading containers: start.
WARN[2020-02-22T11:09:05.160351700+08:00] Running iptables --wait -t nat -L -n failed with message: `iptables v1.6.1: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.`, error: exit status 3
INFO[2020-02-22T11:09:05.234905500+08:00] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
INFO[2020-02-22T11:09:05.235118300+08:00] stopping healthcheck following graceful shutdown  module=libcontainerd
INFO[2020-02-22T11:09:05.235126900+08:00] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.1: 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)

我完全迷失在这里,缺乏解决问题的背景 - 我正在参加网络开发类(class),这是很多东西/练习的要求。谢谢!

最佳答案

您无法在适用于 Linux 的 Windows 子系统下运行 Docker。 Docker 依赖于许多 WSL 尚未实现的 Linux 内核功能。您的名字在评论中看起来像这样:

Linux DESKTOP-CD69S60 4.4.0-17763-Microsoft #864-Microsoft Thu Nov 07 15:22:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux

17763-Microsoft 是关键部分 - 这意味着您实际上并未运行 Linux 内核,而是运行 WSL 内核(这是 Windows NT 之上的 Linux 的近似版本)。

您需要使用 WSL2(它运行真正的虚拟机,而不是部分 Linux 兼容的内核)或其他虚拟化技术,例如 VMware、Hyper-V 或 VirtualBox。如果您安装了 Hyper-V,由于 Hyper-V 的工作原理,VMware 和 VirtualBox 都将不再可选,因此,如果您发现 Hyper-V 不能满足您的需求,则需要使用 Hyper-V Switcher 之类的工具将其关闭(然后其他虚拟化技术将起作用)。

关于linux - 在 Ubuntu 上安装/运行 Docker 时出现问题(dockerd 错误)/守护进程运行?内核升级?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60348724/

相关文章:

linux - 在后台运行 SCP 并监控进度

android - Linux 是 Android 开发人员的通用环境吗?

docker - 我应该如何将应用程序配置放入我的 Docker 容器中?

postgresql - 来自 Ubuntu VM 的 Postgres ODBC 连接问题

java - Ubuntu java 错误日志

linux - 哪个网络服务器适合这种设计?

docker - 为什么在 docker-compose 中我应该写卷的完整路径?

docker - 如何在运行docker run命令时在docker文件中动态传递ENV值?

qt - 为什么qt5-default包里没有qmake-qt5

java - 设置 java 主页