编写docker-compose.yml
version: "3"
services:
web:
container_name: nginx
image: nginx:1.18.0
restart: always
ports:
- 80:80
volumes:
- ./html:/usr/share/nginx/html
- ./nginx.conf:/etc/nginx/nginx.conf
- ./conf.d:/etc/nginx/conf.d
- /home/data/nginx/logs:/var/log/nginx
nginx.conf配置
从官网下载对应版本的配置放到同一目录下即可
http://nginx.org/ru/download.html
启动服务
docker-compose up -d