date 工作:
PS> date
Saturday, June 10, 2017 9:10:11 AM
Run Code Online (Sandbox Code Playgroud)
但Get-Command date抛出异常:
PS> Get-Command date
Get-Command : The term 'date' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-Command date
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (date:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Run Code Online (Sandbox Code Playgroud)
也Get-Alias date …
我想在我的 dockerfile 中传递一个参数来构建我的 docker 镜像。我在其他帖子和 docker 手册中看到过如何执行此操作,但在我的情况下不起作用。这是我使用参数的代码摘录:
ARG FirefoxVersion
RUN powershell -Command iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'));
RUN choco install -y firefox --version $FirefoxVersion --ignore-checksums
Run Code Online (Sandbox Code Playgroud)
我在 powershellPrompt 中使用此命令构建我的图像:
docker build -t myimage --build-arg FirefoxVersion=61.0.1 .
Run Code Online (Sandbox Code Playgroud)
最后我有这个错误:
'$FirefoxVersion' is not a valid version string.
Parameter name: version
The command 'cmd /S /C choco install -y firefox --version $FirefoxVersion -- ignore-checksums' returned a non-zero code: 1
Run Code Online (Sandbox Code Playgroud)
有人知道我的代码有什么问题吗?谢谢。