在Windows计算机上构建docker映像时chmod CommandNotFoundException

时间:2019-12-12 05:37:31

标签: windows docker dockerfile sh chmod

我们正在尝试在Python-flask机器上构建Windows 10映像,这是Dockerfile的一部分。

RUN chmod +x /var/www/projectname/entrypoint.local.sh

尝试使用docker文件构建映像时出现错误

这是错误:

chmod : The term 'chmod' 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:76
+ ... nce = 'Stop'; $ProgressPreference = 'SilentlyContinue'; chmod +x /var ...
+                                                             ~~~~~
    + CategoryInfo          : ObjectNotFound: (chmod:String) [], ParentContain     sErrorRecordException
    + FullyQualifiedErrorId : CommandNotFoundException   ERROR: Service 'controller_service' failed to build: The command 'powershell
-Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; chmod +x /var/www/projectname/entry point.local.sh' returned a non-zero code: 1

正在考虑在Dockerfile中将 chmod 作为Windows命令。

编辑1:

我正在尝试使用以下命令将图像构建为docker-compose的一部分:

docker-compose up --build

我正在TerminalPycharm的{​​{1}}中运行以上命令。

请提出解决此问题的建议。谢谢!

1 个答案:

答案 0 :(得分:0)

当您实际配置Linux来构建Docker desktop时,您似乎正在尝试构建Windows images图像。

这就是为什么您可能会得到错误chmod命令的原因,该命令特定于Linux,在Windows上不起作用。

您可以按照以下步骤解决。

  1. 转到任务栏中右下角的Docker桌面图标。
  2. 右键单击并单击Switch to Linux containers的选项。
  3. 尝试立即构建图像。

您应该很好。