【问题标题】:chmod CommandNotFoundException when building docker image on windows machine在 Windows 机器上构建 docker 映像时出现 chmod CommandNotFoundException
【发布时间】:2019-12-12 05:37:31
【问题描述】:

我们正在尝试在Windows 10 机器上构建Python-flask 映像,以下是 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.

我在TerminalPycharmWindows 中运行上述命令。

请提出任何解决此问题的方法。谢谢!

【问题讨论】:

    标签: windows docker dockerfile sh chmod


    【解决方案1】:

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

    这就是您可能会收到错误 chmod command not found 的原因,该错误特定于 Linux 并且不适用于 Windows

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

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

    你应该很高兴。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-23
      • 2018-01-13
      • 2019-03-25
      • 1970-01-01
      • 1970-01-01
      • 2020-07-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多