我在这里有一个dockerfile:
cp: error reading '/content/drive/My Drive/np_data.zip': Operation canceled
输出为
FROM golang:1.13-alpine as build
ARG DIR=somevalue
RUN echo $DIR
当我尝试将DIR替换为另一个名称示例DIR1时,DIR始终为空。 Docker版本在这里
Sending build context to Docker daemon 57.37MB
Step 1/3 : FROM golang:1.13-alpine as build
---> 2e384b27f926
Step 2/3 : ARG DIR=somevalue
---> Running in 3cd3457a795f
Removing intermediate container 3cd3457a795f
---> ecfa2f50c4fa
Step 3/3 : RUN echo $DIR
---> Running in aab4e31e0e14
Removing intermediate container aab4e31e0e14
---> 5351cb77c245
Successfully built 5351cb77c245
但是,当我尝试另一台机器时,它是正确的,它将回显一些值。谁能给我一些提示,以查找有关错误机器的问题?谢谢。
答案 0 :(得分:0)
您可以通过传递--no-cache
选项来尝试运行吗,它对我来说工作正常
❯❯❯ docker build . --no-cache
Sending build context to Docker daemon 194.7MB
Step 1/3 : FROM golang:1.13-alpine as build
---> 2e384b27f926
Step 2/3 : ARG DIR=somevalue
---> Running in c53bbb64dda1
Removing intermediate container c53bbb64dda1
---> b76b21aca433
Step 3/3 : RUN echo $DIR
---> Running in 6c49d289e258
somevalue
Removing intermediate container 6c49d289e258
---> d51e5579f1cb
Successfully built d51e5579f1cb
但是,如果它曾经构建过一次相同的图像,则由于已缓存了该图层,因此不会输出任何内容:
❯❯❯ docker build .
Sending build context to Docker daemon 194.7MB
Step 1/3 : FROM golang:1.13-alpine as build
---> 2e384b27f926
Step 2/3 : ARG DIR=somevalue
---> Using cache
---> b76b21aca433
Step 3/3 : RUN echo $DIR
---> Using cache
---> d51e5579f1cb
Successfully built d51e5579f1cb