Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting npm start with docker?

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.

like image 504
Nespony Avatar asked Oct 14 '17 10:10

Nespony


2 Answers

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

like image 115
Alsushi Avatar answered Oct 28 '22 02:10

Alsushi


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>

like image 37
grizzthedj Avatar answered Oct 28 '22 01:10

grizzthedj