nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream

一、问题

Deploying 'nacos Dockerfile: ruoyi-visual/ruoyi-nacos/Dockerfile'…
Building image…
Preparing build context archive…
[==================================================>]211/211 files
Done

Sending build context to Docker daemon…
[==================================================>] 6.099MB
Done

Step 1/8 : FROM openjdk:11
 ---> 5505a9a39df1
Step 2/8 : MAINTAINER Lion Li
 ---> Using cache
 ---> eca0c2bdad4a
Step 3/8 : RUN mkdir -p /ruoyi/nacos
 ---> Using cache
 ---> be0c071dd7d6
Step 4/8 : WORKDIR /ruoyi/nacos
 ---> Using cache
 ---> 408180929007
Step 5/8 : EXPOSE 8848
 ---> Using cache
 ---> 1595df8aa2ff
Step 6/8 : ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms256m -Xmx512m"
 ---> Using cache
 ---> 899b953e7851
Step 7/8 : ADD ./target/ruoyi-nacos.jar ./app.jar
Error response from daemon: ADD failed: file not found in build context or excluded by .dockerignore: stat target/ruoyi-nacos.jar: file does not exist
Failed to deploy 'nacos Dockerfile: ruoyi-visual/ruoyi-nacos/Dockerfile': Can't retrieve image ID from build stream


报错截图:
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第1张图片

二、解决

2.1 以管理员身份运行IDEA

nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第2张图片
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第3张图片

2.2 检查对应的Dockfile文件的配置

检查ruoyi-nacos.jar相关内容是否配置有误:
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第4张图片

2.3 maven操作

双击clean:
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第5张图片
双击package:
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第6张图片

nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第7张图片

nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第8张图片

nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第9张图片
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第10张图片
already in use by container:
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第11张图片
删除nacos containers改用docker compose 方式启动:
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第12张图片
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第13张图片
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第14张图片
nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第15张图片

nacos运行报错-jar: file does not exist&Can’t retrieve image ID from build stream 问题解决了。
这里又会报一个常见的错误: No DataSource set

nacos: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'memoryMonitor' defined in URL [jar:file:/ruoyi/nacos/app.jar!/BOOT-INF/lib/nacos-config-2.2.1.jar!/com/alibaba/nacos/config/server/monitor/MemoryMonitor.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'asyncNotifyService': Unsatisfied dependency expressed through field 'dumpService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalDumpService': Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :
nacos: No DataSource set

nacos运行报错-jar: file does not exist&Can‘t retrieve image ID from build stream_第16张图片

三、参考资料

IntelliJ IDEA使用docker插件打包镜像的两种方法
微服务模块部署到Docker

你可能感兴趣的:(jar,java,开发语言)