Answers: <p>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.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-05-05T16:56:52.150Z
Answers: 2019-05-05T17:44:14.643Z
Answers: 2019-05-05T17:44:14.643Z
Answers: Jophin Michael
Body: <p>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.</p>
  
  <pre><code>enoent ENOENT: no such file or directory, open '/app/package.json'
  </code></pre>
  
  <p>Here is the output from docker-compose:</p>
  
  <pre><code>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 254
  </code></pre>
  
  <p>Dockerfile.dev</p>
  
  <pre><code>FROM node:alpine
  
  WORKDIR /app
  
  COPY package.json .
  
  RUN npm install
  
  COPY . .
  
  CMD ["npm", "run", "start"]
  </code></pre>
  
  <p>Docker file contents are below</p>
  
  <pre><code>version: '3'
  services:
    web: 
      build:
        context: .
        dockerfile: Dockerfile.dev
      ports:
        - "3000:3000"
      volumes:
        - /app/node_modules
        - .:/app
    test:
      build:
        context: .
        dockerfile: Dockerfile.dev
      volumes:
        - /app/node_modules
        - .:/app
      command: ["npm", "run", "test"]
  </code></pre>
  
  <p>My directory structure as as shown below,</p>
  
  <p><a href="https://i.sstatic.net/e7aZO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/e7aZO.png" alt="enter image description here"></a></p>
  
  <p>Executed the below statement and the corresponding response,</p>
  
  <pre><code>$ docker run -it --rm -v "$(pwd):/app" busybox ls -l /app
  
  the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'
  </code></pre>
  
  <p>Update: 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.</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-04-22T10:11:27.967Z
Comments: When you ask a question; please make everything in your power to make it look good. People will just ignore a question that is not properly formatted. https://devops.stackexchange.com/help/how-to-ask
Comments: Kyslik
Comments: CC BY-SA 4.0
Comments: 2019-04-22T13:47:32.840Z
Comments: Can you try using double quotes in source file name .
Comments: Sandeep Chhabra
Comments: CC BY-SA 4.0
Comments: 2019-04-24T13:03:59.963Z
Comments: Do you have a `package.json` file in the current directory? Is the drive where your files are saved currently shared to docker (part of the docker preferences) and have you attempted to reset the credentials? Try running `docker run -it --rm -v "$(pwd):/app" busybox ls -l /app` and show the output (replacing `$(pwd)` with your current directory if you aren't in a bash shell).
Comments: BMitch
Comments: CC BY-SA 4.0
Comments: 2019-04-24T13:05:16.820Z
Comments: I've edited the question for code formatting and taken my best guess for the indentation of your compose file. Note that whitespace is important in a compose file, so make sure to post that with the same indentation in questions.
Comments: BMitch
Comments: CC BY-SA 4.0
Comments: 2019-04-24T19:34:23.657Z
Comments: Thanks BMitch, I tried to format the docker compose but was not able to to do, I am away from my machine and It will try your solution by tomorrow and post my reply back here. Once again thank you all for your response.
Comments: Jophin Michael
Comments: CC BY-SA 4.0
Comments: 2019-04-25T14:14:57.033Z
Comments: Hi BMitch, This is the response I get,                                                                  
                                                                                                                              $ docker run -it --rm -v "$(pwd):/app" busybox ls -l /app
                                                                                                                           the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'
Comments: Jophin Michael
Comments: CC BY-SA 4.0
Comments: 2019-04-25T16:44:55.367Z
Comments: Have you shared the correct windows drive (most likely C:/ or D:/) to your docker containers? https://rominirani.com/docker-on-windows-mounting-host-directories-d96f3f056a2c
Comments: Preston Martin
Comments: CC BY-SA 4.0
Comments: 2019-04-25T17:27:20.763Z
Comments: Yes PrestonM, mine is windows machine, so I tried in git bash where $(pwd) works. I wrote an entirely new node application, I am getting the same error when trying to do Docker build. Looks like something wrong with my machine in particular.
Comments: Jophin Michael
Tags: <docker>
Title: Error with declaring volumes in Docker-compose, 'no such file or directory, open '/app/package.json'
UserDisplayName: Jophin Michael
ThreadText: # Error with declaring volumes in Docker-compose, 'no such file or directory, open '/app/package.json'
  
  (Asked by: username_0 on 2019-04-21)
  
  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.
  
  ```
  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 254
  
  ```
  
  Dockerfile.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:3000"
      volumes:
        - /app/node_modules
        - .:/app
    test:
      build:
        context: .
        dockerfile: Dockerfile.dev
      volumes:
        - /app/node_modules
        - .:/app
      command: ["npm", "run", "test"]
  
  ```
  
  My directory structure as as shown below,
  
  [![enter image description here](https://i.sstatic.net/e7aZO.png)](https://i.sstatic.net/e7aZO.png)
  
  Executed the below statement and the corresponding response,
  
  ```
  $ docker run -it --rm -v "$(pwd):/app" busybox ls -l /app
  
  the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'
  
  ```
  
  Update: 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.
  
  **Tags:** docker
  
  > **Comments:**
  > **username_1**: When you ask a question; please make everything in your power to make it look good. People will just ignore a question that is not properly formatted. https://devops.stackexchange.com/help/how-to-ask  
  > **username_2**: Can you try using double quotes in source file name .  
  > **username_3**: Do you have a `package.json` file in the current directory? Is the drive where your files are saved currently shared to docker (part of the docker preferences) and have you attempted to reset the credentials? Try running `docker run -it --rm -v "$(pwd):/app" busybox ls -l /app` and show the output (replacing `$(pwd)` with your current directory if you aren't in a bash shell).  
  > **username_3**: I've edited the question for code formatting and taken my best guess for the indentation of your compose file. Note that whitespace is important in a compose file, so make sure to post that with the same indentation in questions.  
  > **username_0**: Thanks username_3, I tried to format the docker compose but was not able to to do, I am away from my machine and It will try your solution by tomorrow and post my reply back here. Once again thank you all for your response.  
  > **username_0**: Hi username_3, This is the response I get,                                                                                                                                                                                               $ docker run -it --rm -v "$(pwd):/app" busybox ls -l /app                                                                                                                          the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'  
  > **username_4**: Have you shared the correct windows drive (most likely C:/ or D:/) to your docker containers? https://rominirani.com/docker-on-windows-mounting-host-directories-d96f3f056a2c  
  > **username_0**: Yes PrestonM, mine is windows machine, so I tried in git bash where $(pwd) works. I wrote an entirely new node application, I am getting the same error when trying to do Docker build. Looks like something wrong with my machine in particular.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-05-05. Score: 1
  
  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 username_3 was suggesting the same solution, but I was a completely beginner and I did not comprehend it well. Thanks everyone for your responses.
  
  
  ---
  
  