我正在尝试在docker gradle中构建jar文件,然后docker openjdk复制jar文件并运行它。
但遇到错误
Step 10/14 : COPY --from=builder /test-command/build/libs/*.jar /app/test-command.jar
ERROR: Service 'test-command' failed to build: COPY failed: no source files were specified
docker文件
FROM gradle:5.6.3-jdk8 as builder
COPY --chown=gradle:gradle . /test-command
ADD --chown=gradle . /app
WORKDIR /app
RUN gradle build
FROM ubuntu
FROM openjdk:8-alpine
WORKDIR /app
VOLUME ["/app"]
COPY --from=builder /test-command/build/libs/*.jar /app/test-command.jar
COPY --from=builder /test-command/docker/startup.sh /app/startup.sh
#RUN sh -c 'touch /app/test-command.jar'
RUN chmod +x /app/startup.sh
RUN chmod +x /app/test-command.jar
ENTRYPOINT ["/bin/sh", "/app/startup.sh"]
当docker gradle构建文件时,我可以使用以下docker命令查看它们,并且我看到了路径,即容器中的jar文件。
但是一旦构建完成,那么我就不再看到该容器了。
这可能是docker oepnjdk找不到文件/源路径的原因吗?
docker exec -it name-of-container bash