首页 > 解决方案 > 无法在 Powershell 命令中创建 DockerFile

问题描述

我无法在 Powershell 中创建 DockerFile。我正在使用的命令是:

FROM mcr.microsoft.com/dotnet/aspnet:3.1

我得到的错误是:

The 'from' keyword is not supported in this version of the language.

这是它的屏幕截图。 在此处输入图像描述

您可以清楚地看到我正在从应用程序目录运行命令:“D:\Website\Project\Dockers\App”。

我正在关注官方的微软文档。链接在这里

我在运行中安装了 dockers 桌面。它在Linux 容器模式下运行。

怎么了,少了点什么?

标签: dockerpowershellasp.net-core

解决方案


PowerShell 不是 Docker,PowerShell 将无法解析或理解 docker 命令。

如果要从 PowerShell编写dockerfile,请像编写任何其他文本文件一样:

"FROM mcr.microsoft.com/dotnet/aspnet:3.1" |Add-Content .\Dockerfile

推荐阅读