思路
1 先run一个nginx
docker run \ --name centos_nginx \ -d -p 80:80 \ -v /usr/local/nginx/html:/usr/share/nginx/html \ -v /usr/local/nginx/logs:/var/log/nginx \ -v /usr/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro \ -v /usr/local/nginx/conf/conf.d:/etc/nginx/conf.d \ nginx
2 进入nginx拷贝nginx.conf
docker exec -it mynginx /bin/bash root@95e2b70fdf49:/# cd /etc/nginx/ root@95e2b70fdf49:/etc/nginx# ls conf.d fastcgi_params koi-utf koi-win mime.types modules nginx.conf scgi_params uwsgi_params win-utf docker cp 95e2b70fdf49:/etc/nginx/nginx.conf /usr/local/nginx/conf/nginx.conf
3 删除run的这个容器
docker rm -f 95e2b70fdf49
4 再次执行带有映射容器的命令
docker run \ --name centos_nginx \ -d -p 80:80 \ -v /usr/local/nginx/html:/usr/share/nginx/html \ -v /usr/local/nginx/logs:/var/log/nginx \ -v /usr/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro \ -v /usr/local/nginx/conf/conf.d:/etc/nginx/conf.d \ nginx