简体   繁体   中英

Problem installing/running Docker on Ubuntu (dockerd errors) / Daemons running? Kernel upgarde?

I am on Ubuntu 18.04 (running emulated Windows) and am a total newbie. I followed the below steps to install Docker, but can't get it to run .

Commands I used to install ( 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

So far so good. Now to check whether you can access and download images from Docker Hub, I run:

sudo docker run hello-world

And I get the following error:

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

Running sudo dockerd returns:

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)

I am totally lost here and lack the background to fix what's wrong - I am taking a web dev class and it's a requirement for a lot of the stuff/exercises. Thank you!

You cannot run Docker under Windows Subsystem for Linux. Docker depends on many Linux kernel features which WSL has not implemented. Your uname looks like this from a comment:

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

The 17763-Microsoft is the key part - this means you're not actually running the Linux kernel, but instead are running the WSL kernel (which is an approximation of Linux on top of Windows NT).

You need to either use WSL2 (which runs a real virtual machine instead of a partially Linux compatible kernel) or another virtualization technology like VMware, Hyper-V, or VirtualBox. If you install Hyper-V, both VMware and VirtualBox become non-options due to how Hyper-V works, so you'll need something like Hyper-V Switcher to turn it off if you find that Hyper-V doesn't satisfy your needs (and then other virtualization technology will work).

You will have to add the user to the docker group.

Example:

usermod -g  docker username

Then, you will be able to connect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM