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/

相关推荐
随便做点啥39 分钟前
32卡-64G-910B4-16后端-(Qwen3.8-27B-W8A8)集群部署报告
运维·服务器·经验分享·docker·vllm
CJY6217 小时前
k8spod管理
云原生·容器·kubernetes
Orange_sparkle10 小时前
从 Docker 到 Doris:建立后端基础设施全景图
运维·docker·ai·容器·claude code
gx234811 小时前
控制器管理
docker·容器·kubernetes
白清羽12 小时前
7.3系统安装docker
运维·docker·容器
dazhong201214 小时前
Docker 入门篇(八)-- CentOS7 安装 MySQL 8
mysql·docker·容器
w2005122415 小时前
Pod管理
linux·服务器·云原生·容器·k8s·podman
典典分享指南16 小时前
用大模型把写作 SOP 变成可复用 Prompt
docker·jupyter·eclipse·phpstorm·myeclipse
sryyd_0216 小时前
Kubernetes Pod 管理从入门到实战:命令、YAML 与生命周期全解析
云原生·容器·kubernetes
Larru-Sun19 小时前
从零开始用 Docker 部署 Node.js 后端服务
docker·容器·node.js