Access Angular app running inside Docker container

筅森魡賤 提交于 2019-12-11 17:03:34

问题


I've created a docker image to test an Angular app but I cannot connect from host to running app inside docker container.

The image was created using a Dockerfile with: EXPOSE 4200 8080 80

I run the docker container with command: docker run -ti -p 4200:4200 angulardev /bin/bash

Inside container I create the Angular application and start it using: ng serve

From container, if I open localhost:4200 I see the application but I cannot access it from host OS (RHEL7)

What is wrong? The Angular app starts on port 4200 which is exposed and mapped to host 4200.

Thanks.


回答1:


If you are running angular app inside your container with just ng serve it won't allow other hosts from accessing it.

Instead you should run it using ng serve --host 0.0.0.0 --port 4200



来源:https://stackoverflow.com/questions/48633244/access-angular-app-running-inside-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!