1、拉取镜像
docker pull nginx:1.25.4
2、配置nginx路径
mkdir -p /data/nginx/html mkdir -p /data/nginx/log mkdir -p /data/nginx/conf
3、启动nginx
docker run -p 80:80 -d --name nginx nginx:1.25.4
#拷贝配置,容器ID查看命令:docker ps
docker cp fdafd05e248c:/etc/nginx/nginx.conf /data/nginx/conf/nginx.conf
docker cp fdafd05e248c:/etc/nginx/conf.d /data/nginx/conf/conf.d
docker cp fdafd05e248c:/usr/share/nginx/html /data/nginx
4、重启nginx
#停止容器 docker stop fdafd05e248c标签:data,nginx,html,conf,docker,安装,80,docke From: https://www.cnblogs.com/sxpdy8571/p/18337197
#删除容器
docker rm fdafd05e248c
#启动nginx
docker run -d -p 80:80 --name nginx --privileged --restart always -v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/conf/conf.d:/etc/nginx/conf.d -v /data/nginx/html:/usr/share/nginx/html -v /data/nginx/log:/var/log/nginx nginx:1.25.4