docker 安装openresty

bash 复制代码
docker pull openresty/openresty

mkdir -p /root/docker/openresty/nginx
mkdir -p /root/docker/openresty/nginx/lua
mkdir -p /root/docker/openresty/nginx/logs

#运行OpenResty容器拷贝配置文件到宿主服务器上
docker run -d --name openresty -p 7000:80 openresty/openresty
docker cp openresty:/usr/local/openresty/nginx/conf /root/docker/openresty/nginx/conf
docker cp openresty:/usr/local/openresty/nginx/html /root/docker/openresty/nginx/html
docker cp openresty:/etc/nginx/conf.d /root/docker/openresty/nginx/conf.d
#删除容器
docker stop openresty
docker rm openresty
#在/root/docker/openresty/nginx/conf.d目录下添加一个自己的配置文件demo.com.conf(配置和nginx基本一样)
========================================================
upstream demo.com {
        server ip:port weight=1;
}
server {
    listen       80;
    server_name  localhost;
    location / {
        proxy_pass http://demo.com;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/local/openresty/nginx/html;
    }
========================================================

#使用挂载配置文件启动窗口
docker run -d \
--privileged=true \
--restart=always \
--name openresty \
-p 80:80 \
-p 8000:8000 \
-v /root/docker/openresty/nginx/conf:/usr/local/openresty/nginx/conf/:rw \
-v /root/docker/openresty/nginx/conf.d:/etc/nginx/conf.d/:rw \
-v /root/docker/openresty/nginx/html:/usr/local/openresty/nginx/html/:rw \
-v /root/docker/openresty/nginx/logs:/usr/local/openresty/nginx/logs/:rw \
-v /root/docker/openresty/nginx/lua:/usr/local/openresty/nginx/lua/:rw \
openresty/openresty

#浏览器访问:

http://192.168.31.159/

相关推荐
古人诚不我欺15 分钟前
kubeadm安装K8s高可用集群之集群初始化及master/node节点加入calico网络插件安装
云原生·容器·kubernetes
爱学测试的李木子3 小时前
Docker常用命令总结~
运维·软件测试·测试工具·docker·容器
流穿4 小时前
ELK系列-(五)指标收集-MetricBeat(上)
ubuntu·elk·elasticsearch·docker
元气满满的热码式5 小时前
Centos7.9安装docker
运维·docker·容器
China_Yanhy5 小时前
[k8s]报错:Cannot connect to the Docker daemon at unix:///var/run/docker.sock
docker·kubernetes·unix
菜鸟恒6 小时前
Linux下安装docker
linux·docker·eureka
杨半仙儿还未成仙儿6 小时前
docker如何学习与使用入门
学习·docker·容器
勇-子6 小时前
K8s中 statefulset 和deployment的区别
云原生·容器·kubernetes
好看资源平台7 小时前
Docker日志与监控
docker
Smile丶凉轩7 小时前
Docker的存储卷
运维·docker·容器