Centos7+docker 19.03.8 运行正常,废话不多说。直接上代码,解释看下方。
version: '3'
services:
nginx:
# 容器名称
container_name: "compose-nginx"
image: nginx:latest
restart: always
# 端口映射
ports:
- "80:80"
- "443:443"
environment:
- TZ=Asia/Shanghai
# 依赖关系 先跑php
depends_on:
- "php"
# 数据卷
volumes:
# 映射主机./conf.d目录到容器/etc/nginx/conf.d目录
- "/data/nginx/conf.d:/etc/nginx/conf.d"
- "/data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf"
- "/data/nginx/html:/usr/share/nginx/html"
- "/data/nginx/log:/var/log/nginx/"
networks:
app_net:
ipv4_address: 10.10.10.2
php:
build: ./php-extension
image: php:7.4
restart: always
ports:
- "9000:9000"
volumes:
- "/data/nginx/html:/var/www/html"
- "/data/php74/etc:/usr/local/etc"
- "/data/php74/log:/var/log/php"