通过添加非破坏性的更改创建了Dockerfile。构建正在成功,但是当我们运行docker映像时出现以下错误。
FROM openjdk:11-jdk-slim AS build-env
RUN mkdir /app/examples
WORKDIR /app/examples
#Copy lib dir
ADD ./examples/target/dist/lib lib
ADD ./examples/target/test.jar lib/
ADD ./examples/config config
ADD ./examples/scripts scripts
FROM gcr.io/distroless/java:11-debug
COPY --from=build-env /app /app
WORKDIR /app
#Jetty port available outside this container
EXPOSE 20830
CMD ["java”,"-jar","dist/lib/test.jar"]
运行映像时出现错误错误:无法访问jarfile / bin / sh
docker run -d -p 8080:20830 <image-name:v1>
docker ps
显示为空列表,但当我检查docker logs <container_id>
时显示为Error: Unable to access jarfile /bin/sh
在没有distroless的docker运行成功的情况下。