I built an image from a docker file to run node and copy in a simple node express app which works perfectly. The image builds I can run a container and bash in and the local
When your docker-compose.yml
says
volumes:
- ./:/usr/src/app
it hides everything that gets done in the Dockerfile and replaces it with the current directory. If your current directory doesn't have the package.json
file (maybe you moved everything Docker-related into a subdirectory) it will cause the error you see.
Personally I would just remove these two lines, develop my application locally (without Docker, using the per-project node_modules
directory for isolation), and only build the Docker image when I'm actually ready to deploy it.