java - docker OCI 运行时创建失败
问题描述
我在 java web 应用程序项目中使用以下 docker-compose 文件。
version: "3"
services:
product:
image: jboss/wildfly
ports:
- 8080:8080
volumes:
- Product/target/Product.war:/opt/jboss/wildfly/standalone/deployments
我得到的错误是
ERROR: Named volume "Product/target/Product.war:/opt/jboss/wildfly/standalone/deployments:rw" is used in service "product" but no declaration was found in the volumes section.
Failed to deploy 'Compose: docker-compose.yml': `docker-compose` process finished with exit code 1
编辑 OCI 运行时创建失败:
在修复路径之后,我遇到了另一个错误。OCI 运行时创建失败:
Deploying 'Compose: docker-compose.yml'...
/usr/local/bin/docker-compose -f /Users/username/Desktop/Project/docker-compose.yml up -d
Starting project_product ...
Starting project_product ... error
ERROR: for project_product Cannot start service product: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/username/Desktop/Project/User/target/Product.war\\\" to rootfs \\\"/var/lib/docker/overlay2/e090197e0697ec14446020cf2444dc0d3f39dfb240de9f399017415f6faeb13b/merged\\\" at \\\"/var/lib/docker/overlay2/e090197e0697ec14446020cf2444dc0d3f39dfb240de9f399017415f6faeb13b/merged/opt/jboss/wildfly/standalone/deployments\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for product Cannot start service product: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/username/Desktop/Project/User/target/Product.war\\\" to rootfs \\\"/var/lib/docker/overlay2/e090197e0697ec14446020cf2444dc0d3f39dfb240de9f399017415f6faeb13b/merged\\\" at \\\"/var/lib/docker/overlay2/e090197e0697ec14446020cf2444dc0d3f39dfb240de9f399017415f6faeb13b/merged/opt/jboss/wildfly/standalone/deployments\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
Failed to deploy 'Compose: docker-compose.yml': `docker-compose` process finished with exit code 1
解决方案
将本地文件挂载到容器中时,必须.
在开头添加或使用绝对路径。否则 Docker 将假定它是一个命名卷,如错误所示。
推荐阅读
- python - 我如何在此代码中收到语法错误?
- c# - 从异步方法进行服务调用时,线程被中止错误
- wpf - WPF/MVVM 应用程序中的 RDLC 报告。如何显示外部图像
- python - Confluent Kafka:流式传输网络摄像头提要时 Kafka Consumer 滞后
- algorithm - 优先区间调度算法
- java - Android 谷歌地图在生产中显示白屏
- sql - 选择和内连接中的 DB2 SQL If 语句
- javascript - 将双维数组传递给控制器
- python - 选择要从 excel 读取到 pandas 数据框的行号
- prometheus - 如何在内置 Prometheus 表达式浏览器中显示多个向量