错误示例(ARG为空)
ARG VERSION=latest
FROM busybox:$VERSION
RUN echo $VERSION
正确示例(ARG输出latest)
在FROM 之后RUN 前要重新什么前面FROM前的ARG
ARG VERSION=latest
FROM busybox:$VERSION
ARG VERSION
RUN echo $VERSION
docker 官网说明:
An ARG declared before a FROM is outside of a build stage, so it can’t be used in any instruction after a FROM. To use the default value of an ARG declared before the first FROM use an ARG instruction without a value inside of a build stage:
https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact