简体   繁体   English

Dockerfile 脚本在本机 Ubuntu 中工作,但在 Windows 或 WSL 中不工作

[英]Dockerfile script working in native Ubuntu but not in Windows or WSL

In my Dockerfile I have the next RUN script:在我的 Dockerfile 中,我有下一个 RUN 脚本:

RUN set -ex; \
  echo "Downloading plugins"; \
  cd /tmp/plugins; \
  for f in `cat plugins.list`; do\
    curl -O -fSL $f; \
  done;

When I build the image from native Ubuntu it works flawlessly, but when I do it from Powershell or Ubuntu in Windows Subsystem for Linux it always gives me the same error: When I build the image from native Ubuntu it works flawlessly, but when I do it from Powershell or Ubuntu in Windows Subsystem for Linux it always gives me the same error:

 ---> Running in 095faf998ee4
 + echo 'Downloading plugins'
 + cd /tmp/plugins
 Downloading plugins                                                                                             
 + cat plugins.list
 ' curl -O -fS 'https://downloads.wordpress.org/plugin/ninja-forms.3.4.19.zip
 curl: (3) URL using bad/illegal format or missing URL    

If I run the curl command directly from bash it works flawlessly too, but if I run that part of the script it fails too.如果我直接从 bash 运行 curl 命令,它也可以完美运行,但是如果我运行脚本的那一部分,它也会失败。

As @cbley commented, the issue was in the EOL character, since on default sublime text on windows has EOL like windows, it was giving errors to the script.正如@cbley 评论的那样,问题出在 EOL 字符中,因为 windows 上的默认崇高文本具有像 windows 这样的 EOL,它给脚本带来了错误。

Either replacing with tr -d '\r' < plugins.list > plugins.list_new as @cbley commented on my question or setting sublime text's default EOL as "Unix" by adding "default_line_ending": "unix", to the sublime preferences did the trick.要么用tr -d '\r' < plugins.list > plugins.list_new替换 @cbley 评论我的问题,要么通过在 sublime 偏好中添加"default_line_ending": "unix",将 sublime text 的默认 EOL 设置为 "Unix"诀窍。

Thanks @cbley!谢谢@cbley!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Docker Windows WSL Ubuntu连接到VMware Ubuntu - Connecting Docker Windows WSL Ubuntu to VMware Ubuntu 在Linux(Ubuntu pwsh)上运行的PowerShell脚本,但在Windows上不运行 - PowerShell script working on Linux (Ubuntu pwsh) but not on Windows 在 Windows 上的特定或当前文件夹中启动 WSL Ubuntu - Start WSL Ubuntu in specific or current folder on Windows 在 Windows 11 (Ubuntu WSL) 上安装 Anbox - Install Anbox on Windows 11 (Ubuntu WSL) 如何在 WSL Ubuntu 中激活 Windows conda 环境? - How to activate Windows conda environment in WSL Ubuntu? 使用 Windows WSL 安装 Poetry 不起作用,忽略 $HOME - Poetry installation with Windows WSL not working, ignoring $HOME Conda 命令在适用于 Linux 的 Windows 子系统 (WSL) 中不起作用 - Conda commands not working in Windows Subsystem for Linux (WSL) AutoHotKey Hotstring 不会在 Windows 上的 gvim 或 WSL Ubuntu 中的 vim 中触发 - AutoHotKey Hotstring Won't Trigger in gvim on Windows or vim in WSL Ubuntu "如何在 Windows 10 Ubuntu bash (WSL) 上使用 difftool 和 mergetool" - How to use difftool and mergetool on Windows 10 Ubuntu bash (WSL) 是否可以使用 IntelliJ + PHP + Xdebug + WSL(Windows 上的 Ubuntu)? - Is it possible to use IntelliJ + PHP + Xdebug + WSL (Ubuntu on Windows)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM