编写docker-compose.yml

  1. version: "3"
  2. services:
  3. web:
  4. container_name: nginx
  5. image: nginx:1.18.0
  6. restart: always
  7. ports:
  8. - 80:80
  9. volumes:
  10. - ./html:/usr/share/nginx/html
  11. - ./nginx.conf:/etc/nginx/nginx.conf
  12. - ./conf.d:/etc/nginx/conf.d
  13. - /home/data/nginx/logs:/var/log/nginx

nginx.conf配置

从官网下载对应版本的配置放到同一目录下即可
http://nginx.org/ru/download.html

启动服务

  1. docker-compose up -d