[英]Problem accessing dockerized node application from outside of container
i have been trying to dockerize an angular project, using Docker Desktop for windows, with linux containers, and Hyper-V.我一直在尝试使用 windows 的 Docker 桌面和 ZE206A、0CC4E97670EE89CCEZ5 容器来对接 angular 项目。
Here is my dockerfile:这是我的 dockerfile:
FROM node:alpine
WORKDIR /var/app
EXPOSE 4200
COPY package*.json ./
COPY proxy*.json ./
COPY . .
RUN npm install @angular/cli -g
#Custom dependencies
RUN npm config set registry http://maven.corp.com.br:8081/artifactory/api/npm/
RUN npm install
RUN npm run build:dev
ENTRYPOINT npm start
i build it and can run it just fine with:我构建它并可以很好地运行它:
docker build -t name .
docker run -p 4200:4200 name
The problem is, when i try to access https://localhost:4200 from my windows pc, i get ERR_CONNECTION_CLOSED.问题是,当我尝试从我的 windows 电脑访问https://localhost:4200时,我得到 ERR_CONNECTION_CLOSED。
However, if i go into the container cli, and use Links (the command line web browser https://i.imgur.com/jwhD9cm.gif ) to access the url, it works just fine, i'm just having issues trying to access it from my windows pc. However, if i go into the container cli, and use Links (the command line web browser https://i.imgur.com/jwhD9cm.gif ) to access the url, it works just fine, i'm just having issues trying从我的 windows 电脑访问它。
I tried using the host.docker.domain dns aswell but no success.我也尝试使用 host.docker.domain dns 但没有成功。
Any help will be greatly appreciated.任何帮助将不胜感激。
Thanks!谢谢!
Thank you very much @paltaa, all i had to do was change from "npm start" to a custom "ng serve" with the flag --host 0.0.0.0"非常感谢@paltaa,我所要做的就是从“npm start”更改为带有标志的自定义“ng serve”--host 0.0.0.0”
change ENTRYPOINT npm start
to将ENTRYPOINT npm start
更改为
ENTRYPOINT npm start -- --host 0.0.0.0 --disable-host-check
or update package.json
或更新package.json
"start": "ng serve --host 0.0.0.0 --disable-host-check",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.