如何将Docker映像名称设置为其在构建时创建的文件名称
因此,我想将Docker Image名称设置为其创建的文件。 Dockerfile内部的阶段是:为pom.xml,compile,package设置新版本 所有使用MVN。 我想将Docker映像名称设置为构建创建的工件 示例:my-app-1.0.1
FROM maven:3-jdk-8-alpine AS build
ADD . /my-app
WORKDIR /my-app
RUN mvn versions:set -DnewVersion="1.0.1"
RUN mvn compile
RUN mvn package
FROM openjdk:8-jdk-alpine
COPY --from=build /my-app/target/my-app-1.0.1.jar my-app-1.0.1.jar
ENTRYPOINT ["java" "-cp" "my-app-1.0.1.jar" "com.mycompany.app.App"]
谢谢!
So i want to set the docker image name as a file it creates.
the stages inside the dockerfile are: set new version for pom.xml, compile, package
all using mvn.
i want to set the docker image name as the artifact the build creates
Example: my-app-1.0.1
FROM maven:3-jdk-8-alpine AS build
ADD . /my-app
WORKDIR /my-app
RUN mvn versions:set -DnewVersion="1.0.1"
RUN mvn compile
RUN mvn package
FROM openjdk:8-jdk-alpine
COPY --from=build /my-app/target/my-app-1.0.1.jar my-app-1.0.1.jar
ENTRYPOINT ["java" "-cp" "my-app-1.0.1.jar" "com.mycompany.app.App"]
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看
docker build
用法look at
docker build
usage因此,正如ThorbjørnRavn一样,安德森(Andersen)和马克斯(Max)建议我改变了方法。
我将其设置在外面,然后用image Build命令将其正确放置。
感谢大家的帮助!
命令帮助
So as Thorbjørn Ravn, Andersen and Max advised I changed my approach.
i set it outside and put it right with the image build command.
Thanks for the help everyone!
command help