lwsjs / local-web-server

A lean, modular web server for rapid full-stack development.
MIT License
1.2k stars 85 forks source link

Cannot find the port when running in docker #179

Closed Superhzf closed 1 year ago

Superhzf commented 1 year ago

Hi there,

This works fine locally. However, when I try to move it into a docker container, the server cannot find the correct port. My docker file looks like this:

FROM node:18.12.1

ENV NODE_ENV=production
WORKDIR /fronted
RUN npm install -g local-web-server
COPY . .
CMD [ "ws", "--port 30" ]

Then, if I run docker run -dp 30:30 frontend-server, and then docker logs -f <container-id> it shows Listening on http://8ab29995624f:null, http://127.0.0.1:null, http://172.17.0.2:null. I expect null to be 30.

75lb commented 1 year ago

Try changing this line

CMD [ "ws", "--port 30" ]

to this

CMD [ "ws", "--port", "30" ]
Superhzf commented 1 year ago

Try changing this line

CMD [ "ws", "--port 30" ]

to this

CMD [ "ws", "--port", "30" ]

Thank you so much for your quick reply, that works!

Now, in the docker it shows Listening on http://5f80a3af8967:30, http://127.0.0.1:30, http://172.17.0.2:30. But I can only open the page with http://127.0.0.1:30. http://5f80a3af8967:30 and http://172.17.0.2:30 are not loading up, is it normal? If I run without docker, all three sites work perfectly.

75lb commented 1 year ago

http://5f80a3af8967:30 and http://172.17.0.2:30 are not loading up, is it normal? If I run without docker, all three sites work perfectly.

it could be normal - i don't know how you have networking/routing/DNS/WIN etc set up on your machine or container.. Closing as beyond the scope of ws..