debugdockerMinor
Error with declaring volumes in Docker-compose, 'no such file or directory, open '/app/package.json'
Viewed 0 times
suchdirectoryerrorfilevolumespackageappwithdockeropen
Problem
I am a very beginner in the Docker world, while I am trying to experiment with Docker file and Docker-Compose I am facing the below error, I now am able to understand it is related to declaring volumes in Docker compose, if I remove volumes, everything works fine, may be it is trying to refer back to the package.json file in my local drive and somehow container is not finding the package.json inside the container, yet to figure out how to solve this.
Here is the output from docker-compose:
Dockerfile.dev
Docker file contents are below
```
version: '3'
services:
web:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "3000
enoent ENOENT: no such file or directory, open '/app/package.json'Here is the output from docker-compose:
Starting frontend_web_1 ... done
Starting frontend_test_1 ... done
Attaching to frontend_test_1, frontend_web_1
web_1 | npm ERR! path /app/package.json
web_1 | npm ERR! code ENOENT
web_1 | npm ERR! errno -2
web_1 | npm ERR! syscall open
web_1 | npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
web_1 | npm ERR! enoent This is related to npm not being able to find a file.
web_1 | npm ERR! enoent
test_1 | npm ERR! path /app/package.json
test_1 | npm ERR! code ENOENT
test_1 | npm ERR! errno -2
web_1 |
test_1 | npm ERR! syscall open
web_1 | npm ERR! A complete log of this run can be found in:
web_1 | npm ERR! /root/.npm/_logs/2019-04-22T04_10_39_226Z-debug.log
test_1 | npm ERR! enoent ENOENT: no such file or directory, open '/app/package.json'
test_1 | npm ERR! enoent This is related to npm not being able to find a file.
test_1 | npm ERR! enoent
test_1 |
test_1 | npm ERR! A complete log of this run can be found in:
test_1 | npm ERR! /root/.npm/_logs/2019-04-22T04_10_39_236Z-debug.log
frontend_web_1 exited with code 254
frontend_test_1 exited with code 254Dockerfile.dev
FROM node:alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "run", "start"]Docker file contents are below
```
version: '3'
services:
web:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "3000
Solution
As mentioned in the post/question, it was an issue with volumes, my PC's firewall was blocking the Docker from accessing the drives in my local machine, I reset the credentials in 'Docker for Desktop' app in the shared drives section and everything was back working once again :). Thank you everyone, in fact BMitch was suggesting the same solution, but I was a completely beginner and I did not comprehend it well. Thanks everyone for your responses.
Context
StackExchange DevOps Q#6916, answer score: 1
Revisions (0)
No revisions yet.