Hi I wanted to develop create-react-app
based project using docker without installing NodeJS
on my machine. I have this Dockerfile.dev
file
FROM node:lts
VOLUME ./:/usr/src/app # mount my react project on container
WORKDIR /usr/src/app
RUN npm install
RUN npm start
However, when I run docker build -f .\\Dockerfile.dev .
I get this error
npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
I can see that maybe the VOLUME
command wasn't successful. How do I fix or make it work? Maybe docker-compose is better?
PS: I don't want to copy project files, since it's not production or deployment scenario, and auto refresh on file change won't work.
VOLUME in Dockerfile is not what you need , just use -v option and set your dockerfile as :
FROM node:lts
WORKDIR /usr/src/app
CMD npm install && npm start
build and start the container:
docker build -t MYIMAGE . && docker run -tid -v ./app:/usr/src/app MYIMAGE
compose:
volumes:
- ./app:/usr/src/app
command:
docker-compose up -d --build
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.