Open frankchen76 opened 5 years ago
@frankchen76 you need to bind a host port to the container port at runtime. Are you doing docker run
or are you using docker-compose
?
@LaurentGoderre thanks for your response. yes, I used docker run to start my container. the following is my docker run
docker run -it --rm --name spfx-dev --mount type=bind,source=c:/dockerprojects,destination=/usr/app/spfx -p 5432:5432 -p 4321:4321 -p 35729:35729 frank/spfx:SPFx1.8-Node8.15.0
or
docker run -it --rm --name spfx-dev -v /c/dockerprojects:/usr/app/spfx -p 5432:5432 -p 4321:4321 -p 35729:35729 frank/spfx:SPFx1.8-Node8.15.0
it was weird that I used the same docker run for a node 6.11.0 image and had no problem at all.
BTW, do you have ideas why NPM install
got failed somehow?
What is the output of docker ps
?
please see the screenshot below:
So it is bound properly. Are you sure a process is listening on those ports in the container?
@LaurentGoderre while I am going to check if a process is listening on those port in my container, do you know what was the reason to cause NPM install failed. the following came from my npm:
2733 verbose stack Error: node-sass@4.9.3 install: `node scripts/install.js`
2733 verbose stack Exit status 1
2733 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
2733 verbose stack at emitTwo (events.js:126:13)
2733 verbose stack at EventEmitter.emit (events.js:214:7)
2733 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
2733 verbose stack at emitTwo (events.js:126:13)
2733 verbose stack at ChildProcess.emit (events.js:214:7)
2733 verbose stack at maybeClose (internal/child_process.js:915:16)
2733 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
2734 verbose pkgid node-sass@4.9.3
2735 verbose cwd /usr/app/spfx/spfx2
2736 verbose Linux 4.9.125-linuxkit
2737 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "node-sass@4.9.3" "--unsafe-perm=true" "--allow-root"
2738 verbose node v8.15.0
2739 verbose npm v6.4.1
2740 error code ELIFECYCLE
2741 error errno 1
2742 error node-sass@4.9.3 install: `node scripts/install.js`
2742 error Exit status 1
2743 error Failed at the node-sass@4.9.3 install script.
2743 error This is probably not a problem with npm. There is likely additional logging output above.
2744 verbose exit [ 1, true ]
if I install it from node without using docker, it was fine. There are a few articles to mention this was caused by node.js for mount volume. do you have ideas about that? Thanks
My first guess for a culprit would be using npm install
using the root
user instead of node
user. If you add -u node
to your command, do you get the same error?
I just tried what you suggested as the following. But unfortunately, I still got same error message.
docker run -it --rm --name spfx-dev -v /c/dockerprojects:/usr/app/spfx -p 5432:5432 -p 4321:4321 -p 35729:35729 -u node frank/spfx:SPFx1.8-Node8.15.0
error:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.3 install: node scripts/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.9.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-03-28T16_57_46_805Z-debug.log
I'm having the similar issue. Built the image with no problem and got the container running no problem. The port mapping is correct. Just couldn't access the node app from localhost on my host browser.
So it tuned out that I had to use 0.0.0.0 instead of localhost in the hapi app.
Hi there, I'm facing the same issue. Trying docker for the first time.
docker run -p 80:3000 [my_node_app_image]
in my dockerfile : EXPOSE 3000
Server runs on container and listens to port 3000 (as per my console.log msg) but no response when I request localhost or even 0.0.0.0
The app works fine locally, no response when running on docker container.
Any ideas? How can I further investigate the issue? Where should I look? Many thanks
Container running, see ports mapping (docker ps):
Node app running:
Alright, never mind guys. Used the container's ip address. Got my response.
docker-machine ip
Have a nice day ::)
I had similar issue, I'm on Windows, and have Kaspersky internet security which caused this issue by some firewalls rules. Just check your firewall, sometimes it causes problems with mounting your directories or mapping the ports.
try to use docker machine ip and the port number whichever you have provided.
for getting docker machine ip, use docker-machine ip
suppose you got 192.168.99.100 then after colon write port such as : 1880
finally as
http://192.168.99.100:1880/
Hi,
I am trying to use node:8.15.1 version for SharePoint Framework development. I use the following Dockerfile to create my image. however, when I access https://localhost:4321/temp/workbench.html from my host laptop, I got "this site can't be reached" error from my browser. I see my container showed "Request: [::ffff:172.17.0.1] '/workbench'" and there is nothing out. Please see below for my configurations: host: windows 10 v1809 docker: Dcoker desktop for windows. v2.0.0.3. Build: 8858db3 Dockerfile:
I also have problem to use
NPM install
to restore packages for my project and always got sass installation error.I used node:6.11.0 for SharePoint Framework 1.4.1 and had no problem for that.
Can anyone point me out how to solve localhost request and NPM install issues?
Thanks