我有一个Dockerfile,它需要从命令行获取基本镜像标签并动态加载它,但是我在这个命令行中得到了这个错误。
$ docker build --network=host --build-arg sample_TAG=7.0 --rm=true .
Step 9/12 : FROM "${sample_TAG}"
base name ("${sample_TAG}") should not be blankDockerfile:
FROM maven:3.6.1-jdk-8 as maven-build
ARG sample_TAG
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
WORKDIR /apps/sample-google
COPY . /apps/sample-google
RUN mvn clean package
RUN echo "image tag is ${sample_TAG}"
FROM $sample_TAG
VOLUME /apps
RUN mkdir /apps/sample-google
COPY --from=maven-build /apps/sample-google/target /apps/sample-google回显行正确打印'latest‘字符串,但在'FROM $sample_TAG’行打印失败。
发布于 2019-09-13 10:44:18
为此,您需要定义全局参数,最好有一些默认值,并在构建时覆盖它。
ARG sample_TAG=test
FROM maven:3.6.1-jdk-8 as maven-build
ARG sample_TAG
WORKDIR /apps/sample-google
RUN echo "image tag is ${sample_TAG}"
FROM $sample_TAG
VOLUME /apps
RUN mkdir /apps/sample-googlehttps://stackoverflow.com/questions/57913617
复制相似问题