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/

相关推荐
FrankYoou2 小时前
Jenkins 与 GitLab CI/CD 的核心对比
java·docker
隆里卡那唔2 小时前
在dify中通过http请求neo4j时为什么需要将localhost变为host.docker.internal
http·docker·neo4j
疯子的模样2 小时前
Docker 安装 Neo4j 保姆级教程
docker·容器·neo4j
Lpy25696 小时前
Docker Desktop 安装到D盘(包括镜像下载等)+ 汉化
运维·docker·容器
hunjinYang6 小时前
Tomcat镜像实战:掌握Dockerfile的编写以及发布项目
docker·tomcat
好奇的菜鸟7 小时前
Docker 配置项详解与示例
运维·docker·容器
Connie14518 小时前
k8s多集群管理中的联邦和舰队如何理解?
云原生·容器·kubernetes
IT成长日记12 小时前
【Docker基础】Docker数据卷管理:docker volume inspect及其参数详解
运维·docker·容器·volume·inspect
伤不起bb12 小时前
Kubernetes 服务发布基础
云原生·容器·kubernetes
ladymorgana13 小时前
【Docker】如何设置 `wiredTigerCacheSizeGB` 和 `resources.limits.memory`
运维·docker·容器