繁体   English   中英

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

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

在我的 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:

 ---> 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    

如果我直接从 bash 运行 curl 命令,它也可以完美运行,但是如果我运行脚本的那一部分,它也会失败。

正如@cbley 评论的那样,问题出在 EOL 字符中,因为 windows 上的默认崇高文本具有像 windows 这样的 EOL,它给脚本带来了错误。

要么用tr -d '\r' < plugins.list > plugins.list_new替换 @cbley 评论我的问题,要么通过在 sublime 偏好中添加"default_line_ending": "unix",将 sublime text 的默认 EOL 设置为 "Unix"诀窍。

谢谢@cbley!

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM