Should be able to serve apps inside Docker containers.
Container mounts correctly and the server starts but cannot be connected to on the host machine.
myTodoAppdocker run -it -p 4200:4200 -v $PWD:/home/node node:12 yarn --cwd /home/node nx serve myTodoApp --host=0.0.0.08.5.0Docker version 19.03.2, build 6a30dfcThe issue is caused by --host=0.0.0.0 being ignored by dev-server.impl.ts at line 79
If I remove the check allowing 0.0.0.0 through, I can then connect to the server. I use docker to run related Nx apps together during development.
Sorry, my knowledge of docker is limited.
Why is passing the host necessary? Also, it replaces the value with localhost.. Is that invalid for some reason?
@FrozenPandaz when inside a docker container, localhost refers to the docker container and not the host, so effectively it is only allowing connections from within the container
Yes @FrozenPandaz, @xtiancapil is right. Although for other projects, here is a bit more info; brief explanations of basically the same issue with inside / outside container host / port binding:
SO: docker-empty-response-from-server
SO: err-empty-response-from-docker-container
SO: running-rust-on-docker-empty-reply-from-server
@ckokotas's observation that line 79 of dev-server.impl.ts should probably not replace a passed in param _0.0.0.0_ with _localhost_ seems like it would fix the problem, although I don't know what other implications that would have.
Based on the code it looks like the only thing it can affect is live reloading.
Folks, are you interesting in seeing if it affects live reloading? If yes, we can leave the check as is and maybe another flag. If not, we can just remove it.
Fixed by #2129 馃帀
Most helpful comment
Based on the code it looks like the only thing it can affect is live reloading.
Folks, are you interesting in seeing if it affects live reloading? If yes, we can leave the check as is and maybe another flag. If not, we can just remove it.