简体   繁体   English

docker-compose 与卷 - package.json 的“没有这样的文件或目录”

[英]docker-compose up with volumes - “no such file or directory” for package.json

I have a Dockerfile and a docker-compose.yml file.我有一个 Dockerfile 和一个 docker-compose.yml 文件。 Everything works fine until I add the volumes lines to the docker-compose file.在我将卷行添加到 docker-compose 文件之前,一切正常。 When I do add the volumes I get the below error.当我添加卷时,出现以下错误。 I am using docker toolbox with Oracle VM VirtualBox on windows 7.我在 windows 7 上使用 docker 工具箱和 Oracle VM VirtualBox。

Dockerfile Dockerfile

FROM node:10.16.3

WORKDIR /usr/src/facerecognitionbrain-api

COPY ./ ./

RUN npm install

CMD ["/bin/bash"]

docker-compose.yml docker-compose.yml

version: '3.7'

services:
 facerecognitionbrain-api:
  container_name: backend
  # image: node:10.16.3
  build: ./
  command: npm start
  working_dir: /usr/src/facerecognitionbrain-api
  ports:
  - "3008:3008"
  volumes:
  - ./:/usr/src/facerecognitionbrain-api

Error错误

backend                     | npm ERR! code ENOENT
backend                     | npm ERR! errno -2
backend                     | npm ERR! syscall open
backend                     | npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/facerecognitionbrain-api/package.json'
backend                     | npm ERR! enoent This is related to npm not being able to find a file.
backend                     | npm ERR! enoent
backend                     |
backend                     | npm ERR! A complete log of this run can be found in:
backend                     | npm ERR!     /root/.npm/_logs/2019-10-18T10_24_08_071Z-debug.log
backend exited with code 254

I think you should volume only a sub/directory of your WORKDIR, not the full /usr/src/facerecognitionbrain-api.我认为你应该只对你的 WORKDIR 的一个子/目录进行卷,而不是完整的 /usr/src/facerecognitionbrain-api。

Here the volume is created, and then npm tries to read package.json, but docker looks for the file in your volume, which is empty. Here the volume is created, and then npm tries to read package.json, but docker looks for the file in your volume, which is empty.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker-compose up:没有这样的文件或目录,打开'/usr/src/app/package.json' - Docker-compose up : no such file or directory, open '/usr/src/app/package.json' npm ENOENT:没有这样的文件或目录,打开“/usr/app/package.json”。 在尝试使用 docker-compose 与 docker 共享本地空间时 - npm ENOENT: no such file or directory, open '/usr/app/package.json'. While trying to share local space with docker using docker-compose 在 docker-compose 期间找不到模块 @angular-devkit/build-angular/package.json - Cannot find module @angular-devkit/build-angular/package.json during docker-compose up 找不到Docker卷和package.json - Docker volumes and package.json not found 使用 docker-compose 锁定 Docker 容器中的 package.json 文件 - Locked package.json files in Docker container using docker-compose 从 Dockerfile 移动到 docker-compose 时找不到 package.json - package.json not found when moving from Dockerfile to docker-compose docker-compose 对于节点项目获取找不到 package.json on windows - docker-compose for a node project getting cannot find package.json on windows 将 NODE_ENV 从 package.json 传递到 Docker-compose - Passing NODE_ENV from package.json to Docker-compose Elastic Beanstalk / Docker-没有这样的文件或目录package.json - Elastic Beanstalk / Docker - No such file or directory package.json Docker 错误:没有那个文件或目录,打开'/package.json' - Docker error: no such file or directory, open '/package.json'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM