[英]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.