Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 为什么Dockerfile中的单独运行无法生成,但链接运行成功生成?_Powershell_Docker_Dockerfile - Fatal编程技术网

Powershell 为什么Dockerfile中的单独运行无法生成,但链接运行成功生成?

Powershell 为什么Dockerfile中的单独运行无法生成,但链接运行成功生成?,powershell,docker,dockerfile,Powershell,Docker,Dockerfile,Dockerfile如下所示: FROM microsoft/windowsservercore COPY sources sources RUN powershell -Command Add-WindowsFeature NET-WCF-HTTP-Activation45 RUN powershell -Command Add-WindowsFeature Net-Framework-Core -Source C:\sources\sxs ENTRYPOINT powershell

Dockerfile如下所示:

FROM microsoft/windowsservercore

COPY sources sources

RUN powershell -Command Add-WindowsFeature NET-WCF-HTTP-Activation45
RUN powershell -Command Add-WindowsFeature Net-Framework-Core -Source C:\sources\sxs

ENTRYPOINT powershell
FROM microsoft/windowsservercore

COPY sources sources

RUN powershell -Command Add-WindowsFeature NET-WCF-HTTP-Activation45; \
                        Add-WindowsFeature Net-Framework-Core -Source C:\sources\sxs

ENTRYPOINT powershell
由于第二个AddWindowsFeature命令出现超时错误,使用上述Dockerfile生成映像始终失败

此操作返回,因为超时时间已过期。(0x5b4)

但是,如果我像这样编写Dockerfile,它将成功构建:

FROM microsoft/windowsservercore

COPY sources sources

RUN powershell -Command Add-WindowsFeature NET-WCF-HTTP-Activation45
RUN powershell -Command Add-WindowsFeature Net-Framework-Core -Source C:\sources\sxs

ENTRYPOINT powershell
FROM microsoft/windowsservercore

COPY sources sources

RUN powershell -Command Add-WindowsFeature NET-WCF-HTTP-Activation45; \
                        Add-WindowsFeature Net-Framework-Core -Source C:\sources\sxs

ENTRYPOINT powershell

我在文档中找不到任何信息,说明为什么在Dockerfile中为同一个命令(即
powershell-command Add WindowsFeature…
)分别运行两次是不可行的。

可能只是命令返回速度太快,没有这样的限制(无法为类似的事情运行两次命令)我的实际Dockerfile包含了其他运行命令,我注意到的模式是只有第一个运行命令构建成功。在我的问题中,我尝试在链接的AddWindowsFeature上面添加一个不同的RUN命令,第一个RUN命令成功生成。链接的添加窗口功能命令超时。知道为什么“命令返回得不太快”吗?好吧,这只是我的猜测。我无法测试它。最简单的测试方法-尝试另一台pc。尝试使用docker的虚拟机,尝试托管docker,等等。