-1

im Starting a Dev-Mode Container in docker. the documentation says this line

docker run -dp 3000:3000 -w /app -v $PWD:/app node:10-alpine sh -c "yarn install && yarn run dev"

however this might be for linux im on windows. the rest of the internet are suggesting this

docker run -dp 3000:3000 -w /app -v "%cd%:/app" node:10-alpine sh -c "yarn install && yarn run dev"

this does not return any sort of error just a complicated load of letters and numbers (probably some kind of object or w/e its in the screenshot)

however docker ps suggests nothing is running, no containers are open. also when i open up docker desktop app i can see each time i run the line above i do create a new container it just dies straight away. enter image description here im not doing anything special, why does that container crash on opening? i just want it to run normal.

what further info would be useful?

###################################### edit

following the advice of printing the logs i see that my app cannot find a file. however this leaves me more confused because as the screenshot shows, docker is looking in the right place and the files really are there.

enter image description here

  • You can use `docker logs` to check why the containers stopped – Alvaro Flaño Larrondo Jan 04 '21 at 12:21
  • Are you using Powershell? Do you actually have your app in the current directory? – Alvaro Flaño Larrondo Jan 04 '21 at 12:45
  • 1 second more evidence to come – tgm_jack_uk Jan 04 '21 at 13:08
  • If the `package.json` was not found, it seems that the volume mounting was performed incorrectly. Apart from this, SO guides that error logs that can be expressed in text such as docker logs in your explanation are written in text format rather than images. It looks like it needs to be rewritten by following the guide below. [how-to-ask](https://stackoverflow.com/help/how-to-ask) – myeongkil kim Jan 04 '21 at 13:15
  • `package.json` appears to be in `C:\Users\tgmjack\app`. Not `C:\Users\tgmjack`. Can you change `"%cd%:/app"` to `"%cd%/app:/app"`? – myeongkil kim Jan 04 '21 at 13:18

1 Answers1

0

The folder mounted is C:\Users\tgmjack and it should be C:\Users\tgmjack\app because that is the folder containing the package.json file.

So you should run docker run -dp 3000:3000 -w /app -v "%cd%:/app" node:10-alpine sh -c "yarn install && yarn run dev" from the C:\Users\tgmjack\app folder.

Alvaro Flaño Larrondo
  • 5,516
  • 2
  • 27
  • 46