I have a Dockerfile and a docker-compose.yml file. Everything works fine until I add the volumes lines to the docker-compose file. When I do add the volumes I get the below error. I am using docker toolbox with Oracle VM VirtualBox on windows 7.
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
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.