首页 > 解决方案 > DockerCli.exe -SwitchDaemon 没有效果

问题描述

我正在尝试为 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 容器。

标签: dockerdocker-for-windows

解决方案


(部分)问题是我已经./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

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


推荐阅读