首页 > 解决方案 > docker build -“连接时出错:此错误可能表明 docker 守护程序没有运行。”

问题描述

我正在使用 CLI Git Bash、WSL2 和 PowerShell 在 Windows 10 上工作。到目前为止,我还没有弄清楚如何使命令docker build -t aws/codebuild/standard:3.0 .起作用。

我已经尝试了几件事:

  1. 在 Git Bash 中:net stop docker
  2. 在管理员模式下打开 PowerShell,通过cd "C:\Program Files\Docker\Docker" && ./DockerCli.exe -SwitchDaemon重新启动 Docker Daemon
  3. dockerdWSL2 上的管理员权限开始 - shell
  4. 在 Windows 10 上手动启动“Docker Desktop”,直到它显示“Docker Service not running”(单击“start”,“net”窗口立即打开和关闭,没有任何反应): docker_service_not_running

有关与选项 1相关的 CLI 输出的更多细节:

user@hd1pcms0347 MINGW64 ~/Projects/aws-codebuild-docker-images/ubuntu/standard/3.0 (master)
$ net stop docker
The service name is invalid.

More help is available by typing NET HELPMSG 2185.


user@hd1pcms0347 MINGW64 ~/Projects/aws-codebuild-docker-images/ubuntu/standard/3.0 (master)
$ net stop com.docker.service
The Docker Desktop Service service is not started.

More help is available by typing NET HELPMSG 3521.


user@hd1pcms0347 MINGW64 ~/Projects/aws-codebuild-docker-images/ubuntu/standard/3.0 (master)
$ net start docker
The service name is invalid.

More help is available by typing NET HELPMSG 2185.


user@hd1pcms0347 MINGW64 ~/Projects/aws-codebuild-docker-images/ubuntu/standard/3.0 (master)
$ net start com.docker.service
System error 5 has occurred.

Access is denied.


user@hd1pcms0347 MINGW64 ~/Projects/aws-codebuild-docker-images/ubuntu/standard/3.0 (master)
$ sudo net start com.docker.service
System error 1058 has occurred.

The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.

关于 WSL2-shell 输出的更多细节dockerd选项 3):

user@hd1pcms0347:/mnt/c/Users/username/Projects/aws-codebuild-docker-images/ubuntu/standard/3.0$ docker build -t aws/codebuild/standard:3.0 .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

