ng-angular image的DockerFile
FROM node:8
MAINTAINER NG
EXPOSE 4200
RUN npm install
RUN npm install -g @angular/cli
docker-compose.yml
version: '3'
services:
node:
image: ng-angular
container_name: ng-angular1
working_dir: /home/node
ports:
- 4200:4200
ng服务输出
* Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2019-01-30T10:28:28.001Z
Hash: b43d4abc7ff424082a0f
Time: 13641ms
chunk {main} main.js, main.js.map (main) 11.5 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 236 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.4 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.75 MB [initial] [rendered]
ℹ 「wdm」: Compiled successfully.
我想念什么?我无法访问http://localhost:4200/
答案 0 :(得分:0)
docker-compose run -p 4200:4200 node bash
才能发布端口4200并在节点服务上运行bash。--host 0.0.0.0
必须作为ng serve
命令的参数传递。