1.docker中默认路径
conf /etc/nginx/nginx.conf
html /usr/share/nginx/html
log /var/log/nginx
2.启动临时容器
docker run --name tmp-nginx-container -d nginx
3.新建本地目录
mkdir /usr/docker/nginx/
4.拷贝临时容器默认文件到默认路径
docker cp tmp-nginx-container:/etc/nginx/nginx.conf /usr/docker/nginx/nginx.conf
docker cp -a tmp-nginx-container:/usr/share/nginx/html /usr/docker/nginx
docker cp tmp-nginx-container:/etc/nginx/conf.d /docker/nginx/conf.d
5.删除临时容器
docker rm -f tmp-nginx-container
6.重新映射容器启动
docker run --name mynignx -e TZ="Asia/Shanghai" -d -p 80:80 -v /usr/docker/nginx/html:/usr/share/nginx/html -v /usr/docker/nginx/nginx.conf:/etc/nginx/nginx.conf -v /usr/docker/nginx/conf.d:/etc/nginx/conf.d -v /usr/docker/nginx/logs:/var/log/nginx nginx
7.访问,默认80端口
网友评论