Docker部署nginx

0x00 从容器获取配置文件

docker run -d --rm --name nginx nginx
#跑一个容器停止就删除,为的是获取里面的配置文件
docker cp nginx:/etc/nginx/nginx.conf /opt/nginx/conf/nginx.conf
#将配置文件从容器里cp到宿主机
docker stop nginx
#停止那个容器,这里即删除那个容器

0x01 部署nginx

docker  run -d --name nginx -p 80:80 -v /opt/nginx/html:/usr/share/nginx/html -v /opt/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /opt/nginx/log:/var/log/nginx nginx

0x02 使用

将html放入/opt/nginx/html目录下即可

原文地址:https://www.cnblogs.com/Wuser/p/13303816.html