docker - 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 容器。
解决方案
(部分)问题是我已经./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
导致两个正在运行的容器都响应请求。
推荐阅读
- ruby - bundler 安装了特定版本后,为什么 bundler 的版本没有改变?
- c# - 当 Windows 服务停止时,使用块中的 StreamWriter.WriteAsync 无法写入整个文件
- html - 不应该使用 50% 父宽度环绕的 Flex div
- linux - 在 Linux 中将 STDERR 重定向到来自 Perl 的文件
- laravel - 获取关系集合 groupBy 列且不为空
- php - 我的登录屏幕不工作,黑屏
- ruby-on-rails - Rails 路由约束问题/错误或功能?
- java - spring Kafka集成测试监听器不起作用
- ruby-on-rails - 如何使用 Rails+Nginx+Postgresql+DigitalOcean 访问远程数据库?
- .net - 如何在 Powershell 中将 dotnet 框架从核心更改为 .NET 框架