在Docker中运行Angular2应用程序
我试图在docker中运行我的ng2应用程序。 我有Docker文件:
FROM ubuntu:latest RUN apt-get update #Install curl & git RUN apt-get -qq -y install curl RUN apt-get install -yqq git #Download and install nodejs-6 RUN curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh RUN bash nodesource_setup.sh RUN apt-get install -yqq nodejs RUN apt-get install -yqq build-essential RUN npm install -g angular-cli #Clone the project RUN git clone https://github.com/moravianlibrary/RecordManager2.git WORKDIR /RecordManager2 #Checkout webapp_jobs_branch RUN git checkout webapp_jobs_branch #Go to the gui directory WORKDIR /RecordManager2/cz.mzk.recordmanager.webapp.gui/gui EXPOSE 4200 RUN npm install CMD ["ng", "serve"]
build设和运行完成没有错误:
docker build -t rm-gui . docker run --name gui -dp 4200:4200 rm-gui
运行应用程序后,我可以看到该应用程序真的在运行:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES caa4f1f820d6 rm-gui "ng serve" 23 minutes ago Up 23 minutes 0.0.0.0:4200->4200/tcp gui
但是当我打开页面http://localhost:4200/
我看到一个错误This site can't be reached
。 我究竟做错了什么?
在你的package.json
文件中设置下面的start
命令
"scripts": { "ng": "ng", "start": "ng serve -H 0.0.0.0", ..... },
在你的Dockerfile
最后一行代替
CMD ["npm", "start"]
- NGINX不与烧瓶restAPI通信。 docker
- 错误:HTTP请求响应时间
- Angular2在Docker中找不到module:'./class'
- 我如何使用Docker和Angular做实时更改重装?
- 量angular器testing在Jenkins的Docker中随机超时,在本地Docker中正常工作
- 为了开发目的,需要“app / dist”作为卷的一部分时,不能在容器中生成“app / dist”
- 在Docker上运行angular2 springboot应用程序,它显示索引页面,但没有加载angular度
- 混合应用程序中没有使用ion3上的keycloakauthentication
- 似乎无法让我的.Net核心应用程序与SQL Server在Docker容器中工作