拉取镜像

  1. docker pull nginx

创建配置目录

  1. mkdir -p /data/nginx/conf (nginx.conf)
  2. mkdir -p /data/nginx/conf.d (default.conftest.youliaoke.com.conf)
  3. mkdir -p /data/nginx/html (index.html)
  4. mkdir -p /data/nginx/logs

挂载运行

  1. docker run -d --name nginx-server -p 8088:80 -v /data/nginx/html:/usr/share/nginx/html -v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/conf.d:/etc/nginx/conf.d -v /data/nginx/logs:/var/log/nginx nginx
  2. docker run -d --name nginx-server -p 8088:80 -v /home/cv/ROOT:/usr/share/nginx/html nginx

image.png

访问测试

image.png