在我的Dockerfile中,我有以下内容:
ARG a-version
RUN wget -q -O /tmp/alle.tar.gz http://someserver/server/$a-version/a-server-$a-version.tar.gz && \
mkdir /opt/apps/$a-version
但是在构建时:
--build-arg http_proxy=http://myproxy","--build-arg a-version=a","--build-arg b-version=b"
步骤10/15:RUN wget …在路径中显示$a-version而不是替换值,构建失败.
My questions is,what could be causing this issue and how can i solve
it?
最佳答案
不要在变量名中使用 – .
原文链接:https://www.f2er.com/docker/436258.htmlDocker构建将始终显示Dockerfile中记录的行,尽管变量值.
所以使用这个变量名a_version:
ARG a_version
看这个例子:
Dockerfile:
FROM alpine
ARG a_version
RUN echo $a_version
建立:
$docker build . --build-arg a_version=1234
Sending build context to Docker daemon 2.048 kB
Step 1/3 : FROM alpine
---> a41a7446062d
Step 2/3 : ARG a_version
---> Running in c55e98cab494
---> 53dedab7de75
Removing intermediate container c55e98cab494
Step 3/3 : RUN echo $a_version <<< note this <<
---> Running in 56b8aeddf77b
1234 <<<< and this <<
---> 89badadc1ccf
Removing intermediate container 56b8aeddf77b
Successfully built 89badadc1ccf