簡體   English   中英

在 Dockerfile 中多次使用相同的變量

[英]Use same variable multiple times in a Dockerfile

我試圖在以下 Dockerfile 中多次使用相同的變量( $MINERV

FROM debian:stable

ARG MINERV=5.5c

RUN export DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y curl
RUN mkdir /home/docker
RUN curl "https://github.com/PhoenixMinerDevTeam/PhoenixMiner/releases/download/$MINERV/PhoenixMiner_$MINERV_Linux.tar.gz" -L -o "/home/docker/PhoenixMiner_$MINERV_Linux.tar.gz"

WORKDIR /home/docker

CMD ["ls"]

output 用於docker build. -t test && docker run test docker build. -t test && docker run testPhoenixMiner_.tar.gz當我期待PhoenixMiner_5.5c_linux.tar.gz

我可以確認curl嘗試抓取https://github.com/PhoenixMinerDevTeam/PhoenixMiner/releases/download/5.5c/PhoenixMiner_$MINERV_Linux.tar.gz 我也嘗試過使用ENV而不是ARG來獲得相同的結果。

如何在 Dockerfile 中多次使用同一個變量?

謝謝!

我相信你必須把 $MINERV 這樣 -> ${MINERV} 放在你正在使用它的地方

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM