docker / getting-started

Getting started with Docker
Apache License 2.0
2.91k stars 6.4k forks source link

error Couldn't find a package.json file in "/app" #406

Open byanko55 opened 1 year ago

byanko55 commented 1 year ago

I've followed the tutorial section "using-docker-compose" on Ubuntu 20.04.6 LTS on WSL.

When I run the below commands, the app container does not appear in the running container list; it just showed up being terminated as seen from the output of docker ps -a.

docker run -dp 3000:3000 \
  -w /app -v "$(pwd):/app" \
  --network todo-app \
  -e MYSQL_HOST=mysql \
  -e MYSQL_USER=root \
  -e MYSQL_PASSWORD=secret \
  -e MYSQL_DB=todos \
  node:18-alpine \
  sh -c "yarn install && yarn run dev"

image

The execution log of todo-app is

$ 
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 0.03s.
yarn run v1.22.19
error Couldn't find a package.json file in "/app"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Is there any solution?