docker环境安装部署openresty
#拉取openresty镜像
docker pull openresty/openresty
#首次构建容器 得到配置文件 default.conf
docker run -p 90:90 -d --name openresty openresty/openresty
#查看容器是否构建成功
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f391882e0557 openresty/openresty "/usr/bin/openrest..." 13 seconds ago Up 12 seconds 0.0.0.0:90->90/tcp openresty
#进入容器
docker exec -it openresty bash
#查看配置文件地址 /etc/nginx/conf.d
root@f391882e0557:/# cd /etc/nginx/conf.d/
root@f391882e0557:/etc/nginx/conf.d# pwd
/etc/nginx/conf.d
#退出容器
root@f391882e0557:/etc/nginx/conf.d# exit
exit
#创建宿主机映射目录
mkdir /docker/openresty/conf
#拷贝容器配置文件到宿主机指定目录
docker cp openresty:/etc/nginx/conf.d/default.conf default.conf
#停止并删除容器 openresty
[root@localhost conf]# docker stop openresty
openresty
[root@localhost conf]# docker rm openresty
openresty
#重新构建容器openresty 并映射配置以及项目目录
docker run -p 90:90 -d --name openresty -v /docker/openresty/conf/default.conf:/etc/nginx/conf.d/default.conf -v /docker/www:/docker/www --privileged=true openresty/openresty
版权声明:本文为sinat_38926283原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。