nginx docker-compose版本
version: '3'
services:
nginx:
image: nginx:latest
container_name: nginx
ports:
- "80:80"
- "443:443"
# 注意:首次启动,需要先注释掉volumes,启动后把docker容器中的文件复制(docker cp)到对应目录后,再放开注释。
volumes:
- /opt/nginx/conf/:/etc/nginx/
- /opt/nginx/html/:/usr/share/nginx/html/
- /opt/nginx/logs/:/var/log/nginx/
# 简化版
# - /opt/nginx/nginx.conf:/etc/nginx/nginx.conf
restart: always