在我的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"
Step 10/15 : RUN wget...
被示为具有$a-version
在路径中而不是取代的值和生成失败。
我的问题是,什么可能导致此问题,我该如何解决?
不要-
在变量名中使用。
尽管值可变,但Docker构建始终会向您显示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
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句