DockerCli.exe -SwitchDaemon无效

时间:2019-08-12 18:53:15

标签: docker docker-for-windows

我正在尝试为Windows运行Docker,但似乎无法切换到Linux容器。

参考:https://stefanscherer.github.io/run-linux-and-windows-containers-on-windows-10/

步骤

启动守护程序

choco install -y docker-desktop
restart-computer
cd 'c:\program files\docker\docker\resources'
.\dockerd
time="..." level=info msg="Starting up"
time="..." level=info msg="Windows default isolation mode: process"
time="..." level=info msg="Restoring existing overlay networks from HNS into docker"
time="..." level=info msg="Loading containers: done."time="..." level=info msg="Docker daemon" commit=74b1e89 graphdriver(s)=windowsfilter version=19.03.1
time="..." level=info msg="Daemon has completed initialization"
time="..." level=info msg="API listen on //./pipe/docker_engine"

我看到它正在运行“ windowsfilter”(出乎意料,但可以)。所以我尝试启动一些容器

docker run --interactive --tty ubuntu bash
cd c:\program files\docker\docker
./DockerCli -SwitchDaemon
docker run --interactive --tty ubuntu bash
./DockerCli -SwitchLinuxEngine
docker run --interactive --tty ubuntu bash

所有这些都会导致出现消息...

Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: no matching manifest for windows/amd64 10.0.17763 in the manifest list entries.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'

出于记录,我可以运行Windows容器。

1 个答案:

答案 0 :(得分:0)

(部分)问题是我手动启动了./dockerd。我不应该这样做,但是混乱的根源是安装docker。

由于某种原因,实际的docker守护程序没有响应。通过启动管理提示并重新启动守护程序,可以解决此问题。

Start-Process "powershell" -verb RunAs
Restart-Service com.docker.service;
Restart-Service Docker;

现在,在非管理员提示下

& "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchLinuxEngine
docker run -p 80:80 -d nginx
& "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchWindowsEngine
docker run --rm -p 81:80 --name aspnetcore_sample mcr.microsoft.com/dotnet/core/samples:aspnetapp

导致两个正在运行的容器均响应请求。