docker - 没有这样的文件或目录 package.json
问题描述
我正在主机上使用已安装的卷当我运行时,docker-compose build && docker-compose up -d
我得到:
[4/5] RUN npm install:
#7 4.268 npm ERR! code ENOENT
#7 4.268 npm ERR! syscall open
#7 4.268 npm ERR! path /var/www/html/package.json
#7 4.269 npm ERR! errno -2
#7 4.271 npm ERR! enoent ENOENT: no such file or directory, open '/var/www/html/package.json'
#7 4.271 npm ERR! enoent This is related to npm not being able to find a file.
executor failed running [/bin/sh -c npm install]: exit code: 254
ERROR: Service 'node' failed to build : Build failed
这是docker-compose.yml
:
node:
build:
context: ./nodejs-project
dockerfile: Dockerfile
container_name: node
volumes:
- ./nodejs-project:/var/www/html
这是Dockerfile
:
FROM node:alpine
RUN mkdir -p /var/www/html
WORKDIR /var/www/html
EXPOSE 3000
RUN npm run build
CMD ["npm", "run", "dev"]
我相信这与我既从 the 安装卷又从 the 制作卷以及它以某种方式覆盖它的事实docker-compose.yml
有关。但我找不到解决方案WORKDIR
Dockerfile
解决方案
推荐阅读
- javascript - 给定一个对象数组,如何根据键合并数组中的对象?
- sql-server - 等待操作超时从 Azure 函数应用程序建立到 SQL Server 的连接
- visual-studio-code - 为什么应用程序在 VS Code 中寻找错误的存储库?
- javascript - 对象数组中的简单模式条件必需字段
- python-3.x - 在 Python 3 的循环中找到变化列表中最小数字的最快方法
- mongodb - 在 GraphQL 和 Apollo 中检索数组
- go - 在 void 函数中使用的结构上模拟复杂方法
- java - Web 服务能否从不同服务器上的 Web 服务获取自定义错误消息?
- azure - 如何在 Azure 中转储/加载 Neo4j 数据库?
- c++ - 如何在 C++ 中使用 std::bind 函数作为信号处理程序?