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/

相关推荐
曲幽1 小时前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
武子康2 天前
调查研究-183 Apple container:Mac 上用轻量 VM 跑 Linux 容器,Swift 会改写本地容器体验吗?
docker·容器·apple
Alsn865 天前
等待学习-学习目录:Docker 容器安全攻防
学习·安全·docker
2601_961875245 天前
决战申论100题2026|最新|范文
linux·容器·centos·debian·ssh·fabric·vagrant
java_cj5 天前
深入kube-apiserver认证机制:从Bearer Token到mTLS的完整认证链解析
linux·运维·服务器·云原生·容器·kubernetes
程序员老赵5 天前
服务器没有桌面?Docker 跑个 Chrome,浏览器就能远程用
docker·容器·devops
杨浦老苏5 天前
轻量级Docker仪表板Servedash
运维·docker·监控·群晖·仪表板
正经教主5 天前
【docker基础】 第八周:容器监控与应用更新策略
运维·docker·容器
kiros_wang5 天前
Docker 使用完整指南
运维·docker·容器
正经教主5 天前
【docker基础】第九周:Docker安全与镜像优化
运维·docker·容器