gpt4 book ai didi

java - 添加失败 : stat/var/lib/docker/tmp/docker-builderXYZ/myapp. jar: 没有这样的文件或目录

转载 作者:行者123 更新时间:2023-12-02 18:03:52 25 4
gpt4 key购买 nike

我把Dockerfile进入项目根目录。

意思是有一个 ./target目录和其中,maven 生成一个 spring-boot-web-0.0.1-SNAPSHOT.jar文件。

我现在想将其添加到 docker 镜像中:

FROM centos

RUN yum install -y java # `-y` defaults questions to 'yes'

VOLUME /tmp # where Spring Boot will store temporary files

WORKDIR / # self-explanatory

ADD /target/spring-boot-web-0.0.1-SNAPSHOT.jar myapp.jar # add fat jar as "myapp.jar"

RUN sh -c 'touch ./myapp.jar' # updates dates on the application (important for caching)

EXPOSE 8080 # provide a hook into the webapp

# run the application; the `urandom` gets tomcat to start faster
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/myapp.jar"]

ADD失败:
ADD failed: stat /var/lib/docker/tmp/docker-builder119635304/myapp.jar: no such file or directory

最佳答案

解决方案似乎是将注释移到它们自己的行中,因为如果它们与它们在同一行中,它们会破坏命令。

Dockerfile工作得很好:

# a linux runtime environment
FROM centos

# install java; `-y` defaults questions to 'yes'
RUN yum install -y java

# where Spring Boot will store temporary files
VOLUME /tmp

# self-explanatory
WORKDIR /

# add fat jar as "myapp.jar"
ADD /target/spring-boot-web-0.0.1-SNAPSHOT.jar myapp.jar

# updates dates on the application (important for caching)
RUN sh -c 'touch ./myapp.jar'

# provide a hook into the webapp
EXPOSE 8080

# run the application; the `urandom` gets tomcat to start faster
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/myapp.jar"]

关于java - 添加失败 : stat/var/lib/docker/tmp/docker-builderXYZ/myapp. jar: 没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55587360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com