当遵循 tutorial 时对于 Docker 和 .NET Core,使用适用于 Linux 容器的 Docker 构建并运行示例运行良好,但使用适用于 Windows 容器的 Docker 构建并运行示例失败并出现奇怪的错误。
cd aspnetapp
docker build -t aspnetapp .
docker run -it --rm --name aspnetcore_sample aspnetapp
然后在第二个cmd/PS中
docker ps
docker exec aspnetcore_sample ipconfig
OCI runtime exec failed: exec failed: container_linux.go:295: starting container process caused "exec: \"ipconfig\": executable file not found in $PATH": unknown
搜索结果为空。
最佳答案
在尝试使用 Visual Studio 2017 的 docker 项目并使用 add docker support that VS17 has built in 后,解决方案变得显而易见。 .
将 docker 支持添加到新的 .NET Core MVC 项目后进行构建:
Done building project "docker-compose.dcproj" -- FAILED.
Volume sharing is not enabled. Enable volume sharing in the Docker CE for Windows Settings.
右键docker任务栏图标-设置,共享驱动器(选择里面有代码的驱动器)
再次运行。
Your Docker server host is configured for 'Linux', however the docker-compose project targets 'Windows'. docker-compose C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets 165
必须右键单击 docker 任务栏“切换到 Windows 容器”,需要安装或更新,并在重新启动后再次选择它。已修复。
关于Docker 执行 : ipconfig failing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47480782/