了解docker中默认路径
conf
/etc/nginx/nginx.conf
html
/usr/share/nginx/html
log
/var/log/nginx
启动临时容器
docker run --name tmp-nginx-container -d nginx
新建本地目录
mkdir -p /docker/nginx/
拷贝临时容器默认文件到默认路径
docker cp tmp-nginx-container:/etc/nginx/nginx.conf /docker/nginx/nginx.conf docker cp -a tmp-nginx-container:/usr/share/nginx/html /docker/nginx docker cp -a tmp-nginx-container:/etc/nginx/conf.d /docker/nginx
删除临时容器
docker rm -f tmp-nginx-container
重新映射容器启动
docker run --name mynignx -e TZ="Asia/Shanghai" -d -p 80:80 -v /docker/nginx/html:/usr/share/nginx/html -v /docker/nginx/nginx.conf:/etc/nginx/nginx.conf -v /docker/nginx/conf.d:/etc/nginx/conf.d -v /docker/nginx/logs:/var/log/nginx nginx
收刀!!