Loading... 今天忽然要用一下nginx,但是不需要数据库等其他配件,想起docker应该是挺好用的,尝试了一下。 # 环境准备 安装dockert ``````````````````````````````````````` wget -qO- https://get.docker.com/ | sh ``````````````````````````````````````` # 创建目录 创建www目录以及wwwroot ``````````````````````````````````` mkdir www mkdir wwwroot mkdir conf ``````````````````````````````````` # 创建容器 docker run -d --name nginx nginx 这一步主要是获取conf文件,查看 ==> 获取容器ID docker container ls 拷贝容器内 Nginx 默认配置文件到本地当前目录下的 conf 目录 ``````````````````````````````````````````````````````` docker cp a89b2c5f3dd1:/etc/nginx/nginx.conf $PWD/conf ``````````````````````````````````````````````````````` 删除容器: ```````````````````````````````````````````````` docker stop a89b2c5f3dd1 docker rm a89b2c5f3dd1 ```````````````````````````````````````````````` # 开始正式部署 部署命令: ``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` docker run -d -p 8080:80 --name nginx-web -v $PWD/wwwroot:/usr/share/nginx/html -v $PWD/conf/nginx.conf:/etc/nginx/nginx.conf -v $PWD/logs:/var/log/nginx nginx ``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` 转:https://segmentfault.com/a/1190000015758373 Last modification:August 4, 2020 © Allow specification reprint Like 如果觉得我的文章对你有用,请随意赞赏