I installed polymer in nodeJs docker 4.4.7
docker run -it --name polymer-test -h polymer -p 8080:8080 -v $PWD:/host node:4.4.7 bash
useradd -s /bin/bash -m user
npm install -g polymer-cli
npm install -g bower
su - user
polymer init app-drawer-template
bower install # (if not run automatically)
polymer serve
Then from the host I tried to access it using a browser but the connection kept reseted.
From local aspect curl -v "http://127.0.0.1:8080" worked as expected.
I opened a tcpdump listener inside the docker and all the connection from the out side has been logged as expected.
I also tried python -m SimpleHTTPServer 8080 and http-server. They both worked.
Any idea?
Try polymer serve --hostname 0.0.0.0
@gwu , thanks, that worked.
Any reason why its not set as default like other servers? I guess it can also be useful to mention this in the relevant docs.
Thanks @gwu! @mbn18 feel free to create a PR to add this info to the README
Done, https://github.com/Polymer/polymer-cli/pull/322
@FredKSchott , will it be useful to add 3-4 lines to the README that describe how to run the server using docker? Kinda helpful when you wish to use version that is not available on the host platform.
I just got a chance to look into https://nodejs.org/api/http.html#http_server_listen_port_hostname_backlog_callback
If the hostname is omitted, the server will accept connections on any IPv6 address (::) when IPv6 is available, or any IPv4 address (0.0.0.0) otherwise. Use a port value of 0 to have the operating system assign an available port.
If we adopted this same behavior, docker would be supported by default, correct? This would also solve https://github.com/Polymer/polymer-cli/issues/301 by defaulting to port 0 to have the OS automatically assign a port.
@mbn18 @gwu does this make sense? Wdyt?
@FredKSchott , I agree. If this is the consensus, why implant it differently?
@mbn18 exactly :) Lets change our default behavior to match Node's HTTP agent. @mbn18 any interest in tackling this?
/cc @justinfagnani
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Try
polymer serve --hostname 0.0.0.0