java - Docker docker-compose 无法访问 Dockerfile 中指定的 jarfile
问题描述
当我运行命令时一切都很好
docker build -f Dockerfile -t my_app_name .
docker run -t my_app_name
但是,如果我尝试使用docker-compose up
我收到错误 app_1 | Error: Unable to access jarfile /D-1.jar
我有一个文件结构为的项目
DockerPlayground
|_build
|_libs
|_D-1.jar
|_src
|_main
|_java
|_com.DockerPlayground
My Code Here
docker-compose.yml
Dockerfile
我的 Dockerfile
FROM openjdk:11-jre-slim
COPY build/libs/*.jar D-1.jar
ENTRYPOINT ["java","-jar","/D-1.jar"]
我的 docker-compose.yml
version: '3'
services:
app:
build:
context: ""
dockerfile: Dockerfile
ports:
- "8080:8080" # Forward the exposed port 8080 on the container to port 8080 on the host machine
restart: always
解决方案
推荐阅读
- javascript - 弧线笔划线弹出后的画布
- css - 覆盖 CSS 规则类:悬停以使用类中的原始规则值
- pandasql - 当我添加分析函数时,Pandasql 不起作用
- docker - 损坏的 DAG:[/usr/local/airflow/dags/test.py] 没有名为“boto3”的模块。如何将 pip 安装到气流容器中?
- puppet - 如何在木偶清单中懒惰地定义一个类
- c++ - 尝试释放内存时 gSOAP 多线程服务器崩溃
- codeigniter - Codeigniter 从数据库数组中一张一张地分页图像
- azure - 通过 Azure Pipeline 从 GitHub 将 python 脚本部署到虚拟机
- javascript - 如何根据Vue中的条件正确禁用按钮
- qt - 如何在 QML 中使用 MenuBar.insertMenu 方法?