Starting npm start with docker?
Solution 1
I suspect that your ports might be backwards in your docker run
command. If you are running your react app on port 6000, and want to expose this to the outside on port 80, then you should run your container with ...
docker run -p 80:6000 myapp
Usage: docker run -p <HOST_PORT>:<CONTAINER_PORT> <APP_NAME>
Solution 2
Solved a similar issue by modifying npm start into package.json (line 6).
Try to add --host 0.0.0.0 after ng serve.
"start": "ng serve --host 0.0.0.0",
In last result, debug with curl http://localhost:6000
It might be called a websocket issue
Related videos on Youtube
Nespony
Updated on September 15, 2022Comments
-
Nespony over 1 year
Hi I'm running a basic react project with npm and I'm trying to start it in a docker container. However I can't actually get the project to run. My dockerfile looks like this:
FROM node:7.8.0 WORKDIR / ADD . / EXPOSE 80 RUN npm install ENTRYPOINT npm run start
I get the relevant message saying that the project can now be viewed but in the browser nothing shows up. Any help would be appreciated.
-
Prakash SharmaMake sure in your app you are running the server at
80
port and in your browser you are hitting6000
port. -
Prakash SharmaWhat command are you using to run docker container?
-