user@hd1pcms0347:/mnt/c/Users/username/Projects/aws-codebuild-docker-images/ubuntu/standard/3.0$ sudo dockerd
[sudo] password for user: 
INFO[2021-06-30T15:04:18.569848200+02:00] Starting up
INFO[2021-06-30T15:04:18.596368100+02:00] libcontainerd: started new containerd process  pid=3612
INFO[2021-06-30T15:04:18.596759700+02:00] parsed scheme: "unix"                         module=grpc
INFO[2021-06-30T15:04:18.597062800+02:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2021-06-30T15:04:18.597402000+02:00] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock  <nil> 0 <nil>}] <nil> <nil>}  module=grpc
INFO[2021-06-30T15:04:18.597708900+02:00] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2021-06-30T15:04:18.642947300+02:00] starting containerd                           revision= version="1.4.4-0ubuntu1~20.04.2"
INFO[2021-06-30T15:04:18.670987400+02:00] loading plugin "io.containerd.content.v1.content"...  type=io.containerd.content.v1
INFO[2021-06-30T15:04:18.673888800+02:00] loading plugin "io.containerd.snapshotter.v1.aufs"...  type=io.containerd.snapshotter.v1
INFO[2021-06-30T15:04:18.750046200+02:00] skip loading plugin "io.containerd.snapshotter.v1.aufs"...  error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: FATAL: Module aufs not found in directory /lib/modules/4.4.0-19041-Microsoft\\n\"): skip plugin" type=io.containerd.snapshotter.v1
INFO[2021-06-30T15:04:18.750651600+02:00] loading plugin "io.containerd.snapshotter.v1.btrfs"...  type=io.containerd.snapshotter.v1
INFO[2021-06-30T15:04:18.751899400+02:00] skip loading plugin "io.containerd.snapshotter.v1.btrfs"...  error="path /var/lib/docker/containerd/daemon/io.containerd.snapshotter.v1.btrfs (wslfs) must be a btrfs filesystem to be used with the btrfs snapshotter: skip plugin" type=io.containerd.snapshotter.v1
INFO[2021-06-30T15:04:18.752328200+02:00] loading plugin "io.containerd.snapshotter.v1.devmapper"...  type=io.containerd.snapshotter.v1
WARN[2021-06-30T15:04:18.752652800+02:00] failed to load plugin io.containerd.snapshotter.v1.devmapper  error="devmapper not configured"
INFO[2021-06-30T15:04:18.752973800+02:00] loading plugin "io.containerd.snapshotter.v1.native"...  type=io.containerd.snapshotter.v1
INFO[2021-06-30T15:04:18.754531700+02:00] loading plugin "io.containerd.snapshotter.v1.overlayfs"...  type=io.containerd.snapshotter.v1
INFO[2021-06-30T15:04:18.759859700+02:00] loading plugin "io.containerd.snapshotter.v1.zfs"...  type=io.containerd.snapshotter.v1
INFO[2021-06-30T15:04:18.760367200+02:00] skip loading plugin "io.containerd.snapshotter.v1.zfs"...  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" type=io.containerd.snapshotter.v1
INFO[2021-06-30T15:04:18.760925000+02:00] loading plugin "io.containerd.metadata.v1.bolt"...  type=io.containerd.metadata.v1
WARN[2021-06-30T15:04:18.762074700+02:00] could not use snapshotter devmapper in metadata plugin  error="devmapper not configured"
INFO[2021-06-30T15:04:18.762472300+02:00] metadata content store policy set             policy=shared
INFO[2021-06-30T15:04:18.769383900+02:00] loading plugin "io.containerd.differ.v1.walking"...  type=io.containerd.differ.v1
INFO[2021-06-30T15:04:18.769855000+02:00] loading plugin "io.containerd.gc.v1.scheduler"...  type=io.containerd.gc.v1
INFO[2021-06-30T15:04:18.770209900+02:00] loading plugin "io.containerd.service.v1.introspection-service"...  type=io.containerd.service.v1
INFO[2021-06-30T15:04:18.770586300+02:00] loading plugin "io.containerd.service.v1.containers-service"...  type=io.containerd.service.v1
INFO[2021-06-30T15:04:18.771021300+02:00] loading plugin "io.containerd.service.v1.content-service"...  type=io.containerd.service.v1
INFO[2021-06-30T15:04:18.771445400+02:00] loading plugin "io.containerd.service.v1.diff-service"...  type=io.containerd.service.v1
INFO[2021-06-30T15:04:18.772519100+02:00] loading plugin "io.containerd.service.v1.images-service"...  type=io.containerd.service.v1
INFO[2021-06-30T15:04:18.773311600+02:00] loading plugin "io.containerd.service.v1.leases-service"...  type=io.containerd.service.v1
INFO[2021-06-30T15:04:18.773761100+02:00] loading plugin "io.containerd.service.v1.namespaces-service"...  type=io.containerd.service.v1
INFO[2021-06-30T15:04:18.774170300+02:00] loading plugin "io.containerd.service.v1.snapshots-service"...  type=io.containerd.service.v1
INFO[2021-06-30T15:04:18.774548800+02:00] loading plugin "io.containerd.runtime.v1.linux"...  type=io.containerd.runtime.v1
INFO[2021-06-30T15:04:18.776950300+02:00] loading plugin "io.containerd.runtime.v2.task"...  type=io.containerd.runtime.v2
INFO[2021-06-30T15:04:18.780732500+02:00] loading plugin "io.containerd.monitor.v1.cgroups"...  type=io.containerd.monitor.v1
INFO[2021-06-30T15:04:18.782998700+02:00] loading plugin "io.containerd.service.v1.tasks-service"...  type=io.containerd.service.v1
INFO[2021-06-30T15:04:18.783405000+02:00] loading plugin "io.containerd.internal.v1.restart"...  type=io.containerd.internal.v1
INFO[2021-06-30T15:04:18.783818900+02:00] loading plugin "io.containerd.grpc.v1.containers"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.784270200+02:00] loading plugin "io.containerd.grpc.v1.content"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.784640600+02:00] loading plugin "io.containerd.grpc.v1.diff"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.784918600+02:00] loading plugin "io.containerd.grpc.v1.events"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.785216200+02:00] loading plugin "io.containerd.grpc.v1.healthcheck"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.785516200+02:00] loading plugin "io.containerd.grpc.v1.images"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.785764200+02:00] loading plugin "io.containerd.grpc.v1.leases"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.786065700+02:00] loading plugin "io.containerd.grpc.v1.namespaces"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.786339300+02:00] loading plugin "io.containerd.internal.v1.opt"...  type=io.containerd.internal.v1
INFO[2021-06-30T15:04:18.790367300+02:00] loading plugin "io.containerd.grpc.v1.snapshots"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.790831300+02:00] loading plugin "io.containerd.grpc.v1.tasks"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.791225900+02:00] loading plugin "io.containerd.grpc.v1.version"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.791812700+02:00] loading plugin "io.containerd.grpc.v1.introspection"...  type=io.containerd.grpc.v1
INFO[2021-06-30T15:04:18.794298100+02:00] serving...                                    address=/var/run/docker/containerd/containerd-debug.sock
INFO[2021-06-30T15:04:18.796248300+02:00] serving...                                    address=/var/run/docker/containerd/containerd.sock.ttrpc
INFO[2021-06-30T15:04:18.797459100+02:00] serving...                                    address=/var/run/docker/containerd/containerd.sock
INFO[2021-06-30T15:04:18.797772600+02:00] containerd successfully booted in 0.160923s
INFO[2021-06-30T15:04:18.826449900+02:00] parsed scheme: "unix"                         module=grpc
INFO[2021-06-30T15:04:18.828408900+02:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2021-06-30T15:04:18.829324300+02:00] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock  <nil> 0 <nil>}] <nil> <nil>}  module=grpc
INFO[2021-06-30T15:04:18.829885000+02:00] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2021-06-30T15:04:18.835378400+02:00] parsed scheme: "unix"                         module=grpc
INFO[2021-06-30T15:04:18.835778100+02:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2021-06-30T15:04:18.836458600+02:00] ccResolverWrapper: sending update to cc: {[{unix:///var/run/docker/containerd/containerd.sock  <nil> 0 <nil>}] <nil> <nil>}  module=grpc
INFO[2021-06-30T15:04:18.836858700+02:00] ClientConn switching balancer to "pick_first"  module=grpc
WARN[2021-06-30T15:04:18.914129500+02:00] Your kernel does not support cgroup memory limit 
WARN[2021-06-30T15:04:18.914502600+02:00] Unable to find cpu cgroup in mounts
WARN[2021-06-30T15:04:18.914702600+02:00] Unable to find blkio cgroup in mounts
WARN[2021-06-30T15:04:18.914969800+02:00] Unable to find cpuset cgroup in mounts
WARN[2021-06-30T15:04:18.915207100+02:00] Unable to find pids cgroup in mounts
INFO[2021-06-30T15:04:18.915689900+02:00] Loading containers: start.
WARN[2021-06-30T15:04:18.959628600+02:00] Running iptables --wait -t nat -L -n failed with message: `iptables v1.8.4 (legacy): 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[2021-06-30T15:04:19.159782300+02:00] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
INFO[2021-06-30T15:04:19.161237700+02:00] stopping healthcheck following graceful shutdown  module=libcontainerd
INFO[2021-06-30T15:04:19.161256700+02:00] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
WARN[2021-06-30T15:04:20.171320700+02:00] grpc: addrConn.createTransport failed to connect to {unix:///var/run/docker/containerd/containerd.sock  <nil> 0 <nil>}. Err :connection error: desc 
= "transport: Error while dialing dial unix:///var/run/docker/containerd/containerd.sock: timeout". Reconnecting...  module=grpc
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.8.4 (legacy): 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)

user@hd1pcms0347:/mnt/c/Users/username/Projects/aws-codebuild-docker-images/ubuntu/standard/3.0$ docker build -t aws/codebuild/standard:3.0 .
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.24/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=aws%2Fcodebuild%2Fstandard%3A3.0&target=&ulimits=null&version=1: dial unix /var/run/docker.sock: connect: permission denied

user@hd1pcms0347:/mnt/c/Users/username/Projects/aws-codebuild-docker-images/ubuntu/standard/3.0$ sudo docker build -t aws/codebuild/standard:3.0 .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

2021 年 1 月 7 日编辑:

通过简单地重新安装它,我已经设法让 docker 再次工作。但是,我很高兴知道上述行为是否有任何具体原因。

标签: dockerbuilddocker-desktopdocker-daemondocker-cli

解决方案


推荐阅读