我有一个Dockerfile和一个docker-compose.yml文件。一切正常,直到我将卷行添加到docker-compose文件中。当我添加卷时,出现以下错误。我在Windows 7上将docker toolbox与Oracle VM VirtualBox一起使用。
Dockerfile
FROM node:10.16.3
WORKDIR /usr/src/facerecognitionbrain-api
COPY ./ ./
RUN npm install
CMD ["/bin/bash"]
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
错误
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
答案 0 :(得分:1)
我认为您应该只对WORKDIR的一个子目录/目录,而不是完整的/ usr / src / facerecognitionbrain-api。
此处创建了卷,然后npm尝试读取package.json,但是docker在您的卷中查找了空文件。