我设置了一个docker容器,它将在this article之后在nginx服务器上为我的Angular 5应用程序提供服务。
文章提出了这个Dockerfile:
# Stage 0, based on Node.js (for npm) to build and compile the Angular application.
FROM node:8.11.2 as node
WORKDIR /app
COPY package.json /app/
RUN npm install
COPY ./ /app/
ARG env=prod
# For Angular 6: ARG conf=production
RUN npm run build -- --prod --environment $env
# For Angular 6: RUN npm run build --configuration $conf
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.15
COPY --from=node /app/dist/ /usr/share/nginx/html
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
我想知道:为什么不包括以下内容?
EXPOSE 80
)和RUN /usr/bin/nginx
)文章没有谈到以任何其他方式启动nginx服务器。
答案 0 :(得分:1)
由于您使用的是nginx:1.15
,请查看其Dockerfile:
...
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["nginx", "-g", "daemon off;"]
答案 1 :(得分:1)
端口暴露指令(例如EXPOSE 80)
EXPOSE
指令比其他任何指令都更多。 documentation for the nginx image告诉您在使用-p 80:80
运行容器时发布端口,这不需要EXPOSE
指令。 EXPOSE 80
允许您出于同一目的使用-P
。
nginx run命令(例如RUN / usr / bin / nginx)
nginx image为您完成此操作:)