[英]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.