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/

相关推荐
♛识尔如昼♛12 分钟前
SONiC (5) - SONiC 的架构
docker·数据中心·sonic·lldp·sonic 架构
ljp111230 分钟前
UNRaid安装chfs
docker·免费·文件共享
昵称为空C43 分钟前
Spring Boot 项目docker分层镜像构建案例
spring boot·ci/cd·docker
kali-Myon1 小时前
快速解决 Docker 环境中无法打开 gdb 调试窗口以及 tmux 中无法滚动页面内容和无法选中复制的问题
运维·安全·docker·容器·gdb·pwn·tmux
管理大亨1 小时前
ELK + Redis Docker 企业级部署落地方案
大数据·运维·elk·elasticsearch·docker·jenkins
一周困⁸天.2 小时前
K8S-网络组件 Calico
网络·容器·kubernetes
pblh1232 小时前
基于Docker部署测试PySpark
运维·docker·容器
IT_mingY2 小时前
k8S网络概述——详细理论知识
网络·容器·kubernetes
yBmZlQzJ2 小时前
财运到内网穿透-群晖NAS安装(docker版本)
运维·经验分享·网络协议·docker·容器
白学还是没白学?3 小时前
exec db docker from A to B
数据库·docker·容器