(版本号)
docker pull nginx:1.17.8
docker run --name nginx -p 9091:80 -d nginx:1.17.8
mkdir -p /data/nginx/{conf,conf.d,html,logs}
## 拷贝配置文件
docker cp 1022c6f181b9:/etc/nginx/nginx.conf /data/nginx/conf/nginx.conf ## 映射容器目录
docker cp 1022c6f181b9:/etc/nginx/conf.d/default.conf /data/nginx/conf.d/default.conf ## 复制映射容器目录
- 挂载并启动nginx
docker run -p 9091:80 --name nginx --privileged=true -v /data/nginx/html:/usr/share/nginx/html -v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf -v /data/nginx/logs:/var/log/nginx -d nginx:1.17.8
命令说明:
–privileged=true 配置了nginx.conf的外部挂载 之后可能导致nginx不能启动,使用该命令;
-v /data/conf.d/default.conf:/etc/nginx/conf.d/default.conf 挂载默认配置文件
-v /data/conf/nginx.conf:/etc/nginx/nginx.conf 挂载nginx.conf文件
-v /data/logs:/var/log/nginx 挂载日志目录
-v /data/html:/usr/share/nginx/html 挂载html目录
标签:default,nginx,html,conf,docker,data From: https://www.cnblogs.com/ydg123/p/18126426