Starting npm start with docker?

17,194

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

Share:
17,194

Related videos on Youtube

Nespony
Author by

Nespony

Updated on September 15, 2022

Comments

  • Nespony
    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 Sharma
      Prakash Sharma
      Make sure in your app you are running the server at 80 port and in your browser you are hitting 6000 port.
    • Prakash Sharma
      Prakash Sharma
      What command are you using to run docker container?

Related