我正在學習 Dockerfile,之前沒有使用過curl。
我試著去理解第 26 行這個 Dockerfile。
&& bash -c 'curl "https://nodejs.org/dist/$(<.node_version.txt)/node-$(<.node_version.txt)-linux-x64.tar.gz" > /home/meteorapp/meteorapp/build/required-node-linux-x64.tar.gz' \
是否$(<.node_version.txt)
意味著我必須想出一些文本作為它期望的值或按原樣使用,作為命令的一部分?
答案1
這意味著您需要有一個名為.node_version.txt
.該檔案中應該是您想要的節點的版本號。例如:v4.6.0
或latest
。若要查看有效的版本字串,請轉到https://nodejs.org/dist/
所發生的情況是該構造$(<.node_version.txt)
被文件的內容替換。
這條線
https://nodejs.org/dist/$(<.node_version.txt)/node-$(<.node_version.txt)-linux-x64.tar.gz
變成
https://nodejs.org/dist/v4.6.0/node-v4.6.0-linux-x64.tar.gz
該結構$(<filename)
是一個特殊的變體命令替換。它實際上相當於$(cat filename)
.