web容器Dockerfile:
FROM node:latest MAINTAINER YW RUN mkdir -p /home/projects/web WORKDIR /home/projects/web COPY . /home/projects/web RUN npm install RUN npm run build EXPOSE 9999 CMD [ "npm", "start"]
docker-compose文件怎么用nginx映射到web容器暴露的9999端口中,https又怎么用呢,多域名又如何配置呢?
version: '3.1' services: web: build: . container_name: web restart: always network_mode: host
跪求大佬指点
如果nginx也是容器,不需要端口映射,直接把整个服务映射进去
services: web: ... nginx: ... depends_on: - web
如果nginx在宿主机上:
services: web: ... ports: - 9999:9999
通过ports属性,把容器的端口映射到宿主机的端口
至于https和多域名,完全就是nginx内部配置了,与docker-compose无关
1.4m articles
1.4m replys
5 comments
57.0k users